From: Erik V. <ev...@us...> - 2008-12-03 20:15:23
|
Update of /cvsroot/rails/18xx/rails/game In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4937/rails/game Modified Files: Phase.java CompanyManagerI.java PublicCompanyI.java PublicCompany.java RoundI.java Company.java OperatingRound.java CompanyManager.java Log Message: Cleanups Index: CompanyManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyManager.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CompanyManager.java 4 Jul 2008 20:46:33 -0000 1.11 --- CompanyManager.java 3 Dec 2008 20:15:15 -0000 1.12 *************** *** 1 **** ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.*; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ // TODO Currently not used (but some newer games have more than one) private List<StartPacket> startPackets = new ArrayList<StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = (CompanyTypeI) mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", new String[] { name, type })); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name"); if (name == null) name = "Initial"; String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void initCompanies() throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.init2(); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return (PublicCompanyI) lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } /** @deprecated */ public List<PublicCompanyI> getCompaniesWithExcessTrains() { List<PublicCompanyI> list = new ArrayList<PublicCompanyI>(); int phaseIndex = PhaseManager.getInstance().getCurrentPhaseIndex(); for (PublicCompanyI comp : lPublicCompanies) { if (comp.getPortfolio().getNumberOfTrains() > comp.getTrainLimit(phaseIndex)) { list.add(comp); } } return list; } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } } \ No newline at end of file --- 1 ---- ! /* $Header$ */ package rails.game; import java.util.*; import org.apache.log4j.Logger; import rails.util.LocalText; import rails.util.Tag; public class CompanyManager implements CompanyManagerI, ConfigurableComponentI { /** A List with all private companies */ private List<PrivateCompanyI> lPrivateCompanies = new ArrayList<PrivateCompanyI>(); /** A List with all public companies */ private List<PublicCompanyI> lPublicCompanies = new ArrayList<PublicCompanyI>(); /** A map with all private companies by name */ private Map<String, PrivateCompanyI> mPrivateCompanies = new HashMap<String, PrivateCompanyI>(); /** A map with all public (i.e. non-private) companies by name */ private Map<String, PublicCompanyI> mPublicCompanies = new HashMap<String, PublicCompanyI>(); /** A map of all type names to maps of companies of that type by name */ // TODO Redundant, current usage can be replaced. private Map<String, HashMap<String, CompanyI>> mCompaniesByTypeAndName = new HashMap<String, HashMap<String, CompanyI>>(); /** A list of all start packets (usually one) */ // TODO Currently not used (but some newer games have more than one) private List<StartPacket> startPackets = new ArrayList<StartPacket>(); private int numberOfPublicCompanies = 0; protected static Logger log = Logger.getLogger(CompanyManager.class.getPackage().getName()); /* * NOTES: 1. we don't have a map over all companies, because some games have * duplicate names, e.g. B&O in 1830. 2. we have both a map and a list of * private/public companies to preserve configuration sequence while * allowing direct access. */ /** * No-args constructor. */ public CompanyManager() { // Nothing to do here, everything happens when configured. } /** * @see rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element) */ public void configureFromXML(Tag tag) throws ConfigurationException { /** A map with all company types, by type name */ // Localised here as it has no permanent use Map<String, CompanyTypeI> mCompanyTypes = new HashMap<String, CompanyTypeI>(); for (Tag compTypeTag : tag.getChildren(CompanyTypeI.ELEMENT_ID)) { // Extract the attributes of the Component String name = compTypeTag.getAttributeAsString(CompanyTypeI.NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompanyType")); } String className = compTypeTag.getAttributeAsString(CompanyTypeI.CLASS_TAG); if (className == null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeHasNoClass", name)); } if (mCompanyTypes.get(name) != null) { throw new ConfigurationException(LocalText.getText( "CompanyTypeConfiguredTwice", name)); } CompanyTypeI companyType = new CompanyType(name, className); mCompanyTypes.put(name, companyType); // Further parsing is done within CompanyType companyType.configureFromXML(compTypeTag); } /* Read and configure the companies */ for (Tag companyTag : tag.getChildren(CompanyI.COMPANY_ELEMENT_ID)) { // Extract the attributes of the Component String name = companyTag.getAttributeAsString(CompanyI.COMPANY_NAME_TAG); if (name == null) { throw new ConfigurationException( LocalText.getText("UnnamedCompany")); } String type = companyTag.getAttributeAsString(CompanyI.COMPANY_TYPE_TAG); if (type == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasNoType", name)); } CompanyTypeI cType = mCompanyTypes.get(type); if (cType == null) { throw new ConfigurationException(LocalText.getText( "CompanyHasUnknownType", new String[] { name, type })); } try { CompanyI company = cType.createCompany(name, companyTag); /* Private or public */ if (company instanceof PrivateCompanyI) { mPrivateCompanies.put(name, (PrivateCompanyI) company); lPrivateCompanies.add((PrivateCompanyI) company); } else if (company instanceof PublicCompanyI) { ((PublicCompanyI)company).setIndex (numberOfPublicCompanies++); mPublicCompanies.put(name, (PublicCompanyI) company); lPublicCompanies.add((PublicCompanyI) company); } /* By type and name */ if (!mCompaniesByTypeAndName.containsKey(type)) mCompaniesByTypeAndName.put(type, new HashMap<String, CompanyI>()); ((Map<String, CompanyI>) mCompaniesByTypeAndName.get(type)).put( name, company); } catch (Exception e) { throw new ConfigurationException(LocalText.getText( "ClassCannotBeInstantiated", cType.getClassName()), e); } } /* Read and configure the start packets */ List<Tag> packetTags = tag.getChildren("StartPacket"); if (packetTags != null) { for (Tag packetTag : tag.getChildren("StartPacket")) { // Extract the attributes of the Component String name = packetTag.getAttributeAsString("name"); if (name == null) name = "Initial"; String roundClass = packetTag.getAttributeAsString("roundClass"); if (roundClass == null) { throw new ConfigurationException(LocalText.getText( "StartPacketHasNoClass", name)); } StartPacket sp = new StartPacket(name, roundClass); startPackets.add(sp); sp.configureFromXML(packetTag); } } /* Read and configure additional rules */ /* This part may move later to a GameRules or GameManager XML */ Tag rulesTag = tag.getChild("StockRoundRules"); if (rulesTag != null) { for (String ruleTagName : rulesTag.getChildren().keySet()) { if (ruleTagName.equals("NoSaleInFirstSR")) { StockRound.setNoSaleInFirstSR(); } else if (ruleTagName.equals("NoSaleIfNotOperated")) { StockRound.setNoSaleIfNotOperated(); } } } } // Post XML parsing initialisations public void initCompanies() throws ConfigurationException { for (PublicCompanyI comp : lPublicCompanies) { comp.init2(); } } /** * @see rails.game.CompanyManagerI#getCompany(java.lang.String) * */ public PrivateCompanyI getPrivateCompany(String name) { return mPrivateCompanies.get(name); } public PublicCompanyI getPublicCompany(String name) { return mPublicCompanies.get(name); } public List<PrivateCompanyI> getAllPrivateCompanies() { return lPrivateCompanies; } public List<PublicCompanyI> getAllPublicCompanies() { return lPublicCompanies; } public PublicCompanyI getCompanyByName(String name) { for (int i = 0; i < lPublicCompanies.size(); i++) { PublicCompany co = (PublicCompany) lPublicCompanies.get(i); if (name.equalsIgnoreCase(co.getName())) { return lPublicCompanies.get(i); } } return null; } public CompanyI getCompany(String type, String name) { if (mCompaniesByTypeAndName.containsKey(type)) { return (mCompaniesByTypeAndName.get(type)).get(name); } else { return null; } } public void closeAllPrivates() { if (lPrivateCompanies == null) return; for (PrivateCompanyI priv : lPrivateCompanies) { priv.setClosed(); } } public List<PrivateCompanyI> getPrivatesOwnedByPlayers() { List<PrivateCompanyI> privatesOwnedByPlayers = new ArrayList<PrivateCompanyI>(); for (PrivateCompanyI priv : getAllPrivateCompanies()) { if (priv.getPortfolio().getOwner() instanceof Player) { privatesOwnedByPlayers.add(priv); } } return privatesOwnedByPlayers; } } \ No newline at end of file Index: PublicCompany.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompany.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** PublicCompany.java 29 Nov 2008 20:01:33 -0000 1.44 --- PublicCompany.java 3 Dec 2008 20:15:15 -0000 1.45 *************** *** 218,222 **** /** Initial train at floating time */ protected String initialTrain = null; ! /** * The constructor. The way this class is instantiated does not allow --- 218,222 ---- /** Initial train at floating time */ protected String initialTrain = null; ! /** * The constructor. The way this class is instantiated does not allow *************** *** 249,254 **** numberOfBaseTokens = tag.getAttributeAsInteger("tokens", 1); ! ! boolean certsAreInitiallyAvailable = tag.getAttributeAsBoolean("available", true); --- 249,254 ---- numberOfBaseTokens = tag.getAttributeAsInteger("tokens", 1); ! ! boolean certsAreInitiallyAvailable = tag.getAttributeAsBoolean("available", true); *************** *** 279,283 **** if (hex != null) { destinationHex = hex; ! hasReachedDestination = new BooleanState (name+"_reachedDestination", false); } else { throw new ConfigurationException("Invalid destination hex " --- 279,283 ---- if (hex != null) { destinationHex = hex; ! hasReachedDestination = new BooleanState (name+"_reachedDestination", false); } else { throw new ConfigurationException("Invalid destination hex " *************** *** 420,424 **** phaseMap.put(phases[k], lays); } - // phaseMap.put("turns", validForTurns); if (validForTurns > 0) { if (turnsWithExtraTileLaysInit == null) { --- 420,423 ---- *************** *** 449,455 **** "type", "")); int number = certificateTag.getAttributeAsInteger("number", 1); ! ! boolean certIsInitiallyAvailable ! = certificateTag.getAttributeAsBoolean("available", certsAreInitiallyAvailable); --- 448,454 ---- "type", "")); int number = certificateTag.getAttributeAsInteger("number", 1); ! ! boolean certIsInitiallyAvailable ! = certificateTag.getAttributeAsBoolean("available", certsAreInitiallyAvailable); *************** *** 527,530 **** --- 526,530 ---- /** Initialisation, to be called directly after instantiation (cloning) */ + @Override public void init(String name, CompanyTypeI type) { super.init(name, type); *************** *** 580,584 **** } ! public void setIndex (int index) { publicNumber = index; --- 580,584 ---- } ! public void setIndex (int index) { publicNumber = index; *************** *** 629,633 **** /** * Return the company token background colour. ! * * @return Color object */ --- 629,633 ---- /** * Return the company token background colour. ! * * @return Color object */ *************** *** 638,642 **** /** * Return the company token background colour. ! * * @return Hexadecimal string RRGGBB. */ --- 638,642 ---- /** * Return the company token background colour. ! * * @return Hexadecimal string RRGGBB. */ *************** *** 647,651 **** /** * Return the company token foreground colour. ! * * @return Color object. */ --- 647,651 ---- /** * Return the company token foreground colour. ! * * @return Color object. */ *************** *** 656,660 **** /** * Return the company token foreground colour. ! * * @return Hexadecimal string RRGGBB. */ --- 656,660 ---- /** * Return the company token foreground colour. ! * * @return Hexadecimal string RRGGBB. */ *************** *** 697,710 **** return destinationHex; } ! public boolean hasDestination () { return destinationHex != null; } ! public boolean hasReachedDestination() { return hasReachedDestination != null && hasReachedDestination.booleanValue(); } ! public void setReachedDestination (boolean value) { hasReachedDestination.set(value); --- 697,710 ---- return destinationHex; } ! public boolean hasDestination () { return destinationHex != null; } ! public boolean hasReachedDestination() { return hasReachedDestination != null && hasReachedDestination.booleanValue(); } ! public void setReachedDestination (boolean value) { hasReachedDestination.set(value); *************** *** 811,815 **** /** * Has the company already floated? ! * * @return true if the company has floated. */ --- 811,815 ---- /** * Has the company already floated? ! * * @return true if the company has floated. */ *************** *** 820,824 **** /** * Has the company already operated? ! * * @return true if the company has operated. */ --- 820,824 ---- /** * Has the company already operated? ! * * @return true if the company has operated. */ *************** *** 849,853 **** * used to start a company!</i> Use <code><b>start()</b></code> in * stead. ! * * @param spaceI */ --- 849,853 ---- * used to start a company!</i> Use <code><b>start()</b></code> in * stead. ! * * @param spaceI */ *************** *** 862,866 **** /** * Get the company par (initial) price. ! * * @return StockSpace object, which defines the company start position on * the stock chart. --- 862,866 ---- /** * Get the company par (initial) price. ! * * @return StockSpace object, which defines the company start position on * the stock chart. *************** *** 873,877 **** } } ! public int getIPOPrice () { if (hasParPrice) { --- 873,877 ---- } } ! public int getIPOPrice () { if (hasParPrice) { *************** *** 885,889 **** } } ! public int getMarketPrice () { if (getCurrentSpace() != null) { --- 885,889 ---- } } ! public int getMarketPrice () { if (getCurrentSpace() != null) { *************** *** 896,900 **** /** * Set a new company price. ! * * @param price The StockSpace object that defines the new location on the * stock market. --- 896,900 ---- /** * Set a new company price. ! * * @param price The StockSpace object that defines the new location on the * stock market. *************** *** 919,923 **** /** * Get the current company share price. ! * * @return The StockSpace object that defines the current location on the * stock market. --- 919,923 ---- /** * Get the current company share price. ! * * @return The StockSpace object that defines the current location on the * stock market. *************** *** 929,933 **** /** * Add a given amount to the company treasury. ! * * @param amount The amount to add (may be negative). */ --- 929,933 ---- /** * Add a given amount to the company treasury. ! * * @param amount The amount to add (may be negative). */ *************** *** 938,942 **** /** * Get the current company treasury. ! * * @return The current cash amount. */ --- 938,942 ---- /** * Get the current company treasury. ! * * @return The current cash amount. */ *************** *** 962,966 **** /** * Get a list of this company's certificates. ! * * @return ArrayList containing the certificates (item 0 is the President's * share). --- 962,966 ---- /** * Get a list of this company's certificates. ! * * @return ArrayList containing the certificates (item 0 is the President's * share). *************** *** 973,977 **** * Assign a predefined list of certificates to this company. The list is * deep cloned. ! * * @param list ArrayList containing the certificates. */ --- 973,977 ---- * Assign a predefined list of certificates to this company. The list is * deep cloned. ! * * @param list ArrayList containing the certificates. */ *************** *** 984,990 **** } } ! ! /** ! * Backlink the certificates to this company, * and give each one a type name. * --- 984,990 ---- } } ! ! /** ! * Backlink the certificates to this company, * and give each one a type name. * *************** *** 998,1002 **** /** * Add a certificate to the end of this company's list of certificates. ! * * @param certificate The certificate to add. */ --- 998,1002 ---- /** * Add a certificate to the end of this company's list of certificates. ! * * @param certificate The certificate to add. */ *************** *** 1010,1014 **** * Get the Portfolio of this company, containing all privates and * certificates owned.. ! * * @return The Portfolio of this company. */ --- 1010,1014 ---- * Get the Portfolio of this company, containing all privates and * certificates owned.. ! * * @return The Portfolio of this company. */ *************** *** 1019,1023 **** /** * Get the percentage of shares that must be sold to float the company. ! * * @return The float percentage. */ --- 1019,1023 ---- /** * Get the percentage of shares that must be sold to float the company. ! * * @return The float percentage. */ *************** *** 1028,1032 **** /** * Get the company President. ! * */ public Player getPresident() { --- 1028,1032 ---- /** * Get the company President. ! * */ public Player getPresident() { *************** *** 1037,1041 **** return null; } ! public PublicCertificateI getPresidentsShare () { return certificates.get(0); --- 1037,1041 ---- return null; } ! public PublicCertificateI getPresidentsShare () { return certificates.get(0); *************** *** 1050,1054 **** /** * Store the last revenue earned by this company. ! * * @param i The last revenue amount. */ --- 1050,1054 ---- /** * Store the last revenue earned by this company. ! * * @param i The last revenue amount. */ *************** *** 1059,1063 **** /** * Get the last revenue earned by this company. ! * * @return The last revenue amount. */ --- 1059,1063 ---- /** * Get the last revenue earned by this company. ! * * @return The last revenue amount. */ *************** *** 1088,1092 **** /** Split a dividend. TODO Optional rounding down the payout ! * * @param amount */ --- 1088,1092 ---- /** Split a dividend. TODO Optional rounding down the payout ! * * @param amount */ *************** *** 1110,1114 **** /** * Distribute the dividend amongst the shareholders. ! * * @param amount */ --- 1110,1114 ---- /** * Distribute the dividend amongst the shareholders. ! * * @param amount */ *************** *** 1161,1165 **** /** * Withhold a given amount of revenue (and store it). ! * * @param The revenue amount. */ --- 1161,1165 ---- /** * Withhold a given amount of revenue (and store it). ! * * @param The revenue amount. */ *************** *** 1175,1179 **** * (jan 2008) interpreted as: no share is owned either by the Bank or by the * company's own Treasury. ! * * @return true if the share price can move up. */ --- 1175,1179 ---- * (jan 2008) interpreted as: no share is owned either by the Bank or by the * company's own Treasury. ! * * @return true if the share price can move up. */ *************** *** 1199,1203 **** /** * Get the unit of share. ! * * @return The percentage of ownership that is called "one share". */ --- 1199,1203 ---- /** * Get the unit of share. ! * * @return The percentage of ownership that is called "one share". */ *************** *** 1271,1275 **** /** * Check if the presidency has changed for a <b>buying</b> player. ! * * @param buyer Player who has just bought a certificate. */ --- 1271,1275 ---- /** * Check if the presidency has changed for a <b>buying</b> player. ! * * @param buyer Player who has just bought a certificate. */ *************** *** 1417,1421 **** * "sequence" method. The other token layong costing methods will be * implemented later. ! * * @param index The sequence number of the token that the company is laying. * @return The cost of laying that token. --- 1417,1421 ---- * "sequence" method. The other token layong costing methods will be * implemented later. ! * * @param index The sequence number of the token that the company is laying. * @return The cost of laying that token. Index: RoundI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/RoundI.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RoundI.java 30 Jun 2008 20:35:29 -0000 1.7 --- RoundI.java 3 Dec 2008 20:15:15 -0000 1.8 *************** *** 2,9 **** package rails.game; - import java.util.List; - import rails.game.action.PossibleAction; - import rails.game.special.SpecialPropertyI; /** --- 2,6 ---- *************** *** 26,32 **** public String getHelp(); - /** @deprecated */ - public List<SpecialPropertyI> getSpecialProperties(); - public boolean process(PossibleAction action); --- 23,26 ---- Index: Company.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Company.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Company.java 4 Jun 2008 19:00:30 -0000 1.8 --- Company.java 3 Dec 2008 20:15:15 -0000 1.9 *************** *** 28,32 **** protected int certLimitCount = 2; - // protected boolean closed = false; protected BooleanState closedObject; --- 28,31 ---- *************** *** 145,149 **** * Stub method implemented to comply with TokenHolderI interface. Always * returns false. ! * * Use addToken(MapHex hex) method instead. */ --- 144,148 ---- * Stub method implemented to comply with TokenHolderI interface. Always * returns false. ! * * Use addToken(MapHex hex) method instead. */ Index: PublicCompanyI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/PublicCompanyI.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** PublicCompanyI.java 20 Nov 2008 21:49:38 -0000 1.25 --- PublicCompanyI.java 3 Dec 2008 20:15:15 -0000 1.26 *************** *** 247,252 **** public boolean hasParPrice(); - // public int percentageOwnedByPlayers(); - public boolean isSplitAllowed(); --- 247,250 ---- *************** *** 257,269 **** public void checkPresidencyOnBuy(Player buyer); - /** - * Only usable if the float percentage is fixed. Games where the percentage - * varies must check this in StockRound and possibly StartRound. - */ - // public boolean checkFlotation(boolean moveCash); - /** @deprecated */ - @Deprecated - public int percentageOwnedByPlayers(); - public int getCapitalisation(); --- 255,258 ---- *************** *** 274,278 **** public int getCurrentTrainLimit(); - // public boolean mayBuyTrains (); public int getNumberOfTrains(); --- 263,266 ---- Index: OperatingRound.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/OperatingRound.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** OperatingRound.java 29 Nov 2008 20:01:33 -0000 1.45 --- OperatingRound.java 3 Dec 2008 20:15:15 -0000 1.46 *************** *** 111,115 **** /** * The constructor. ! * * @param operate If false, only the privates pay out. This applies if the * Start Packet has not yet been sold completely. --- 111,115 ---- /** * The constructor. ! * * @param operate If false, only the privates pay out. This applies if the * Start Packet has not yet been sold completely. *************** *** 204,210 **** result = buyPrivate((BuyPrivate) selectedAction); ! } else if (selectedAction instanceof ReachDestinations) { ! result = reachDestinations ((ReachDestinations) selectedAction); --- 204,210 ---- result = buyPrivate((BuyPrivate) selectedAction); ! } else if (selectedAction instanceof ReachDestinations) { ! result = reachDestinations ((ReachDestinations) selectedAction); *************** *** 360,364 **** if (tile != null) { ! if (cost > 0) new CashMove(operatingCompany, null, cost); operatingCompany.layTile(hex, tile, orientation, cost); --- 360,364 ---- if (tile != null) { ! if (cost > 0) new CashMove(operatingCompany, null, cost); operatingCompany.layTile(hex, tile, orientation, cost); *************** *** 765,769 **** * Internal method: change the OR state to the next step. If the currently * Operating Company is done, notify this. ! * * @param company The current company. */ --- 765,769 ---- * Internal method: change the OR state to the next step. If the currently * Operating Company is done, notify this. ! * * @param company The current company. */ *************** *** 919,923 **** /* Special-property tile lays */ currentSpecialTileLays.clear(); - // specialPropertyPerHex.clear(); /* * In 1835, this only applies to major companies. TODO: For now, --- 919,922 ---- *************** *** 959,963 **** /* Special-property tile lays */ currentSpecialTokenLays.clear(); ! /* * In 1835, this only applies to major companies. TODO: For now, --- 958,962 ---- /* Special-property tile lays */ currentSpecialTokenLays.clear(); ! /* * In 1835, this only applies to major companies. TODO: For now, *************** *** 1013,1017 **** /** * The current Company is done operating. ! * * @param company Name of the company that finished operating. * @return False if an error is found. --- 1012,1016 ---- /** * The current Company is done operating. ! * * @param company Name of the company that finished operating. * @return False if an error is found. *************** *** 1064,1068 **** priv.checkClosingIfExercised(true); } ! if (setNextOperatingCompany(false)) { --- 1063,1067 ---- priv.checkClosingIfExercised(true); } ! if (setNextOperatingCompany(false)) { *************** *** 1072,1079 **** } } ! protected boolean setNextOperatingCompany(boolean initial) { ! ! if (operatingCompanyIndexObject == null) { operatingCompanyIndexObject = --- 1071,1078 ---- } } ! protected boolean setNextOperatingCompany(boolean initial) { ! ! if (operatingCompanyIndexObject == null) { operatingCompanyIndexObject = *************** *** 1085,1091 **** operatingCompanyIndexObject.add(1); } ! operatingCompanyIndex = operatingCompanyIndexObject.intValue(); ! if (operatingCompanyIndex >= operatingCompanyArray.length) { return false; --- 1084,1090 ---- operatingCompanyIndexObject.add(1); } ! operatingCompanyIndex = operatingCompanyIndexObject.intValue(); ! if (operatingCompanyIndex >= operatingCompanyArray.length) { return false; *************** *** 1103,1107 **** priv.checkClosingIfExercised(true); } ! // OR done. Inform GameManager. ReportBuffer.add(LocalText.getText("EndOfOperatingRound", thisOrNumber)); --- 1102,1106 ---- priv.checkClosingIfExercised(true); } ! // OR done. Inform GameManager. ReportBuffer.add(LocalText.getText("EndOfOperatingRound", thisOrNumber)); *************** *** 1455,1466 **** } ! public boolean reachDestinations (ReachDestinations action) { ! List<PublicCompanyI> destinedCompanies = action.getReachedCompanies(); if (destinedCompanies != null) { for (PublicCompanyI company : destinedCompanies) { ! if (company.hasDestination() && !company.hasReachedDestination()) { if (!MoveSet.isOpen()) MoveSet.start(true); --- 1454,1465 ---- } ! public boolean reachDestinations (ReachDestinations action) { ! List<PublicCompanyI> destinedCompanies = action.getReachedCompanies(); if (destinedCompanies != null) { for (PublicCompanyI company : destinedCompanies) { ! if (company.hasDestination() && !company.hasReachedDestination()) { if (!MoveSet.isOpen()) MoveSet.start(true); *************** *** 1478,1489 **** return true; } ! /** Stub for applying any follow-up actions when ! * a company reaches it destinations. * Default version: no actions. * @param company */ protected void reachDestination (PublicCompanyI company) { ! } --- 1477,1488 ---- return true; } ! /** Stub for applying any follow-up actions when ! * a company reaches it destinations. * Default version: no actions. * @param company */ protected void reachDestination (PublicCompanyI company) { ! } *************** *** 1492,1496 **** /** * Get the public company that has the turn to operate. ! * * @return The currently operating company object. */ --- 1491,1495 ---- /** * Get the public company that has the turn to operate. ! * * @return The currently operating company object. */ *************** *** 1506,1510 **** /** * Get the current operating round step (i.e. the next action). ! * * @return The number that defines the next action. */ --- 1505,1509 ---- /** * Get the current operating round step (i.e. the next action). ! * * @return The number that defines the next action. */ *************** *** 1517,1521 **** * should only be done for specific rails.game exceptions, such as forced * train purchases. ! * * @param step */ --- 1516,1520 ---- * should only be done for specific rails.game exceptions, such as forced * train purchases. ! * * @param step */ *************** *** 1539,1543 **** * actions. (new method, intended to absorb code from several other * methods). ! * */ @Override --- 1538,1542 ---- * actions. (new method, intended to absorb code from several other * methods). ! * */ @Override *************** *** 1597,1601 **** setBonusTokenLays(); ! setDestinationActions(); --- 1596,1600 ---- setBonusTokenLays(); ! setDestinationActions(); *************** *** 1644,1648 **** * trains that the company has no money for. If there is no cash to buy any * train from the Bank, prepare for emergency train buying. ! * * @return List of all trains that could potentially be bought. */ --- 1643,1647 ---- * trains that the company has no money for. If there is no cash to buy any * train from the Bank, prepare for emergency train buying. ! * * @return List of all trains that could potentially be bought. */ *************** *** 1799,1803 **** * Returns whether or not the company is allowed to buy a train, considering * its train limit. ! * * @return */ --- 1798,1802 ---- * Returns whether or not the company is allowed to buy a train, considering * its train limit. ! * * @return */ *************** *** 1829,1841 **** } } ! ! /** * This is currently a stub, as it is unclear if there is a common * rule for setting destination reaching options. * See OperatingRound_1856 for a first implementation ! * of such rules. */ protected void setDestinationActions () { ! } --- 1828,1840 ---- } } ! ! /** * This is currently a stub, as it is unclear if there is a common * rule for setting destination reaching options. * See OperatingRound_1856 for a first implementation ! * of such rules. */ protected void setDestinationActions () { ! } Index: CompanyManagerI.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/CompanyManagerI.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CompanyManagerI.java 4 Jun 2008 19:00:32 -0000 1.9 --- CompanyManagerI.java 3 Dec 2008 20:15:15 -0000 1.10 *************** *** 18,22 **** /** * Returns the Private Company identified by the supplied name. ! * * @param name the name of the company sought * @return the Private Company with the supplied name --- 18,22 ---- /** * Returns the Private Company identified by the supplied name. ! * * @param name the name of the company sought * @return the Private Company with the supplied name *************** *** 26,30 **** /** * Returns the Public Company identified by the supplied name. ! * * @param name the name of the company sought * @return the Public Company with the supplied name --- 26,30 ---- /** * Returns the Public Company identified by the supplied name. ! * * @param name the name of the company sought * @return the Public Company with the supplied name *************** *** 34,38 **** /** * Gives a list of all the registered Private Companies. ! * * @return a list of all the registered Private Companies */ --- 34,38 ---- /** * Gives a list of all the registered Private Companies. ! * * @return a list of all the registered Private Companies */ *************** *** 41,45 **** /** * Gives a list of all the registered Private Companies. ! * * @return a list of all the registered Private Companies */ --- 41,45 ---- /** * Gives a list of all the registered Private Companies. ! * * @return a list of all the registered Private Companies */ *************** *** 48,52 **** /** * Find a company by type and name ! * * @param type The name of the CompanyType * @param name The name of the Company --- 48,52 ---- /** * Find a company by type and name ! * * @param type The name of the CompanyType * @param name The name of the Company *************** *** 60,65 **** public void initCompanies() throws ConfigurationException; - public List<PublicCompanyI> getCompaniesWithExcessTrains(); - public void closeAllPrivates(); --- 60,63 ---- Index: Phase.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/Phase.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Phase.java 3 Nov 2008 15:55:00 -0000 1.9 --- Phase.java 3 Dec 2008 20:15:14 -0000 1.10 *************** *** 2,14 **** package rails.game; ! import java.util.ArrayList; ! import java.util.HashMap; ! import java.util.List; ! import java.util.Map; ! ! import rails.util.Tag; import org.apache.log4j.Logger; public class Phase implements PhaseI { --- 2,11 ---- package rails.game; ! import java.util.*; import org.apache.log4j.Logger; + import rails.util.Tag; + public class Phase implements PhaseI { *************** *** 42,46 **** /** Items to close if a phase gets activated */ protected List<Closeable> closedObjects = null; ! /** A HashMap to contain phase-dependent parameters * by name and value. --- 39,43 ---- /** Items to close if a phase gets activated */ protected List<Closeable> closedObjects = null; ! /** A HashMap to contain phase-dependent parameters * by name and value. *************** *** 48,56 **** protected Map<String, String> parameters = null; - // protected static boolean previousPrivateSellingAllowed = false; - // protected static int previousNumberOfOperatingRounds = 1; - // protected static String previousTileColours = ""; - // protected static int previousOffBoardRevenueStep = 1; - protected static Logger log = Logger.getLogger(Phase.class.getPackage().getName()); --- 45,48 ---- *************** *** 130,134 **** oneTrainPerTypePerTurn); } ! Tag parameterTag = tag.getChild("Parameters"); if (parameterTag != null) { --- 122,126 ---- oneTrainPerTypePerTurn); } ! Tag parameterTag = tag.getChild("Parameters"); if (parameterTag != null) { *************** *** 211,215 **** closedObjects.add(object); } ! public String getParameterAsString (String key) { if (parameters != null) { --- 203,207 ---- closedObjects.add(object); } ! public String getParameterAsString (String key) { if (parameters != null) { *************** *** 219,223 **** } } ! public int getParameterAsInteger (String key) { String stringValue = getParameterAsString(key); --- 211,215 ---- } } ! public int getParameterAsInteger (String key) { String stringValue = getParameterAsString(key); *************** *** 234,237 **** --- 226,230 ---- } + @Override public String toString() { return name; |