|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjfreerails.world.top.WorldImpl
public class WorldImpl
An implementation of World that uses standard java.util collections internally.
| Nested Class Summary | |
|---|---|
static class |
WorldImpl.ActivityAndTime
|
| Field Summary | |
|---|---|
(package private) List3D<WorldImpl.ActivityAndTime> |
activityLists
A 3D list: D1 is player, D2 is train id, D3 is train position. |
(package private) List2D<TransactionAndTimeStamp> |
bankAccounts
A 2D list: D1 is player, D2 is transaction. |
(package private) List1D<Money> |
currentBalance
|
(package private) List1D<FreerailsSerializable> |
items
|
(package private) List3D<FreerailsSerializable> |
lists
A 3D list: D1 is player, D2 is type, D3 is element. |
(package private) FreerailsSerializable[][] |
map
|
(package private) List1D<Player> |
players
|
private static long |
serialVersionUID
|
(package private) List2D<FreerailsSerializable> |
sharedLists
A 2D list: D1 is type, D2 is element. |
(package private) GameTime |
time
|
| Constructor Summary | |
|---|---|
WorldImpl()
|
|
WorldImpl(int mapWidth,
int mapHeight)
|
|
| Method Summary | |
|---|---|
void |
add(FreerailsPrincipal p,
int index,
Activity element)
|
int |
add(FreerailsPrincipal p,
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 p,
Activity element)
|
int |
addPlayer(Player player)
|
void |
addTransaction(FreerailsPrincipal p,
Transaction t)
Adds the specified transaction to the specified principal's bank account. |
boolean |
boundsContain(FreerailsPrincipal p,
KEY k,
int index)
|
boolean |
boundsContain(int x,
int y)
|
boolean |
boundsContain(SKEY k,
int index)
|
GameTime |
currentTime()
|
World |
defensiveCopy()
Returns a copy of this world object - making changes to this copy will not change this object. |
boolean |
equals(java.lang.Object o)
|
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)
|
private int |
getPlayerIndex(FreerailsPrincipal p)
|
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)
|
int |
hashCode()
|
boolean |
isPlayer(FreerailsPrincipal p)
|
FreerailsSerializable |
removeLast(FreerailsPrincipal p,
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 p)
|
Activity |
removeLastActivity(FreerailsPrincipal p,
int index)
|
Player |
removeLastPlayer()
Removes the last player to be added. |
Transaction |
removeLastTransaction(FreerailsPrincipal p)
Removes and returns the last transaction added the the specified principal's bank account. |
void |
set(FreerailsPrincipal p,
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 element)
Replaces the tile at the specified position on the map with the specified tile. |
void |
setTime(GameTime t)
|
(package private) void |
setupItems()
|
void |
setupMap(int mapWidth,
int mapHeight)
|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
List3D<WorldImpl.ActivityAndTime> activityLists
List2D<TransactionAndTimeStamp> bankAccounts
List1D<Money> currentBalance
List1D<FreerailsSerializable> items
List3D<FreerailsSerializable> lists
FreerailsSerializable[][] map
List1D<Player> players
List2D<FreerailsSerializable> sharedLists
GameTime time
| Constructor Detail |
|---|
public WorldImpl()
public WorldImpl(int mapWidth,
int mapHeight)
| Method Detail |
|---|
public void add(FreerailsPrincipal p,
int index,
Activity element)
add in interface World
public int add(FreerailsPrincipal p,
KEY key,
FreerailsSerializable element)
World
add in interface World
public int add(SKEY key,
FreerailsSerializable element)
World
add in interface World
public int addActiveEntity(FreerailsPrincipal p,
Activity element)
addActiveEntity in interface Worldpublic int addPlayer(Player player)
addPlayer in interface Worldplayer - Player to add
public void addTransaction(FreerailsPrincipal p,
Transaction t)
World
addTransaction in interface World
public boolean boundsContain(FreerailsPrincipal p,
KEY k,
int index)
boundsContain in interface ReadOnlyWorld
public boolean boundsContain(int x,
int y)
boundsContain in interface ReadOnlyWorld
public boolean boundsContain(SKEY k,
int index)
boundsContain in interface ReadOnlyWorldpublic GameTime currentTime()
currentTime in interface ReadOnlyWorldpublic World defensiveCopy()
World
defensiveCopy in interface Worldpublic boolean equals(java.lang.Object o)
equals in class java.lang.Object
public FreerailsSerializable get(FreerailsPrincipal p,
KEY key,
int index)
ReadOnlyWorld
get in interface ReadOnlyWorldpublic FreerailsSerializable get(ITEM item)
ReadOnlyWorld
get in interface ReadOnlyWorld
public FreerailsSerializable get(SKEY key,
int index)
ReadOnlyWorld
get in interface ReadOnlyWorld
public ActivityIterator getActivities(FreerailsPrincipal p,
int index)
getActivities in interface ReadOnlyWorldpublic Money getCurrentBalance(FreerailsPrincipal p)
getCurrentBalance in interface ReadOnlyWorldpublic int getID(FreerailsPrincipal p)
getID in interface ReadOnlyWorldpublic int getMapHeight()
ReadOnlyWorld
getMapHeight in interface ReadOnlyWorldpublic int getMapWidth()
ReadOnlyWorld
getMapWidth in interface ReadOnlyWorldpublic int getNumberOfPlayers()
getNumberOfPlayers in interface ReadOnlyWorldpublic int getNumberOfTransactions(FreerailsPrincipal p)
getNumberOfTransactions in interface ReadOnlyWorldpublic Player getPlayer(int i)
getPlayer in interface ReadOnlyWorldprivate int getPlayerIndex(FreerailsPrincipal p)
public FreerailsSerializable getTile(int x,
int y)
ReadOnlyWorld
getTile in interface ReadOnlyWorld
public Transaction getTransaction(FreerailsPrincipal p,
int i)
getTransaction in interface ReadOnlyWorld
public GameTime getTransactionTimeStamp(FreerailsPrincipal p,
int i)
getTransactionTimeStamp in interface ReadOnlyWorldpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean isPlayer(FreerailsPrincipal p)
isPlayer in interface ReadOnlyWorld
public FreerailsSerializable removeLast(FreerailsPrincipal p,
KEY key)
World
removeLast in interface Worldpublic FreerailsSerializable removeLast(SKEY key)
World
removeLast in interface Worldpublic Activity removeLastActiveEntity(FreerailsPrincipal p)
removeLastActiveEntity in interface World
public Activity removeLastActivity(FreerailsPrincipal p,
int index)
removeLastActivity in interface Worldpublic Player removeLastPlayer()
removeLastPlayer in interface Worldjava.lang.IllegalStateException - if any elements belonging to the player have not been
removed.public Transaction removeLastTransaction(FreerailsPrincipal p)
World
removeLastTransaction in interface World
public void set(FreerailsPrincipal p,
KEY key,
int index,
FreerailsSerializable element)
World
set in interface World
public void set(ITEM item,
FreerailsSerializable element)
World
set in interface World
public void set(SKEY key,
int index,
FreerailsSerializable element)
World
set in interface World
public void setTile(int x,
int y,
FreerailsSerializable element)
World
setTile in interface Worldpublic void setTime(GameTime t)
setTime in interface Worldvoid setupItems()
public void setupMap(int mapWidth,
int mapHeight)
public int size(FreerailsPrincipal p)
ReadOnlyWorld
size in interface ReadOnlyWorld
public int size(FreerailsPrincipal p,
KEY key)
ReadOnlyWorld
size in interface ReadOnlyWorldpublic int size(SKEY key)
ReadOnlyWorld
size in interface ReadOnlyWorldpublic int getNumberOfActiveEntities(FreerailsPrincipal p)
getNumberOfActiveEntities in interface ReadOnlyWorld
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||