25 June 2015

BoardGame Model

In  this small post i will discuss the game's model. For my first iteration, I've decided  to model  the game's  model on  reality.   Thus, I've  got  a board-game instance that map physical game's objects to abstract / logical one.

The  board-game  is a  singleton instance that contains
  • a map,  formed  by  a map of hexagonal cells. Cells know  their coordinate, their type (and height, since this is linked in this game), as well as their  content (token)
   => 

  • a current turn
  • a tide set, generated using  the game's rules.
  => 
  • a list of players,with all  their attributes (names, action point, tokens  available)
=> 


These elements are  added  to  the  board-game during instantiation. This will allows  an option screen with the ability to generate them depending on the fields filled by the player, and then transmit them to the board-game for starting the game (and thus mimicking  the "set up the game" phase of the physical game).

Events


Any action on the game is made on the board-game :  selection,  movement, next  player,  creation of a unit... Each  of  those actions  may  generate one or more event. For example the "next player" action can generate a "player  selection" event as well a a "new turn" event.

Others components may register themselves as event  listener. Most  of  these listener are graphical  representations of one or more components, as shown in the  pictures higher in  this  post. Listeners  have access to all data of the board-game. As an example, the "Tide" representation shown higher in this post display the current tide, as well as the  future ones, depending on the number of  weather units available to the current  player.

Another  example of  listener  is the  event  logger that  display/log the  list of generated events.  It is  registered  as listener  to all events. A last example would be a listener that send the event onto the network to a distant game. The other user ould see every  game action the current player is performing..

Usage


Currently the screen (state in JME parlor) possess a refercne to this class, as well as a reference to a BoardmapDisplay object. This second object is used to generate the  map geometry, and perform actions (picking and so on). While the modelis a singleton (there is only one game at a moment), there is several child of BoardmapDisplay instanciated at one moment. However only one is used at any point. This allows the selection of a representation over another (for example, the current one display cells as flat hexagons, but I'm working one a 'real' terrain with slope and so on).


 

No comments:

Post a Comment