rails.game.action
Class BuyTrain

java.lang.Object
  extended by rails.game.action.PossibleAction
      extended by rails.game.action.PossibleORAction
          extended by rails.game.action.BuyTrain
All Implemented Interfaces:
java.io.Serializable

public class BuyTrain
extends PossibleORAction

Author:
Erik Vos
See Also:
Serialized Form

Field Summary
static long serialVersionUID
           
 
Fields inherited from class rails.game.action.PossibleORAction
company, companyName
 
Fields inherited from class rails.game.action.PossibleAction
acted, gameManager, log, playerIndex, playerName
 
Constructor Summary
BuyTrain(TrainI train, Portfolio from, int fixedCost)
           
 
Method Summary
 boolean equalsAsAction(PossibleAction action)
          Compare the chosen actions of two action objects.
 boolean equalsAsOption(PossibleAction action)
          Compare the choice options of two action objects, without regard to whatever choice has been made, if any.
 int getAddedCash()
           
 TrainI getExchangedTrain()
           
 java.lang.String getExtraMessage()
           
 int getFixedCost()
           
 Portfolio getFromPortfolio()
           
 Portfolio getHolder()
           
 CashHolder getOwner()
           
 int getPresidentCashToAdd()
           
 int getPricePaid()
           
 SpecialTrainBuy getSpecialProperty()
           
 TrainI getTrain()
          To be used for all usage of train, also within this class.
 java.util.List<TrainI> getTrainsForExchange()
           
 boolean hasSpecialProperty()
           
 boolean isForcedBuyIfNoRoute()
           
 boolean isForExchange()
           
 boolean mayPresidentAddCash()
           
 boolean mustPresidentAddCash()
           
 void setAddedCash(int addedCash)
           
 void setExchangedTrain(TrainI exchangedTrain)
           
 void setExtraMessage(java.lang.String message)
           
 void setForcedBuyIfNoRoute(boolean hasNoTrains)
           
 BuyTrain setPresidentMayAddCash(int amount)
           
 BuyTrain setPresidentMustAddCash(int amount)
           
 void setPricePaid(int pricePaid)
           
 void setSpecialProperty(SpecialTrainBuy specialProperty)
           
 BuyTrain setTrainsForExchange(java.util.List<TrainI> trains)
           
 java.lang.String toString()
           
 
Methods inherited from class rails.game.action.PossibleORAction
getCompany, getCompanyName, setCompany
 
Methods inherited from class rails.game.action.PossibleAction
getCompanyManager, getGameManager, getPlayerIndex, getPlayerName, hasActed, setActed, setPlayerName, toMenu
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

BuyTrain

public BuyTrain(TrainI train,
                Portfolio from,
                int fixedCost)
Method Detail

setTrainsForExchange

public BuyTrain setTrainsForExchange(java.util.List<TrainI> trains)

setPresidentMustAddCash

public BuyTrain setPresidentMustAddCash(int amount)

setPresidentMayAddCash

public BuyTrain setPresidentMayAddCash(int amount)

setForcedBuyIfNoRoute

public void setForcedBuyIfNoRoute(boolean hasNoTrains)

setExtraMessage

public void setExtraMessage(java.lang.String message)

getExtraMessage

public java.lang.String getExtraMessage()

getSpecialProperty

public SpecialTrainBuy getSpecialProperty()
Returns:
Returns the specialProperty.

setSpecialProperty

public void setSpecialProperty(SpecialTrainBuy specialProperty)
Parameters:
specialProperty - The specialProperty to set.

hasSpecialProperty

public boolean hasSpecialProperty()

getTrain

public TrainI getTrain()
To be used for all usage of train, also within this class. After reloading the 2nd copy etc. of a train with unlimited quantity, the train attribute will be null (because readObject() is called and the train is initiated before the actions have been executed - the second train is in this case only created after buying the first one).

Returns:

getFromPortfolio

public Portfolio getFromPortfolio()

getFixedCost

public int getFixedCost()

isForExchange

public boolean isForExchange()

getTrainsForExchange

public java.util.List<TrainI> getTrainsForExchange()

mustPresidentAddCash

public boolean mustPresidentAddCash()

mayPresidentAddCash

public boolean mayPresidentAddCash()

getPresidentCashToAdd

public int getPresidentCashToAdd()

isForcedBuyIfNoRoute

public boolean isForcedBuyIfNoRoute()

getHolder

public Portfolio getHolder()

getOwner

public CashHolder getOwner()

getAddedCash

public int getAddedCash()

setAddedCash

public void setAddedCash(int addedCash)

getPricePaid

public int getPricePaid()

setPricePaid

public void setPricePaid(int pricePaid)

getExchangedTrain

public TrainI getExchangedTrain()

setExchangedTrain

public void setExchangedTrain(TrainI exchangedTrain)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equalsAsOption

public boolean equalsAsOption(PossibleAction action)
Description copied from class: PossibleAction
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).

Specified by:
equalsAsOption in class PossibleAction
Parameters:
action - Another PossibleAction to compare with.
Returns:
True if the compared PossibleAction object has equal choice options.

equalsAsAction

public boolean equalsAsAction(PossibleAction action)
Description copied from class: PossibleAction
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).

Specified by:
equalsAsAction in class PossibleAction
Parameters:
action - Another PossibleAction to compare with.
Returns:
True if the compared PossibleAction object has equal selected action values.