From: Erik V. <ev...@us...> - 2009-08-30 18:15:31
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13182/rails/game Modified Files: Portfolio.java PublicCompany.java PublicCertificate.java PublicCertificateI.java Player.java Log Message: Added fractional certificate counts. 1856 CGR 5% shares now count as 0.5 certificate against limits Index: Portfolio.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Portfolio.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Portfolio.java 4 May 2009 20:29:14 -0000 1.33 --- Portfolio.java 30 Aug 2009 18:15:18 -0000 1.34 *************** *** 236,242 **** /** Get the number of certificates that count against the certificate limit */ ! public int getNumberOfCountedCertificates() { ! int number = privateCompanies.size(); // May not hold for all games PublicCompanyI comp; --- 236,242 ---- /** Get the number of certificates that count against the certificate limit */ ! public float getCertificateCount() { ! float number = privateCompanies.size(); // May not hold for all games PublicCompanyI comp; *************** *** 245,249 **** if (!comp.hasFloated() || !comp.hasStockPrice() || !cert.getCompany().getCurrentSpace().isNoCertLimit()) ! number++; } return number; --- 245,249 ---- if (!comp.hasFloated() || !comp.hasStockPrice() || !cert.getCompany().getCurrentSpace().isNoCertLimit()) ! number += cert.getCertificateCount(); } return number; Index: PublicCertificate.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCertificate.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PublicCertificate.java 28 Aug 2009 20:27:38 -0000 1.15 --- PublicCertificate.java 30 Aug 2009 18:15:18 -0000 1.16 *************** *** 21,24 **** --- 21,27 ---- /** President's certificate? */ protected boolean president; + /** Count against certificate limits */ + protected float certificateCount = 1.0f; + /** Availability at the start of the game */ protected boolean initiallyAvailable; *************** *** 39,54 **** Logger.getLogger(PublicCertificate.class.getPackage().getName()); ! public PublicCertificate(int shares) { ! this(shares, false, true); ! } ! ! public PublicCertificate(int shares, boolean president) { ! this(shares, president, true); ! } ! ! public PublicCertificate(int shares, boolean president, boolean available) { this.shares = shares; this.president = president; this.initiallyAvailable = available; } --- 42,51 ---- Logger.getLogger(PublicCertificate.class.getPackage().getName()); ! public PublicCertificate(int shares, boolean president, ! boolean available, float certificateCount) { this.shares = shares; this.president = president; this.initiallyAvailable = available; + this.certificateCount = certificateCount; } *************** *** 57,60 **** --- 54,58 ---- this.president = oldCert.isPresidentShare(); this.initiallyAvailable = oldCert.isInitiallyAvailable(); + this.certificateCount = oldCert.getCertificateCount(); } *************** *** 145,148 **** --- 143,154 ---- return initiallyAvailable; } + + public float getCertificateCount() { + return certificateCount; + } + + public void setCertificateCount(float certificateCount) { + this.certificateCount = certificateCount; + } /** Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** PublicCompany.java 28 Aug 2009 20:27:38 -0000 1.51 --- PublicCompany.java 30 Aug 2009 18:15:18 -0000 1.52 *************** *** 464,467 **** --- 464,469 ---- = certificateTag.getAttributeAsBoolean("available", certsAreInitiallyAvailable); + + float certificateCount = certificateTag.getAttributeAsFloat("certificateCount", 1.0f); if (president) { *************** *** 476,480 **** for (int k = 0; k < number; k++) { certificate = new PublicCertificate(shares, president, ! certIsInitiallyAvailable); addCertificate(certificate); shareTotal += shares * shareUnit.intValue(); --- 478,482 ---- for (int k = 0; k < number; k++) { certificate = new PublicCertificate(shares, president, ! certIsInitiallyAvailable, certificateCount); addCertificate(certificate); shareTotal += shares * shareUnit.intValue(); Index: Player.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Player.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Player.java 15 Jan 2009 20:53:28 -0000 1.16 --- Player.java 30 Aug 2009 18:15:18 -0000 1.17 *************** *** 107,111 **** // Over the total certificate hold Limit? ! if (portfolio.getNumberOfCountedCertificates() > playerCertificateLimit) return true; --- 107,111 ---- // Over the total certificate hold Limit? ! if (portfolio.getCertificateCount() > playerCertificateLimit) return true; *************** *** 129,133 **** if (comp.hasFloated() && comp.getCurrentSpace().isNoCertLimit()) return true; ! if (portfolio.getNumberOfCountedCertificates() + number > playerCertificateLimit) return false; return true; --- 129,133 ---- if (comp.hasFloated() && comp.getCurrentSpace().isNoCertLimit()) return true; ! if (portfolio.getCertificateCount() + number > playerCertificateLimit) return false; return true; Index: PublicCertificateI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCertificateI.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PublicCertificateI.java 28 Aug 2009 20:27:38 -0000 1.10 --- PublicCertificateI.java 30 Aug 2009 18:15:18 -0000 1.11 *************** *** 45,48 **** --- 45,52 ---- public boolean isInitiallyAvailable(); + public float getCertificateCount(); + + public void setCertificateCount(float certificateCount); + /** * @param portfolio |