From: Erik V. <ev...@us...> - 2010-06-17 21:36:02
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv26332/rails/game Modified Files: PublicCertificateI.java StockRound.java GameManager.java PublicCompany.java PublicCertificate.java Log Message: Fixed 1835 certificate ordering in IPO after Undo Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** PublicCompany.java 25 May 2010 20:27:17 -0000 1.99 --- PublicCompany.java 17 Jun 2010 21:35:54 -0000 1.100 *************** *** 487,490 **** --- 487,491 ---- } + int certIndex = 0; List<Tag> certificateTags = tag.getChildren("Certificate"); if (certificateTags != null) { *************** *** 521,525 **** for (int k = 0; k < number; k++) { certificate = new PublicCertificate(shares, president, ! certIsInitiallyAvailable, certificateCount); addCertificate(certificate); shareTotal += shares * shareUnit.intValue(); --- 522,526 ---- for (int k = 0; k < number; k++) { certificate = new PublicCertificate(shares, president, ! certIsInitiallyAvailable, certificateCount, certIndex++); addCertificate(certificate); shareTotal += shares * shareUnit.intValue(); Index: GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** GameManager.java 15 Jun 2010 20:16:54 -0000 1.106 --- GameManager.java 17 Jun 2010 21:35:54 -0000 1.107 *************** *** 908,915 **** } getCurrentRound().setPossibleActions(); if (!isGameOver()) setCorrectionActions(); } catch (Exception e) { ! log.debug("Error while reprocessing " + action.toString(), e); throw new Exception("Reload failure", e); } --- 908,919 ---- } getCurrentRound().setPossibleActions(); + //String playerName = getCurrentPlayer().getName(); + //for (PossibleAction a : possibleActions.getList()) { + // log.debug(playerName+" may: "+a.toString()); + //} if (!isGameOver()) setCorrectionActions(); } catch (Exception e) { ! log.error("Error while reprocessing " + action.toString(), e); throw new Exception("Reload failure", e); } Index: PublicCertificate.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCertificate.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PublicCertificate.java 31 Jan 2010 22:22:28 -0000 1.18 --- PublicCertificate.java 17 Jun 2010 21:35:54 -0000 1.19 *************** *** 34,37 **** --- 34,40 ---- /** A key identifying the certificate's unique ID */ protected String certId; + + /** Index within company (to be maintained in the IPO) */ + protected int indexInCompany; /** A map allowing to find certificates by unique id */ *************** *** 43,51 **** public PublicCertificate(int shares, boolean president, ! boolean available, float certificateCount) { this.shares = shares; this.president = president; this.initiallyAvailable = available; this.certificateCount = certificateCount; } --- 46,55 ---- public PublicCertificate(int shares, boolean president, ! boolean available, float certificateCount, int index) { this.shares = shares; this.president = president; this.initiallyAvailable = available; this.certificateCount = certificateCount; + this.indexInCompany = index; } *************** *** 55,58 **** --- 59,63 ---- this.initiallyAvailable = oldCert.isInitiallyAvailable(); this.certificateCount = oldCert.getCertificateCount(); + this.indexInCompany = oldCert.getIndexInCompany(); } *************** *** 65,68 **** --- 70,77 ---- return certId; } + + public int getIndexInCompany() { + return indexInCompany; + } public static PublicCertificateI getByUniqueId(String certId) { Index: PublicCertificateI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCertificateI.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PublicCertificateI.java 30 Aug 2009 18:15:18 -0000 1.11 --- PublicCertificateI.java 17 Jun 2010 21:35:54 -0000 1.12 *************** *** 11,14 **** --- 11,16 ---- /** Set the certificate's unique ID */ public String getUniqueId(); + + public int getIndexInCompany(); /** Index: StockRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/StockRound.java,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** StockRound.java 15 Jun 2010 20:16:54 -0000 1.75 --- StockRound.java 17 Jun 2010 21:35:54 -0000 1.76 *************** *** 168,173 **** certs = map.get(compName); if (certs == null || certs.isEmpty()) continue; /* Only the top certificate is buyable from the IPO */ ! cert = certs.get(0); comp = cert.getCompany(); unitsForPrice = comp.getShareUnitsForSharePrice(); --- 168,184 ---- certs = map.get(compName); if (certs == null || certs.isEmpty()) continue; + /* Only the top certificate is buyable from the IPO */ ! int lowestIndex = 99; ! cert = null; ! int index; ! for (PublicCertificateI c : certs) { ! index = c.getIndexInCompany(); ! if (index < lowestIndex) { ! lowestIndex = index; ! cert = c; ! } ! } ! comp = cert.getCompany(); unitsForPrice = comp.getShareUnitsForSharePrice(); |