jfreerails.world.top
Interface ReadOnlyWorld

All Superinterfaces:
FreerailsMutableSerializable, java.io.Serializable
All Known Subinterfaces:
World
All Known Implementing Classes:
WorldDiffs, WorldImpl

public interface ReadOnlyWorld
extends FreerailsMutableSerializable

This interface defines a unified set of methods to access the elements that make up the game world. The game world is composed of the following specific-purpose collections into which one can put game world elements.

Example: the following code gets player1's train #5.

TrainModel t = (TrainModel)world.get(KEY.TRAINS, 5, player1);

The motivation for accessing lists using keys is that one does not need to add a new class or change the interface of the World class when a new list is added. Instead one can just add a new entry to the class KEY.

Code that loops through lists should handle null values gracefully

Author:
Luke, Rob

Method Summary
 boolean boundsContain(FreerailsPrincipal p, KEY k, int index)
           
 boolean boundsContain(int x, int y)
           
 boolean boundsContain(SKEY k, int index)
           
 GameTime currentTime()
           
 FreerailsSerializable get(FreerailsPrincipal p, KEY key, int index)
          Returns the element at the specified position in the specified list.
 FreerailsSerializable get(ITEM item)
          Returns the element mapped to the specified item.
 FreerailsSerializable get(SKEY key, int index)
          Returns the element at the specified position in the specified list.
 ActivityIterator getActivities(FreerailsPrincipal p, int index)
           
 Money getCurrentBalance(FreerailsPrincipal p)
           
 int getID(FreerailsPrincipal p)
           
 int getMapHeight()
          Returns the height of the map in tiles.
 int getMapWidth()
          Returns the width of the map in tiles.
 int getNumberOfActiveEntities(FreerailsPrincipal p)
           
 int getNumberOfPlayers()
           
 int getNumberOfTransactions(FreerailsPrincipal p)
           
 Player getPlayer(int i)
           
 FreerailsSerializable getTile(int x, int y)
          Returns the tile at the specified position on the map.
 Transaction getTransaction(FreerailsPrincipal p, int i)
           
 GameTime getTransactionTimeStamp(FreerailsPrincipal p, int i)
           
 boolean isPlayer(FreerailsPrincipal p)
           
 int size(FreerailsPrincipal p)
          Returns number of active entities belonging to the specified principal.
 int size(FreerailsPrincipal p, KEY key)
          Returns the number of elements in the specified list.
 int size(SKEY key)
          Returns the number of elements in the specified list.
 

Method Detail

boundsContain

boolean boundsContain(int x,
                      int y)

boundsContain

boolean boundsContain(FreerailsPrincipal p,
                      KEY k,
                      int index)

boundsContain

boolean boundsContain(SKEY k,
                      int index)

currentTime

GameTime currentTime()

get

FreerailsSerializable get(ITEM item)
Returns the element mapped to the specified item.


get

FreerailsSerializable get(FreerailsPrincipal p,
                          KEY key,
                          int index)
Returns the element at the specified position in the specified list.


get

FreerailsSerializable get(SKEY key,
                          int index)
Returns the element at the specified position in the specified list.


getActivities

ActivityIterator getActivities(FreerailsPrincipal p,
                               int index)

getCurrentBalance

Money getCurrentBalance(FreerailsPrincipal p)

getID

int getID(FreerailsPrincipal p)

getMapHeight

int getMapHeight()
Returns the height of the map in tiles.


getMapWidth

int getMapWidth()
Returns the width of the map in tiles.


getNumberOfPlayers

int getNumberOfPlayers()

getNumberOfTransactions

int getNumberOfTransactions(FreerailsPrincipal p)

getNumberOfActiveEntities

int getNumberOfActiveEntities(FreerailsPrincipal p)

getPlayer

Player getPlayer(int i)

getTile

FreerailsSerializable getTile(int x,
                              int y)
Returns the tile at the specified position on the map.


getTransaction

Transaction getTransaction(FreerailsPrincipal p,
                           int i)

getTransactionTimeStamp

GameTime getTransactionTimeStamp(FreerailsPrincipal p,
                                 int i)

isPlayer

boolean isPlayer(FreerailsPrincipal p)

size

int size(FreerailsPrincipal p,
         KEY key)
Returns the number of elements in the specified list.


size

int size(SKEY key)
Returns the number of elements in the specified list.


size

int size(FreerailsPrincipal p)
Returns number of active entities belonging to the specified principal.