From: Erik V. <ev...@us...> - 2009-08-28 20:27:48
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv29002/rails/game Modified Files: Phase.java PublicCompanyI.java PublicCompany.java PublicCertificate.java PublicCertificateI.java Log Message: Split off new class PublicCompany_State for 1856 CGR Index: PublicCertificate.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCertificate.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PublicCertificate.java 15 Jan 2009 20:53:28 -0000 1.14 --- PublicCertificate.java 28 Aug 2009 20:27:38 -0000 1.15 *************** *** 32,36 **** protected String certId; ! /** A map alllowing to find certificates by unique id */ protected static Map<String, PublicCertificateI> certMap = new HashMap<String, PublicCertificateI>(); --- 32,36 ---- protected String certId; ! /** A map allowing to find certificates by unique id */ protected static Map<String, PublicCertificateI> certMap = new HashMap<String, PublicCertificateI>(); *************** *** 53,56 **** --- 53,62 ---- } + public PublicCertificate(PublicCertificateI oldCert) { + this.shares = oldCert.getShares(); + this.president = oldCert.isPresidentShare(); + this.initiallyAvailable = oldCert.isInitiallyAvailable(); + } + public void setUniqueId(String name, int index) { certId = name + "-" + index; *************** *** 129,133 **** } ! /** * @param b */ --- 135,143 ---- } ! public void setInitiallyAvailable(boolean initiallyAvailable) { ! this.initiallyAvailable = initiallyAvailable; ! } ! ! /** * @param b */ Index: Phase.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Phase.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Phase.java 3 Dec 2008 20:15:14 -0000 1.10 --- Phase.java 28 Aug 2009 20:27:38 -0000 1.11 *************** *** 33,36 **** --- 33,39 ---- /** May company buy more than one Train of each type from the Bank per turn? */ protected boolean oneTrainPerTypePerTurn = false; + + /** Is loan taking allowed */ + protected boolean loanTakingAllowed = false; /** Previous phase, defining the current one's defaults */ *************** *** 63,66 **** --- 66,70 ---- oneTrainPerTurn = defaults.oneTrainPerTurn; oneTrainPerTypePerTurn = defaults.oneTrainPerTypePerTurn; + loanTakingAllowed = defaults.loanTakingAllowed; if (defaults.parameters != null) { this.parameters = new HashMap<String, String>(); Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** PublicCompany.java 3 Aug 2009 21:27:19 -0000 1.50 --- PublicCompany.java 28 Aug 2009 20:27:38 -0000 1.51 *************** *** 170,173 **** --- 170,175 ---- /** The certificates of this company (minimum 1) */ protected ArrayList<PublicCertificateI> certificates; + /** Are the certificates available from the first SR? */ + boolean certsAreInitiallyAvailable = true; /** Privates and Certificates owned by the public company */ *************** *** 226,230 **** protected int maxLoansPerRound = 0; protected MoneyModel currentLoanValue = null; ! protected GameManagerI gameManager; --- 228,232 ---- protected int maxLoansPerRound = 0; protected MoneyModel currentLoanValue = null; ! protected GameManagerI gameManager; *************** *** 260,269 **** numberOfBaseTokens = tag.getAttributeAsInteger("tokens", 1); ! boolean certsAreInitiallyAvailable ! = tag.getAttributeAsBoolean("available", true); Tag shareUnitTag = tag.getChild("ShareUnit"); if (shareUnitTag != null) { ! shareUnit = new IntegerState (name+"_ShareUnit", shareUnitTag.getAttributeAsInteger("percentage", DEFAULT_SHARE_UNIT)); } --- 262,271 ---- numberOfBaseTokens = tag.getAttributeAsInteger("tokens", 1); ! certsAreInitiallyAvailable ! = tag.getAttributeAsBoolean("available", certsAreInitiallyAvailable); Tag shareUnitTag = tag.getChild("ShareUnit"); if (shareUnitTag != null) { ! shareUnit = new IntegerState (name+"_ShareUnit", shareUnitTag.getAttributeAsInteger("percentage", DEFAULT_SHARE_UNIT)); } *************** *** 614,622 **** * Final initialisation, after all XML has been processed. */ ! public void init2(GameManagerI gameManager) throws ConfigurationException { ! this.gameManager = gameManager; ! if (hasStockPrice && Util.hasValue(startSpace)) { parPrice.setPrice(StockMarket.getInstance().getStockSpace( --- 616,624 ---- * Final initialisation, after all XML has been processed. */ ! public void init2(GameManagerI gameManager) throws ConfigurationException { ! this.gameManager = gameManager; ! if (hasStockPrice && Util.hasValue(startSpace)) { parPrice.setPrice(StockMarket.getInstance().getStockSpace( *************** *** 624,633 **** if (parPrice.getPrice() == null) throw new ConfigurationException("Invalid start space " ! + startSpace + "for company " + name); currentPrice.setPrice(parPrice.getPrice()); } ! if (shareUnit == null) { shareUnit = new IntegerState (name+"_ShareUnit", DEFAULT_SHARE_UNIT); --- 626,635 ---- if (parPrice.getPrice() == null) throw new ConfigurationException("Invalid start space " ! + startSpace + " for company " + name); currentPrice.setPrice(parPrice.getPrice()); } ! if (shareUnit == null) { shareUnit = new IntegerState (name+"_ShareUnit", DEFAULT_SHARE_UNIT); *************** *** 635,640 **** // Give each certificate an unique Id for (int i = 0; i < certificates.size(); i++) { ! certificates.get(i).setUniqueId(name, i); } --- 637,646 ---- // Give each certificate an unique Id + PublicCertificateI cert; for (int i = 0; i < certificates.size(); i++) { ! cert = certificates.get(i); ! cert.setUniqueId(name, i); ! cert.setInitiallyAvailable(cert.isInitiallyAvailable() ! && this.certsAreInitiallyAvailable); } *************** *** 880,884 **** Util.moveObjects(laidBaseTokens, this); StockMarket.getInstance().close(this); ! } --- 886,890 ---- Util.moveObjects(laidBaseTokens, this); StockMarket.getInstance().close(this); ! } *************** *** 1016,1023 **** public void setCertificates(List<PublicCertificateI> list) { certificates = new ArrayList<PublicCertificateI>(); - PublicCertificateI cert2; for (PublicCertificateI cert : list) { ! cert2 = cert.copy(); ! certificates.add(cert2); } } --- 1022,1027 ---- public void setCertificates(List<PublicCertificateI> list) { certificates = new ArrayList<PublicCertificateI>(); for (PublicCertificateI cert : list) { ! certificates.add(new PublicCertificate(cert)); } } *************** *** 1652,1655 **** --- 1656,1663 ---- return maxNumberOfLoans; } + + public boolean canLoan() { + return maxNumberOfLoans > 0; + } public int getMaxLoansPerRound() { Index: PublicCertificateI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCertificateI.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PublicCertificateI.java 2 Nov 2008 19:52:48 -0000 1.9 --- PublicCertificateI.java 28 Aug 2009 20:27:38 -0000 1.10 *************** *** 19,23 **** /** * Get the number of shares that this certificate represents. ! * * @return The number of shares. */ --- 19,23 ---- /** * Get the number of shares that this certificate represents. ! * * @return The number of shares. */ *************** *** 27,31 **** * Get the percentage of ownership that this certificate represents. This is * equal to the number of shares * the share unit. ! * * @return The share percentage. */ --- 27,31 ---- * Get the percentage of ownership that this certificate represents. This is * equal to the number of shares * the share unit. ! * * @return The share percentage. */ *************** *** 34,42 **** /** * Get the current price of this certificate. ! * * @return The current certificate price. */ //public int getCertificatePrice(); /** * @param b --- 34,43 ---- /** * Get the current price of this certificate. ! * * @return The current certificate price. */ //public int getCertificatePrice(); + public void setInitiallyAvailable(boolean initiallyAvailable); /** * @param b *************** *** 71,75 **** /** * Compare certificates ! * * @param cert Another publoc certificate. * @return TRUE if the certificates are of the same company and represent --- 72,76 ---- /** * Compare certificates ! * * @param cert Another publoc certificate. * @return TRUE if the certificates are of the same company and represent Index: PublicCompanyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompanyI.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PublicCompanyI.java 24 Jan 2009 15:10:26 -0000 1.28 --- PublicCompanyI.java 28 Aug 2009 20:27:38 -0000 1.29 *************** *** 332,335 **** --- 332,336 ---- public int getLoanInterestPct(); public int getMaxNumberOfLoans(); + public boolean canLoan(); public int getMaxLoansPerRound(); public int getValuePerLoan(); |