From: Erik V. <ev...@us...> - 2010-04-02 20:04:02
|
Update of /cvsroot/rails/18xx/rails/game/specific/_1835 In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv8876/rails/game/specific/_1835 Modified Files: StockRound_1835.java Log Message: 1835 Nationalisation Index: StockRound_1835.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/specific/_1835/StockRound_1835.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** StockRound_1835.java 27 Mar 2010 18:27:08 -0000 1.8 --- StockRound_1835.java 2 Apr 2010 20:03:55 -0000 1.9 *************** *** 5,9 **** --- 5,13 ---- package rails.game.specific._1835; + import java.util.ArrayList; + import java.util.List; + import rails.game.*; + import rails.game.action.BuyCertificate; import rails.util.LocalText; *************** *** 29,32 **** --- 33,86 ---- } + /** Add nationalisations */ + protected void setGameSpecificActions() { + if (!mayCurrentPlayerBuyAnything()) return; + if (companyBoughtThisTurnWrapper.getObject() != null) return; + + List<Player> otherPlayers = new ArrayList<Player>(); + Portfolio holder; + CashHolder owner; + Player otherPlayer; + int price; + int cash = currentPlayer.getCash(); + + for (PublicCompanyI company : companyManager.getAllPublicCompanies()) { + if (!company.getTypeName().equalsIgnoreCase("Major")) continue; + if (!company.hasFloated()) continue; + if (company.getPresident() != currentPlayer) continue; + if (currentPlayer.getPortfolio().getShare(company) >= 55) { + otherPlayers.clear(); + for (PublicCertificateI cert : company.getCertificates()) { + holder = (Portfolio)cert.getHolder(); + owner = holder.getOwner(); + if (owner instanceof Player) { + otherPlayer = (Player) owner; + if (!otherPlayers.contains(otherPlayer)) { + price = (int)(1.5 * company.getCurrentPriceModel().getPrice().getPrice()); + if (price <= cash) { + possibleActions.add(new BuyCertificate (cert, holder, + (int)(1.5 * company.getCurrentPriceModel().getPrice().getPrice()), + 1)); + } + otherPlayers.add(otherPlayer); + } + } + } + } + } + } + + public boolean checkAgainstHoldLimit(Player player, PublicCompanyI company, int number) { + return true; + } + + protected int getBuyPrice (BuyCertificate action, StockSpaceI currentSpace) { + int price = currentSpace.getPrice(); + if (action.getFromPortfolio().getOwner() instanceof Player) { + price *= 1.5; + } + return price; + } + /** Share price goes down 1 space for any number of shares sold. */ |