Thank you for your answers! And sorry for the radio silence. I took some of 
your advice and went and studied some javascript and came up with a small 
demo.

More on the workflow: I need updates coming to and going from server 
without page reloads. Not necessarily all of them, but it would make the 
using more smooth. The possible actions are:

   - User chooses different options from dropdown boxes: these don't change 
   data, they just change what data is displayed on the map. Like changing a 
   tab on web browser. But the data is shown on the same page and grid of 
   course.
   - User chooses an action from several options and performs it on a cell, 
   by clicking on it when an action is selected. The program checks, if it's 
   possible, and executes it. This changes data and the changes have to be 
   shown immediately.
   - The player ends a turn. This changes data and the effects have to be 
   shown immediately.

There are some more actions, but those three are the most important ones. 
There are not multiple players playing the game simultaneously. Every 
player has their own game session. They can however save and load, so 
that's why every action that changes data have to be saved to db.

So, I made a very simple HTML/JS demo. It's just quickly thrown together, 
everything is mostly placeholder and I wouldn't be surprised if a few 
errors are mixed in as well. But it shows the main action and what should 
be going on.

Link: https://www.dropbox.com/s/isf38wh9x54pqfj/gm_demo.html?dl=0

The main problems still are:

   - The very question I have, how can I create an HTML table with an 
   algorithm? The algorithm would be something like: 
   function createMap(dataset) {
       createTable{
           width=dataset.width;
           height=dataset.height;
       }
       fillTable{
           for(cell in table){
               cell.onclick = performAction();
               cell.mined=false;
           }
       }
   }
   
   So a table is created according to the dimensions in dataset and every 
   cell is given a function to execute, when onclick event happens. Also some 
   values in database are assigned for the cell (in this example "mined"). Any 
   idea how this should be done?
   - How do you get data to/from database? And without page reloads? This 
   version only has global variables.
   - It seems that innerHTML always converts the content to a string before 
   returning. Luckily JavaScript can convert strings back to numbers on the 
   fly, so no problems in calculations, but on logical operations there are 
   problems. Since "true" and "false are handled as strings, I had to compare 
   them as such.

The problem came up in function giveColor(). If the data we are showing is 
"mined", which is a boolean list, the coloring rule has to check the values 
as strings. Any "proper" solutions?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to