From: Stefan F. <ste...@us...> - 2010-02-24 21:10:01
|
Update of /cvsroot/rails/18xx/rails/game/correct In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31633/rails/game/correct Modified Files: OperatingCost.java ClosePrivate.java Log Message: Changed base class of ClosePrivate and OperatingCost actions to PossibleAction and PossibleOR in preparation of new Correction Actions Breaks save compatibility with previous actions. Index: ClosePrivate.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/correct/ClosePrivate.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ClosePrivate.java 22 Feb 2010 22:48:18 -0000 1.2 --- ClosePrivate.java 24 Feb 2010 21:09:22 -0000 1.3 *************** *** 9,18 **** /** ! * Correction action that allows the closure of a private company. */ ! public class ClosePrivate extends CorrectionAction { ! private static final long serialVersionUID = 1L; /* Preconditions */ --- 9,19 ---- /** ! * Action that allows the closure of a private company ! * used for NoMapMode */ ! public class ClosePrivate extends PossibleAction { ! private static final long serialVersionUID = 2L; /* Preconditions */ *************** *** 46,52 **** if (!(action instanceof ClosePrivate)) return false; ClosePrivate a = (ClosePrivate) action; ! return (a.privateCompany == this.privateCompany && ! a.inCorrectionMenu == this.inCorrectionMenu ! ); } --- 47,51 ---- if (!(action instanceof ClosePrivate)) return false; ClosePrivate a = (ClosePrivate) action; ! return (a.privateCompany == this.privateCompany); } *************** *** 58,62 **** if (privateCompany != null) b.append(", privateCompany="+privateCompany); - b.append(", inCorrectionMenu="+inCorrectionMenu); } else { b.append(" (acted)"); --- 57,60 ---- Index: OperatingCost.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/correct/OperatingCost.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OperatingCost.java 22 Feb 2010 22:48:18 -0000 1.4 --- OperatingCost.java 24 Feb 2010 21:09:19 -0000 1.5 *************** *** 3,6 **** --- 3,7 ---- import rails.game.*; import rails.game.action.PossibleAction; + import rails.game.action.PossibleORAction; import rails.util.Util; *************** *** 9,30 **** /** ! * Correction action that mirrors operating actions like tile and token lays, but ! * only changes the cash position of a cashholder. * @author Stefan Frey */ ! public class OperatingCost extends CorrectionAction implements CorrectCashI { public enum OCType {LAY_TILE, LAY_BASE_TOKEN}; /** The Constant serialVersionUID. */ ! public static final long serialVersionUID = 1L; /* Preconditions */ - - /** operating Company */ - transient private PublicCompanyI operatingCompany; - - /** converted to name */ - private String operatingCompanyName; /** operating cost type (as tile lay, token lay etc.) */ --- 10,26 ---- /** ! * OR action for no map mode ! * mirrors operating actions like tile and token lays, but ! * only changes the cash position of the public company * @author Stefan Frey */ ! public class OperatingCost extends PossibleORAction { public enum OCType {LAY_TILE, LAY_BASE_TOKEN}; /** The Constant serialVersionUID. */ ! public static final long serialVersionUID = 2L; /* Preconditions */ /** operating cost type (as tile lay, token lay etc.) */ *************** *** 50,68 **** * @param pc Public Company */ ! public OperatingCost(PublicCompanyI pc, OCType ot, int ocCosts, boolean freeEntry) { ! operatingCompany = pc; ! operatingCompanyName = pc.getName(); operatingCostType = ot; suggestedCost = ocCosts; freeEntryAllowed = freeEntry; ! maximumCost = pc.getCash(); ! } ! ! public CashHolder getCashHolder() { ! return operatingCompany; ! } ! ! public String getCashHolderName() { ! return operatingCompanyName; } --- 46,57 ---- * @param pc Public Company */ ! public OperatingCost(OCType ot, int ocCosts, boolean freeEntry) { ! ! super(); ! operatingCostType = ot; suggestedCost = ocCosts; freeEntryAllowed = freeEntry; ! maximumCost = company.getCash(); } *************** *** 73,77 **** public int getAmount() { if (acted) ! return -operatingCost; else return suggestedCost; --- 62,66 ---- public int getAmount() { if (acted) ! return operatingCost; else return suggestedCost; *************** *** 90,98 **** if (!(action instanceof OperatingCost)) return false; OperatingCost a = (OperatingCost) action; ! return (a.operatingCompany == this.operatingCompany && a.operatingCostType == this.operatingCostType && a.suggestedCost == this.suggestedCost && ! a.maximumCost == this.maximumCost && ! a.inCorrectionMenu == this.inCorrectionMenu ); } --- 79,86 ---- if (!(action instanceof OperatingCost)) return false; OperatingCost a = (OperatingCost) action; ! return (a.company == this.company && a.operatingCostType == this.operatingCostType && a.suggestedCost == this.suggestedCost && ! a.maximumCost == this.maximumCost ); } *************** *** 102,115 **** if (!acted) { b.append(" (not acted)"); ! if (operatingCompany != null) ! b.append(", operatingCompany="+operatingCompany); b.append(", operatingCostType="+operatingCostType); b.append(", suggestedCost="+suggestedCost); b.append(", maximumCost="+maximumCost); - b.append(", inCorrectionMenu="+inCorrectionMenu); } else { b.append(" (acted)"); ! if (operatingCompany != null) ! b.append(", operatingCompany="+operatingCompany); b.append(", operatingCostType="+operatingCostType); b.append(", operatingCost="+operatingCost); --- 90,102 ---- if (!acted) { b.append(" (not acted)"); ! if (company != null) ! b.append(", company="+company); b.append(", operatingCostType="+operatingCostType); b.append(", suggestedCost="+suggestedCost); b.append(", maximumCost="+maximumCost); } else { b.append(" (acted)"); ! if (company != null) ! b.append(", company="+company); b.append(", operatingCostType="+operatingCostType); b.append(", operatingCost="+operatingCost); *************** *** 122,127 **** ClassNotFoundException { in.defaultReadObject(); ! if (Util.hasValue(operatingCompanyName)) ! operatingCompany = getCompanyManager().getCompanyByName(operatingCompanyName); } } --- 109,114 ---- ClassNotFoundException { in.defaultReadObject(); ! if (Util.hasValue(companyName)) ! company = getCompanyManager().getCompanyByName(companyName); } } |