|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrails.game.Round
rails.game.StockRound
public class StockRound
Implements a basic Stock Round.
A new instance must be created for each new Stock Round. At the end of a round, the current instance should be discarded.
Permanent memory is formed by static attributes (like who has the Priority Deal).
Field Summary | |
---|---|
static int |
BOUGHT
|
protected State |
companyBoughtThisTurnWrapper
|
protected Player |
currentPlayer
|
protected BooleanState |
hasActed
|
protected BooleanState |
hasSoldThisTurnBeforeBuying
|
protected int |
numberOfPlayers
|
protected IntegerState |
numPasses
|
protected java.util.HashMap<Player,java.util.HashMap<PublicCompanyI,java.lang.Object>> |
playersThatSoldThisRound
HashMap per player containing a HashMap per company |
protected static int |
SELL_BUY
|
protected static int |
SELL_BUY_OR_BUY_SELL
|
protected static int |
SELL_BUY_SELL
|
protected HashSetState<PublicCompanyI> |
sellObligationLifted
Records lifted share selling obligations in the current round |
protected java.util.Map<java.lang.String,StockSpaceI> |
sellPrices
|
protected int |
sequenceRule
|
static int |
SOLD
|
protected Player |
startingPlayer
|
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 | |
---|---|
StockRound(GameManagerI aGameManager)
Constructor with the GameManager, will call super class (Round's) Constructor to initialize |
Method Summary | |
---|---|
protected void |
adjustSharePrice(PublicCompanyI company,
int numberSold,
boolean soldBefore)
|
boolean |
buyShares(java.lang.String playerName,
BuyCertificate action)
Buying one or more single or double-share certificates (more is sometimes possible) |
boolean |
checkAgainstHoldLimit(Player player,
PublicCompanyI company,
int number)
Check if a player may buy the given number of shares from a given company, given the "hold limit" per company, that is the percentage of shares of one company that a player may hold (typically 60%). |
boolean |
done(java.lang.String playerName,
boolean hasAutopassed)
The current Player passes or is done. |
boolean |
executeExchangeForShare(ExchangeForShare sp)
|
protected void |
executeShareTransfer(PublicCompanyI company,
java.util.List<PublicCertificateI> certsToSell,
Player dumpedPlayer,
int presSharesToSell)
|
protected void |
finishRound()
|
protected void |
finishTurn()
|
protected void |
gameSpecificChecks(Portfolio boughtFrom,
PublicCompanyI company)
Stub, may be overridden in subclasses |
protected int |
getBuyPrice(BuyCertificate action,
StockSpaceI currentSpace)
Allow different price setting in subclasses (i.e. |
int |
getCurrentPlayerIndex()
|
protected int |
getCurrentSellPrice(PublicCompanyI company)
|
java.lang.String |
getHelp()
|
java.lang.String |
getRoundName()
|
protected CashHolder |
getSharePriceRecipient(PublicCompanyI comp,
Portfolio from,
int price)
Who receives the cash when a certificate is bought. |
int |
getStockRoundNumber()
|
protected void |
initPlayer()
|
protected boolean |
isPlayerOverLimits(Player player)
|
protected java.lang.String |
isPlayerOverLimitsDetail(Player player)
|
protected boolean |
isSaleRecorded(Player player,
PublicCompanyI company)
|
boolean |
isSellObligationLifted(PublicCompanyI company)
|
int |
maxAllowedNumberOfSharesToBuy(Player player,
PublicCompanyI company,
int shareSize)
Return the number of additional shares of a certain company and of a certain size that a player may buy, given the share "hold limit" per company, that is the percentage of shares of one company that a player may hold (typically 60%). |
boolean |
mayCurrentPlayerBuyAnything()
Can the current player do any buying? |
boolean |
mayCurrentPlayerSellAnything()
Can the current player do any selling? |
boolean |
mayPlayerBuyCertificate(Player player,
PublicCompanyI comp,
float number)
Check if a player may buy the given number of certificates. |
boolean |
mayPlayerSellShareOfCompany(PublicCompanyI company)
|
protected boolean |
noSaleIfNotOperated()
|
protected boolean |
noSaleInFirstSR()
|
boolean |
process(PossibleAction action)
|
protected boolean |
processGameSpecificAction(PossibleAction action)
|
protected void |
recordSale(Player player,
PublicCompanyI company)
|
protected void |
releaseCompanyShares(PublicCompanyI company)
Make the certificates of one company available for buying by putting these in the IPO. |
protected boolean |
requestTurn(RequestTurn action)
|
boolean |
sellShares(SellShares action)
|
void |
setBuyableCerts()
Create a list of certificates that a player may buy in a Stock Round, taking all rules into account. |
void |
setCurrentPlayer(Player player)
|
protected void |
setGameSpecificActions()
Stub, can be overridden in subclasses |
protected void |
setNextPlayer()
Internal method: pass the turn to the next player. |
boolean |
setPossibleActions()
Default version, does nothing. |
protected void |
setPriority()
Remember the player that has the Priority Deal. |
void |
setSellableShares()
Create a list of certificates that a player may sell in a Stock Round, taking all rules taken into account. |
void |
setSellObligationLifted(PublicCompanyI company)
|
protected void |
setSpecialActions()
|
void |
start()
|
boolean |
startCompany(java.lang.String playerName,
StartCompany action)
Start a company by buying one or more shares (more applies to e.g. |
java.lang.String |
toString()
|
boolean |
useSpecialProperty(UseSpecialProperty action)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int numberOfPlayers
protected Player currentPlayer
protected Player startingPlayer
protected State companyBoughtThisTurnWrapper
protected BooleanState hasSoldThisTurnBeforeBuying
protected BooleanState hasActed
protected IntegerState numPasses
protected java.util.Map<java.lang.String,StockSpaceI> sellPrices
protected HashSetState<PublicCompanyI> sellObligationLifted
Example: >60% ownership allowed after a merger in 18EU.
protected java.util.HashMap<Player,java.util.HashMap<PublicCompanyI,java.lang.Object>> playersThatSoldThisRound
protected static final int SELL_BUY_SELL
protected static final int SELL_BUY
protected static final int SELL_BUY_OR_BUY_SELL
public static final int BOUGHT
public static final int SOLD
protected int sequenceRule
Constructor Detail |
---|
public StockRound(GameManagerI aGameManager)
aGameManager
- The GameManager Object needed to initialize the Round ClassMethod Detail |
---|
public void start()
public int getStockRoundNumber()
public boolean setPossibleActions()
Round
setPossibleActions
in interface RoundI
setPossibleActions
in class Round
protected void setGameSpecificActions()
public void setBuyableCerts()
public void setSellableShares()
protected void setSpecialActions()
public boolean process(PossibleAction action)
process
in interface RoundI
process
in class Round
protected boolean processGameSpecificAction(PossibleAction action)
public boolean startCompany(java.lang.String playerName, StartCompany action)
player
- The player that wants to start a company.company
- The company to start.price
- The start (par) price (ignored if the price is fixed).shares
- The number of shares to buy (can be more than 1 in e.g.
1841).
public boolean buyShares(java.lang.String playerName, BuyCertificate action)
player
- The player that wants to buy shares.action
- The executed BuyCertificates action
protected void gameSpecificChecks(Portfolio boughtFrom, PublicCompanyI company)
protected int getBuyPrice(BuyCertificate action, StockSpaceI currentSpace)
protected CashHolder getSharePriceRecipient(PublicCompanyI comp, Portfolio from, int price)
cert
-
protected void releaseCompanyShares(PublicCompanyI company)
company
- The company to be released.protected void recordSale(Player player, PublicCompanyI company)
protected boolean isSaleRecorded(Player player, PublicCompanyI company)
public boolean sellShares(SellShares action)
protected void executeShareTransfer(PublicCompanyI company, java.util.List<PublicCertificateI> certsToSell, Player dumpedPlayer, int presSharesToSell)
protected int getCurrentSellPrice(PublicCompanyI company)
protected void adjustSharePrice(PublicCompanyI company, int numberSold, boolean soldBefore)
public boolean useSpecialProperty(UseSpecialProperty action)
public boolean executeExchangeForShare(ExchangeForShare sp)
public boolean done(java.lang.String playerName, boolean hasAutopassed)
player
- Name of the passing player.
protected void finishRound()
finishRound
in class Round
protected boolean requestTurn(RequestTurn action)
protected void finishTurn()
protected void setNextPlayer()
protected void initPlayer()
protected void setPriority()
public void setCurrentPlayer(Player player)
setCurrentPlayer
in class Round
public int getCurrentPlayerIndex()
getCurrentPlayerIndex
in class Round
public boolean mayCurrentPlayerSellAnything()
public boolean mayPlayerSellShareOfCompany(PublicCompanyI company)
public boolean mayCurrentPlayerBuyAnything()
protected boolean isPlayerOverLimits(Player player)
protected java.lang.String isPlayerOverLimitsDetail(Player player)
public boolean mayPlayerBuyCertificate(Player player, PublicCompanyI comp, float number)
number
- Number of certificates to buy (usually 1 but not always
so).
public boolean checkAgainstHoldLimit(Player player, PublicCompanyI company, int number)
player
- the buying playercompany
- The company from which to buynumber
- The number of shares (usually 1 but not always so)
public int maxAllowedNumberOfSharesToBuy(Player player, PublicCompanyI company, int shareSize)
If no hold limit applies, it is taken to be 100%.
company
- The company from which to buynumber
- The share unit (typically 10%).
protected boolean noSaleInFirstSR()
protected boolean noSaleIfNotOperated()
public java.lang.String getHelp()
getHelp
in interface RoundI
getHelp
in class Round
public java.lang.String toString()
toString
in class Round
public java.lang.String getRoundName()
getRoundName
in interface RoundI
getRoundName
in class Round
public boolean isSellObligationLifted(PublicCompanyI company)
public void setSellObligationLifted(PublicCompanyI company)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |