jfreerails.world.top
Interface World

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

public interface World
extends ReadOnlyWorld

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

Author:
Luke, rob

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

addActiveEntity

int addActiveEntity(FreerailsPrincipal principal,
                    Activity element)

add

void add(FreerailsPrincipal principal,
         int index,
         Activity element)

add

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.


add

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.


addPlayer

int addPlayer(Player player)

addTransaction

void addTransaction(FreerailsPrincipal p,
                    Transaction t)
Adds the specified transaction to the specified principal's bank account.


defensiveCopy

World defensiveCopy()
Returns a copy of this world object - making changes to this copy will not change this object.


removeLastActiveEntity

Activity removeLastActiveEntity(FreerailsPrincipal principal)

removeLastActivity

Activity removeLastActivity(FreerailsPrincipal principal,
                            int index)

removeLast

FreerailsSerializable removeLast(FreerailsPrincipal principal,
                                 KEY key)
Removes the last element from the specified list.


removeLast

FreerailsSerializable removeLast(SKEY key)
Removes the last element from the specified list.


removeLastTransaction

Transaction removeLastTransaction(FreerailsPrincipal p)
Removes and returns the last transaction added the the specified principal's bank account. This method is only here so that moves that add transactions can be undone.


removeLastPlayer

Player removeLastPlayer()

set

void set(ITEM item,
         FreerailsSerializable element)
Replaces the element mapped to the specified item with the specified element.


set

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.


set

void set(SKEY key,
         int index,
         FreerailsSerializable element)
Replaces the element at the specified position in the specified list with the specified element.


setTile

void setTile(int x,
             int y,
             FreerailsSerializable tile)
Replaces the tile at the specified position on the map with the specified tile.


setTime

void setTime(GameTime t)