From: Erik V. <ev...@us...> - 2012-05-08 11:56:30
|
rails/game/PublicCompany.java | 26 +++++++++++++++++++++----- rails/game/PublicCompanyI.java | 7 +++---- 2 files changed, 24 insertions(+), 9 deletions(-) New commits: commit d136bf8dd11a71574fee182a00c2f1277370a39d Author: Erik Vos <eri...@xs...> Date: Tue May 8 13:55:25 2012 +0200 Companies with a fixed start price postpone laying the current price token until floating time. This applies to 1835 (bug reported by Volker Schnell) and 1825. Only defaults are set. For 1837, an (game or company) attribute must be added to set this rule also for the companies that don't ahve a fixed starting price. diff --git a/rails/game/PublicCompany.java b/rails/game/PublicCompany.java index 92c045e..1b589e2 100644 --- a/rails/game/PublicCompany.java +++ b/rails/game/PublicCompany.java @@ -29,10 +29,10 @@ public class PublicCompany extends Company implements PublicCompanyI { protected static int numberOfPublicCompanies = 0; - // Home base token lay times + // Home base & price token lay times protected static final int WHEN_STARTED = 0; protected static final int WHEN_FLOATED = 1; - protected static final int START_OF_FIRST_OR = 2; + protected static final int START_OF_FIRST_OR = 2; // Only applies to home base tokens // Base token lay cost calculation methods public static final String BASE_COST_SEQUENCE = "sequence"; @@ -235,6 +235,8 @@ public class PublicCompany extends Company implements PublicCompanyI { /*---- variables needed during initialisation -----*/ protected String startSpace = null; + protected int dropPriceToken = WHEN_STARTED; + protected int capitalisation = CAPITALISE_FULL; /** Fixed price (for a 1835-style minor) */ @@ -313,6 +315,11 @@ public class PublicCompany extends Company implements PublicCompanyI { floatPerc = tag.getAttributeAsInteger("floatPerc", floatPerc); startSpace = tag.getAttributeAsString("startspace"); + // Set the default price token drop time. + // Currently, no exceptions exist, so this value isn't changed anywhere yet. + // Any (future) games with exceptions to these defaults will require a separate XML attribute. + // Known games to have exceptions: 1837. + dropPriceToken = startSpace != null ? WHEN_FLOATED : WHEN_STARTED; fixedPrice = tag.getAttributeAsInteger("price", 0); @@ -934,8 +941,12 @@ public class PublicCompany extends Company implements PublicCompanyI { if (startSpace != null) { setParSpace(startSpace); - // The current price is set via the Stock Market - stockMarket.start(this, startSpace); + setCurrentSpace(startSpace); + + // Drop the current price token, if allowed at this point + if (dropPriceToken == WHEN_STARTED) { + stockMarket.start(this, startSpace); + } } @@ -1002,6 +1013,11 @@ public class PublicCompany extends Company implements PublicCompanyI { stockMarket.moveUp(this); } + // Drop the current price token, if allowed at this point + if (dropPriceToken == WHEN_FLOATED) { + stockMarket.start(this, getCurrentSpace()); + } + if (homeBaseTokensLayTime == WHEN_FLOATED) { layHomeBaseTokens(); } @@ -1170,7 +1186,7 @@ public class PublicCompany extends Company implements PublicCompanyI { * stock market. */ public void setCurrentSpace(StockSpaceI price) { - if (price != null) { + if (price != null && price != getCurrentSpace()) { currentPrice.setPrice(price); } } diff --git a/rails/game/PublicCompanyI.java b/rails/game/PublicCompanyI.java index ecd928f..7b28906 100644 --- a/rails/game/PublicCompanyI.java +++ b/rails/game/PublicCompanyI.java @@ -11,12 +11,11 @@ import rails.game.model.*; */ public interface PublicCompanyI extends CompanyI, CashHolder, TokenHolder { + /* Capitalisation options */ public static final int CAPITALISE_FULL = 0; - public static final int CAPITALISE_INCREMENTAL = 1; - public static final int CAPITALISE_WHEN_BOUGHT = 2; - + public void setIndex (int index); @@ -96,7 +95,7 @@ public interface PublicCompanyI extends CompanyI, CashHolder, TokenHolder { */ public boolean hasFloated(); - + public ModelObject getFloatedModel(); /** |