|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ReadOnlyWorld
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.
SKEY
KEY
ITEM
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
| 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 |
|---|
boolean boundsContain(int x,
int y)
boolean boundsContain(FreerailsPrincipal p,
KEY k,
int index)
boolean boundsContain(SKEY k,
int index)
GameTime currentTime()
FreerailsSerializable get(ITEM item)
FreerailsSerializable get(FreerailsPrincipal p,
KEY key,
int index)
FreerailsSerializable get(SKEY key,
int index)
ActivityIterator getActivities(FreerailsPrincipal p,
int index)
Money getCurrentBalance(FreerailsPrincipal p)
int getID(FreerailsPrincipal p)
int getMapHeight()
int getMapWidth()
int getNumberOfPlayers()
int getNumberOfTransactions(FreerailsPrincipal p)
int getNumberOfActiveEntities(FreerailsPrincipal p)
Player getPlayer(int i)
FreerailsSerializable getTile(int x,
int y)
Transaction getTransaction(FreerailsPrincipal p,
int i)
GameTime getTransactionTimeStamp(FreerailsPrincipal p,
int i)
boolean isPlayer(FreerailsPrincipal p)
int size(FreerailsPrincipal p,
KEY key)
int size(SKEY key)
int size(FreerailsPrincipal p)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||