|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrails.game.Round
rails.game.OperatingRound
public class OperatingRound
Implements a basic Operating Round.
A new instance must be created for each new Operating Round. At the end of a round, the current instance should be discarded.
Fields inherited from class rails.game.Round |
---|
autopasses, bank, canRequestTurn, companyManager, gameManager, guiHints, hasRequestedTurn, ipo, log, mapManager, moveStack, playerManager, pool, possibleActions, scrapHeap, stockMarket, unavailable, wasInterrupted |
Constructor Summary | |
---|---|
OperatingRound(GameManagerI gameManager)
Constructor with no parameters, call the super Class (Round's) Constructor with no parameters |
Method Summary | ||
---|---|---|
protected boolean |
areTileLaysPossible()
|
|
boolean |
buyBonusToken(BuyBonusToken action)
|
|
boolean |
buyPrivate(BuyPrivate action)
|
|
boolean |
buyTrain(BuyTrain action)
|
|
protected int |
calculateLoanAmount(int numberOfLoans)
|
|
protected boolean |
canBuyTrainNow()
Can the company buy a train now? Normally only calls isBelowTrainLimit() to get the result. |
|
protected int |
checkForDeductions(SetDividend action)
Default version, to be overridden if need be |
|
void |
checkForeignSales()
|
|
boolean |
checkForExcessTrains()
|
|
protected boolean |
checkNormalTileLay(TileI tile,
boolean update)
|
|
protected java.util.Map<CashHolder,java.lang.Integer> |
countSharesPerRecipient()
|
|
boolean |
discardTrain(DiscardTrain action)
|
|
boolean |
done()
The current Company is done operating. |
|
boolean |
equals(RoundI round)
|
|
protected boolean |
executeClosePrivate(ClosePrivate action)
|
|
protected int |
executeDeductions(SetDividend action)
Default version, to be overridden if need be |
|
protected boolean |
executeOperatingCost(OperatingCost action)
|
|
protected void |
executeRepayLoans(RepayLoans action)
|
|
protected void |
executeSetRevenueAndDividend(SetDividend action)
|
|
protected void |
executeTakeLoans(TakeLoans action)
|
|
protected void |
finishOR()
|
|
protected void |
finishTurn()
|
|
protected boolean |
finishTurnSpecials()
Stub, may be overridden in subclasses Return value: TRUE = normal turn end; FALSE = return immediately from finishTurn(). |
|
protected boolean |
gameSpecificNextStep(GameDef.OrStep step)
Stub, can be overridden in subclasses to check for extra steps |
|
protected CashHolder |
getBeneficiary(PublicCertificateI cert)
Who gets the per-share revenue? |
|
java.lang.String |
getHelp()
|
|
protected java.util.List<LayTile> |
getNormalTileLays(boolean display)
|
|
java.util.List<PublicCompanyI> |
getOperatingCompanies()
|
|
PublicCompanyI |
getOperatingCompany()
Get the public company that has the turn to operate. |
|
int |
getOperatingCompanyIndex()
|
|
protected int |
getPrivateMaximumPrice(PrivateCompanyI privComp)
|
|
protected int |
getPrivateMinimumPrice(PrivateCompanyI privComp)
|
|
java.lang.String |
getRoundName()
|
|
java.util.List<SpecialPropertyI> |
getSpecialProperties()
|
|
protected
|
getSpecialProperties(java.lang.Class<T> clazz)
|
|
protected java.util.List<LayTile> |
getSpecialTileLays(boolean display)
Create a List of allowed special tile lays (see LayTile class). |
|
GameDef.OrStep |
getStep()
Get the current operating round step (i.e. |
|
protected void |
initNormalTileLays()
Create a List of allowed normal tile lays (see LayTile class). |
|
protected void |
initTurn()
|
|
protected boolean |
isBelowTrainLimit()
Returns whether or not the company is allowed to buy a train, considering its train limit. |
|
protected boolean |
isPrivateSellingAllowed()
|
|
protected boolean |
isTileLayAllowed(PublicCompanyI company,
MapHex hex,
int orientation)
Reports if a tile lay is allowed by a certain company on a certain hex |
|
protected boolean |
isTokenLayAllowed(PublicCompanyI company,
MapHex hex,
int station)
Reports if a token lay is allowed by a certain company on a certain hex and city |
|
boolean |
layBaseToken(LayBaseToken action)
|
|
boolean |
layBonusToken(LayBonusToken action)
|
|
boolean |
layTile(LayTile action)
|
|
protected boolean |
maySellPrivate(Player player)
|
|
protected void |
newPhaseChecks()
Stub |
|
protected void |
nextStep()
Internal method: change the OR state to the next step. |
|
protected void |
nextStep(GameDef.OrStep step)
Take the next step after a given one (see nextStep()) |
|
void |
payLoanInterest()
|
|
void |
payout(int amount)
Distribute the dividend amongst the shareholders. |
|
protected void |
prepareNoMapActions()
|
|
protected void |
prepareRevenueAndDividendAction()
|
|
protected void |
prepareStep()
This method is only called at the start of each step (unlike updateStatus(), which is called after each user action) |
|
protected void |
privatesPayOut()
|
|
boolean |
process(PossibleAction action)
|
|
boolean |
processGameSpecificAction(PossibleAction action)
Stub, to be overridden in game-specific subclasses. |
|
protected void |
reachDestination(PublicCompanyI company)
Stub for applying any follow-up actions when a company reaches it destinations. |
|
boolean |
reachDestinations(ReachDestinations action)
|
|
protected void |
registerNormalTileLay(TileI tile)
|
|
protected boolean |
repayLoans(RepayLoans action)
|
|
void |
resume()
Generic stub to resume an interrupted round. |
|
protected void |
setBonusTokenLays()
TODO Should be merged with setSpecialTokenLays() in the future. |
|
void |
setBuyableTrains()
Get a list of buyable trains for the currently operating company. |
|
protected void |
setDestinationActions()
This is currently a stub, as it is unclear if there is a common rule for setting destination reaching options. |
|
protected void |
setGameSpecificPossibleActions()
Stub, can be overridden by subclasses |
|
protected boolean |
setNextOperatingCompany(boolean initial)
|
|
protected void |
setNormalTokenLays()
|
|
protected void |
setOperatingCompany(PublicCompanyI company)
|
|
boolean |
setPossibleActions()
To be called after each change, to re-establish the currently allowed actions. |
|
boolean |
setRevenueAndDividend(SetDividend action)
|
|
protected void |
setSpecialTokenLays()
Create a List of allowed special token lays (see LayToken class). |
|
protected void |
setStep(GameDef.OrStep step)
Bypass normal order of operations and explicitly set round step. |
|
protected void |
setTrainsToDiscard()
|
|
void |
skip()
|
|
void |
splitRevenue(int amount)
Split a dividend. |
|
void |
start()
|
|
protected boolean |
takeLoans(TakeLoans action)
|
|
java.lang.String |
toString()
|
|
void |
update(java.util.Observable observable,
java.lang.Object object)
Update the status if the step has changed by an Undo or Redo |
|
protected void |
updateAllowedTileColours(java.lang.String colour,
int oldAllowedNumber)
|
|
protected boolean |
validateNormalTileLay(TileI tile)
|
|
protected java.lang.String |
validateRepayLoans(RepayLoans action)
|
|
protected java.lang.String |
validateSetRevenueAndDividend(SetDividend action)
|
|
protected java.lang.String |
validateTakeLoans(TakeLoans action)
|
|
void |
withhold(int amount)
Withhold a given amount of revenue (and store it). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected EnumState<GameDef.OrStep> stepObject
protected boolean actionPossible
protected boolean noMapMode
protected java.util.List<PublicCompanyI> companiesOperatedThisRound
protected ArrayListState<PublicCompanyI> operatingCompanies
protected GenericState<PublicCompanyI> operatingCompany
protected java.util.List<SpecialPropertyI> currentSpecialProperties
protected HashMapState<java.lang.String,java.lang.Integer> tileLaysPerColour
protected java.util.List<LayBaseToken> currentNormalTokenLays
protected java.util.List<LayBaseToken> currentSpecialTokenLays
protected java.util.Map<Player,java.util.List<PublicCompanyI>> excessTrainCompanies
protected java.util.List<TrainTypeI> trainsBoughtThisTurn
protected java.util.Map<PublicCompanyI,java.lang.Integer> loansThisRound
protected java.lang.String thisOrNumber
protected PossibleAction selectedAction
protected PossibleAction savedAction
public static final int SPLIT_ROUND_DOWN
protected GameDef.OrStep[] steps
protected boolean doneAllowed
protected TrainManager trainManager
Constructor Detail |
---|
public OperatingRound(GameManagerI gameManager)
Method Detail |
---|
public void start()
protected void privatesPayOut()
public boolean process(PossibleAction action)
process
in interface RoundI
process
in class Round
public boolean processGameSpecificAction(PossibleAction action)
public boolean layTile(LayTile action)
protected boolean validateNormalTileLay(TileI tile)
protected void registerNormalTileLay(TileI tile)
protected boolean checkNormalTileLay(TileI tile, boolean update)
protected void updateAllowedTileColours(java.lang.String colour, int oldAllowedNumber)
public boolean layBaseToken(LayBaseToken action)
public boolean layBonusToken(LayBonusToken action)
public boolean buyBonusToken(BuyBonusToken action)
public boolean setRevenueAndDividend(SetDividend action)
protected java.lang.String validateSetRevenueAndDividend(SetDividend action)
protected void executeSetRevenueAndDividend(SetDividend action)
public void payout(int amount)
amount
- protected java.util.Map<CashHolder,java.lang.Integer> countSharesPerRecipient()
protected CashHolder getBeneficiary(PublicCertificateI cert)
public void withhold(int amount)
The
- revenue amount.public void splitRevenue(int amount)
amount
- protected int checkForDeductions(SetDividend action)
protected int executeDeductions(SetDividend action)
protected boolean executeOperatingCost(OperatingCost action)
protected boolean executeClosePrivate(ClosePrivate action)
protected void nextStep()
company
- The current company.protected void nextStep(GameDef.OrStep step)
protected boolean gameSpecificNextStep(GameDef.OrStep step)
protected void initTurn()
protected void prepareStep()
protected <T extends SpecialPropertyI> java.util.List<T> getSpecialProperties(java.lang.Class<T> clazz)
protected void initNormalTileLays()
protected java.util.List<LayTile> getNormalTileLays(boolean display)
protected java.util.List<LayTile> getSpecialTileLays(boolean display)
protected boolean areTileLaysPossible()
protected void setNormalTokenLays()
protected void setSpecialTokenLays()
protected void setBonusTokenLays()
protected void setGameSpecificPossibleActions()
public java.util.List<SpecialPropertyI> getSpecialProperties()
getSpecialProperties
in class Round
public void skip()
public boolean done()
company
- Name of the company that finished operating.
protected void finishTurn()
protected boolean finishTurnSpecials()
protected boolean setNextOperatingCompany(boolean initial)
protected void setOperatingCompany(PublicCompanyI company)
protected void finishOR()
public boolean buyTrain(BuyTrain action)
public boolean checkForExcessTrains()
protected void newPhaseChecks()
public void resume()
Round
resume
in interface RoundI
resume
in class Round
public boolean discardTrain(DiscardTrain action)
public boolean buyPrivate(BuyPrivate action)
public boolean reachDestinations(ReachDestinations action)
protected boolean takeLoans(TakeLoans action)
protected java.lang.String validateTakeLoans(TakeLoans action)
protected void executeTakeLoans(TakeLoans action)
protected void reachDestination(PublicCompanyI company)
company
- protected boolean repayLoans(RepayLoans action)
protected java.lang.String validateRepayLoans(RepayLoans action)
protected void executeRepayLoans(RepayLoans action)
protected int calculateLoanAmount(int numberOfLoans)
public PublicCompanyI getOperatingCompany()
public java.util.List<PublicCompanyI> getOperatingCompanies()
public GameDef.OrStep getStep()
protected void setStep(GameDef.OrStep step)
step
- public int getOperatingCompanyIndex()
public boolean setPossibleActions()
setPossibleActions
in interface RoundI
setPossibleActions
in class Round
protected boolean isPrivateSellingAllowed()
protected int getPrivateMinimumPrice(PrivateCompanyI privComp)
protected int getPrivateMaximumPrice(PrivateCompanyI privComp)
protected boolean maySellPrivate(Player player)
protected void prepareRevenueAndDividendAction()
protected void prepareNoMapActions()
public void setBuyableTrains()
protected boolean isBelowTrainLimit()
protected boolean isTileLayAllowed(PublicCompanyI company, MapHex hex, int orientation)
This method can be used both in retricting possible actions and in validating submitted actions.
Currently, only a few standard checks are included. This method can be extended to perform other generic checks, such as if a route exists, and possibly in subclasses for game-specific checks.
company
- The company laying a tile.hex
- The hex on which a tile is laid.orientation
- The orientation in which the tile is laid (-1 is any).protected boolean isTokenLayAllowed(PublicCompanyI company, MapHex hex, int station)
This method can be used both in retricting possible actions and in validating submitted actions.
Currently, only a few standard checks are included. This method can be extended to perform other generic checks, such as if a route exists, and possibly in subclasses for game-specific checks.
company
- The company laying a tile.hex
- The hex on which a tile is laid.station
- The number of the station/city on which the token
is to be laid (0 if any or immaterial).protected boolean canBuyTrainNow()
protected void setTrainsToDiscard()
protected void setDestinationActions()
public void payLoanInterest()
public void checkForeignSales()
public java.lang.String getHelp()
getHelp
in interface RoundI
getHelp
in class Round
public void update(java.util.Observable observable, java.lang.Object object)
update
in interface java.util.Observer
public java.lang.String toString()
toString
in class Round
public boolean equals(RoundI round)
public java.lang.String getRoundName()
getRoundName
in interface RoundI
getRoundName
in class Round
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |