|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface World
This class implements methods which can be used to alter the world. Notice
that incontrast to, say, java.util.List there is no remove()
method that shifts any subsequent elements to the left (subtracts one from
their indices). This means that an elements' position in a list can be used
as an address space independent way to reference the element. If you want to
remove an element from a list, you should set it to null, e.g.
world.set(KEY.TRAINS, 5, null, player);
Code that loops through lists should handle null values gracefully
| Method Summary | |
|---|---|
void |
add(FreerailsPrincipal principal,
int index,
Activity element)
|
int |
add(FreerailsPrincipal principal,
KEY key,
FreerailsSerializable element)
Appends the specified element to the end of the specifed list and returns the index that can be used to retrieve it. |
int |
add(SKEY key,
FreerailsSerializable element)
Appends the specified element to the end of the specifed list and returns the index that can be used to retrieve it. |
int |
addActiveEntity(FreerailsPrincipal principal,
Activity element)
|
int |
addPlayer(Player player)
|
void |
addTransaction(FreerailsPrincipal p,
Transaction t)
Adds the specified transaction to the specified principal's bank account. |
World |
defensiveCopy()
Returns a copy of this world object - making changes to this copy will not change this object. |
FreerailsSerializable |
removeLast(FreerailsPrincipal principal,
KEY key)
Removes the last element from the specified list. |
FreerailsSerializable |
removeLast(SKEY key)
Removes the last element from the specified list. |
Activity |
removeLastActiveEntity(FreerailsPrincipal principal)
|
Activity |
removeLastActivity(FreerailsPrincipal principal,
int index)
|
Player |
removeLastPlayer()
|
Transaction |
removeLastTransaction(FreerailsPrincipal p)
Removes and returns the last transaction added the the specified principal's bank account. |
void |
set(FreerailsPrincipal principal,
KEY key,
int index,
FreerailsSerializable element)
Replaces the element at the specified position in the specified list with the specified element. |
void |
set(ITEM item,
FreerailsSerializable element)
Replaces the element mapped to the specified item with the specified element. |
void |
set(SKEY key,
int index,
FreerailsSerializable element)
Replaces the element at the specified position in the specified list with the specified element. |
void |
setTile(int x,
int y,
FreerailsSerializable tile)
Replaces the tile at the specified position on the map with the specified tile. |
void |
setTime(GameTime t)
|
| Methods inherited from interface jfreerails.world.top.ReadOnlyWorld |
|---|
boundsContain, boundsContain, boundsContain, currentTime, get, get, get, getActivities, getCurrentBalance, getID, getMapHeight, getMapWidth, getNumberOfActiveEntities, getNumberOfPlayers, getNumberOfTransactions, getPlayer, getTile, getTransaction, getTransactionTimeStamp, isPlayer, size, size, size |
| Method Detail |
|---|
int addActiveEntity(FreerailsPrincipal principal,
Activity element)
void add(FreerailsPrincipal principal,
int index,
Activity element)
int add(FreerailsPrincipal principal,
KEY key,
FreerailsSerializable element)
int add(SKEY key,
FreerailsSerializable element)
int addPlayer(Player player)
void addTransaction(FreerailsPrincipal p,
Transaction t)
World defensiveCopy()
Activity removeLastActiveEntity(FreerailsPrincipal principal)
Activity removeLastActivity(FreerailsPrincipal principal,
int index)
FreerailsSerializable removeLast(FreerailsPrincipal principal,
KEY key)
FreerailsSerializable removeLast(SKEY key)
Transaction removeLastTransaction(FreerailsPrincipal p)
Player removeLastPlayer()
void set(ITEM item,
FreerailsSerializable element)
void set(FreerailsPrincipal principal,
KEY key,
int index,
FreerailsSerializable element)
void set(SKEY key,
int index,
FreerailsSerializable element)
void setTile(int x,
int y,
FreerailsSerializable tile)
void setTime(GameTime t)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||