rails.game.action
Class PossibleAction

java.lang.Object
  extended by rails.game.action.PossibleAction
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BuyCertificate, ClosePrivate, CorrectionAction, FoldIntoPrussian, GameAction, MergeCompanies, NullAction, PossibleORAction, RepayLoans, RequestTurn, SellShares, StartItemAction

public abstract class PossibleAction
extends java.lang.Object
implements java.io.Serializable

PossibleAction is the superclass of all classes that describe an allowed user action (such as laying a tile or dropping a token on a specific hex, buying a train etc.).

Author:
Erik Vos
See Also:
Serialized Form

Field Summary
protected  boolean acted
           
protected  GameManagerI gameManager
           
protected static org.apache.log4j.Logger log
           
protected  int playerIndex
           
protected  java.lang.String playerName
           
static long serialVersionUID
           
 
Constructor Summary
PossibleAction()
           
 
Method Summary
abstract  boolean equalsAsAction(PossibleAction pa)
          Compare the chosen actions of two action objects.
abstract  boolean equalsAsOption(PossibleAction pa)
          Compare the choice options of two action objects, without regard to whatever choice has been made, if any.
protected  CompanyManagerI getCompanyManager()
           
protected  GameManagerI getGameManager()
           
 int getPlayerIndex()
           
 java.lang.String getPlayerName()
           
 boolean hasActed()
           
 void setActed()
           
 void setPlayerName(java.lang.String playerName)
          Set the name of the player who executed the action (as opposed to the player who was allowed to do the action, which is the one set in the constructor).
 java.lang.String toMenu()
          Default version of an Menu item text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

playerName

protected java.lang.String playerName

playerIndex

protected int playerIndex

gameManager

protected transient GameManagerI gameManager

acted

protected boolean acted

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

log

protected static org.apache.log4j.Logger log
Constructor Detail

PossibleAction

public PossibleAction()
Method Detail

getPlayerName

public java.lang.String getPlayerName()

getPlayerIndex

public int getPlayerIndex()

setPlayerName

public void setPlayerName(java.lang.String playerName)
Set the name of the player who executed the action (as opposed to the player who was allowed to do the action, which is the one set in the constructor).

Parameters:
playerName -

hasActed

public boolean hasActed()

setActed

public void setActed()

equalsAsOption

public abstract boolean equalsAsOption(PossibleAction pa)
Compare the choice options of two action objects, without regard to whatever choice has been made, if any. In other words: only the server-set (prior) attributes must be compared.

This method is used by the server (engine) to validate the incoming action that has actually been chosen in the client (GUI), but only for the purpose to check if the chosen option was really on offer, not to check if the chosen action is actually valid. These perspectives could give different results in cases where the PossibleAction does not fully restrict choices to valid values only (such as the blanket LayTile that does no restrict the hex to lay a tile on, or the SetDividend that will accept any revenue value).

Parameters:
pa - Another PossibleAction to compare with.
Returns:
True if the compared PossibleAction object has equal choice options.

equalsAsAction

public abstract boolean equalsAsAction(PossibleAction pa)
Compare the chosen actions of two action objects. In other words: the client-set (posterior) attributes must be compared, in addition to those server-set (prior) attributes that sufficiently identify the action.

This method is used by the server (engine) to check if two action objects represent the same actual action, as is done when reloading a saved file (i.e. loading a later stage of the same game).

Parameters:
pa - Another PossibleAction to compare with.
Returns:
True if the compared PossibleAction object has equal selected action values.

getGameManager

protected GameManagerI getGameManager()

getCompanyManager

protected CompanyManagerI getCompanyManager()

toMenu

public java.lang.String toMenu()
Default version of an Menu item text. To be overridden where useful.