|
From: Stefan F. <ste...@us...> - 2012-01-31 14:30:14
|
rails/common/parser/GameFileParser.java | 8 -
rails/game/Game.java | 2
rails/game/GameManager.java | 10 -
rails/game/OperatingRound.java | 2
rails/game/PublicCompany.java | 14 -
rails/game/Round.java | 4
rails/game/ShareSellingRound.java | 2
rails/game/StockMarket.java | 141 ++++++++++---------
rails/game/StockMarketI.java | 51 -------
rails/game/StockRound.java | 18 +-
rails/game/StockSpace.java | 112 ++++++++++-----
rails/game/StockSpaceI.java | 160 ----------------------
rails/game/StockSpaceType.java | 37 ++++-
rails/game/StockSpaceTypeI.java | 86 -----------
rails/game/TreasuryShareRound.java | 2
rails/game/model/PriceModel.java | 68 +++------
rails/game/model/ViewUpdate.java | 2
rails/game/specific/_1825/PublicCompany_1825.java | 4
rails/game/specific/_1835/StockRound_1835.java | 4
rails/game/specific/_1856/CGRFormationRound.java | 2
rails/game/specific/_1856/PublicCompany_1856.java | 2
rails/game/specific/_18EU/StockRound_18EU.java | 4
rails/game/state/PriceMove.java | 51 -------
rails/game/state/PriceTokenMove.java | 52 -------
rails/ui/swing/StartRoundWindow.java | 10 -
rails/ui/swing/StockChart.java | 4
rails/ui/swing/elements/GUIStockSpace.java | 6
test/GameTestServlet.java | 8 -
test/StockMarketTestServlet.java | 6
test/StockTest.java | 4
30 files changed, 269 insertions(+), 607 deletions(-)
New commits:
commit 0bd58a3e647b7840c035b9f6642668df5fb23960
Author: Stefan Frey <ste...@we...>
Date: Mon Jan 30 16:44:21 2012 +0100
rewrote StockSpace classes and PriceMove mechanism
diff --git a/rails/common/parser/GameFileParser.java b/rails/common/parser/GameFileParser.java
index d6eb4ec..31bc10a 100644
--- a/rails/common/parser/GameFileParser.java
+++ b/rails/common/parser/GameFileParser.java
@@ -12,7 +12,7 @@ import rails.game.GameManager;
import rails.game.MapManager;
import rails.game.PhaseManager;
import rails.game.PlayerManager;
-import rails.game.StockMarketI;
+import rails.game.StockMarket;
import rails.game.TileManager;
import rails.game.TrainManager;
import rails.game.state.Context;
@@ -28,7 +28,7 @@ public class GameFileParser extends XMLParser {
private PlayerManager playerManager;
private PhaseManager phaseManager;
private TrainManager trainManager;
- private StockMarketI stockMarket;
+ private StockMarket stockMarket;
private MapManager mapManager;
private TileManager tileManager;
private RevenueManager revenueManager;
@@ -48,7 +48,7 @@ public class GameFileParser extends XMLParser {
playerManager = (PlayerManager) componentManager.findComponent("PlayerManager");
bank = (Bank) componentManager.findComponent("Bank");
companyManager = (CompanyManagerI) componentManager.findComponent(CompanyManagerI.COMPONENT_NAME);
- stockMarket = (StockMarketI) componentManager.findComponent(StockMarketI.COMPONENT_NAME);
+ stockMarket = (StockMarket) componentManager.findComponent(StockMarket.COMPONENT_NAME);
gameManager = (GameManager) componentManager.findComponent("GameManager");
phaseManager = (PhaseManager) componentManager.findComponent("PhaseManager");
trainManager = (TrainManager) componentManager.findComponent("TrainManager");
@@ -110,7 +110,7 @@ public class GameFileParser extends XMLParser {
/**
* @return the stockMarket
*/
- public StockMarketI getStockMarket() {
+ public StockMarket getStockMarket() {
return stockMarket;
}
diff --git a/rails/game/Game.java b/rails/game/Game.java
index db247c3..bab64de 100644
--- a/rails/game/Game.java
+++ b/rails/game/Game.java
@@ -22,7 +22,7 @@ public class Game {
protected PlayerManager playerManager;
protected PhaseManager phaseManager;
protected TrainManager trainManager;
- protected StockMarketI stockMarket;
+ protected StockMarket stockMarket;
protected MapManager mapManager;
protected TileManager tileManager;
protected RevenueManager revenueManager;
diff --git a/rails/game/GameManager.java b/rails/game/GameManager.java
index c36d563..f476031 100644
--- a/rails/game/GameManager.java
+++ b/rails/game/GameManager.java
@@ -59,7 +59,7 @@ public class GameManager extends GameItem implements Owner, ConfigurableComponen
protected CompanyManagerI companyManager;
protected PhaseManager phaseManager;
protected TrainManager trainManager;
- protected StockMarketI stockMarket;
+ protected StockMarket stockMarket;
protected MapManager mapManager;
protected TileManager tileManager;
protected RevenueManager revenueManager;
@@ -532,7 +532,7 @@ public class GameManager extends GameItem implements Owner, ConfigurableComponen
CompanyManagerI companyManager,
PhaseManager phaseManager,
TrainManager trainManager,
- StockMarketI stockMarket,
+ StockMarket stockMarket,
MapManager mapManager,
TileManager tileManager,
RevenueManager revenueManager,
@@ -1317,7 +1317,7 @@ public class GameManager extends GameItem implements Owner, ConfigurableComponen
addToNextPlayerMessages(msg, true);
}
- public void registerMaxedSharePrice(PublicCompany company, StockSpaceI space){
+ public void registerMaxedSharePrice(PublicCompany company, StockSpace space){
gameOverPending.set(true);
ReportBuffer.add(LocalText.getText("MaxedSharePriceReportText",
company.getId(),
@@ -1581,7 +1581,7 @@ public class GameManager extends GameItem implements Owner, ConfigurableComponen
return trainManager;
}
- public StockMarketI getStockMarket() {
+ public StockMarket getStockMarket() {
return stockMarket;
}
@@ -1806,7 +1806,7 @@ public class GameManager extends GameItem implements Owner, ConfigurableComponen
Map<Integer, PublicCompany> operatingCompanies =
new TreeMap<Integer, PublicCompany>();
- StockSpaceI space;
+ StockSpace space;
int key;
int minorNo = 0;
for (PublicCompany company : companyManager.getAllPublicCompanies()) {
diff --git a/rails/game/OperatingRound.java b/rails/game/OperatingRound.java
index 7f592f6..abf8a41 100644
--- a/rails/game/OperatingRound.java
+++ b/rails/game/OperatingRound.java
@@ -2375,7 +2375,7 @@ public class OperatingRound extends Round implements Observer {
if (!company.hasStockPrice()) return;
// Check if company has entered a closing area
- StockSpaceI newSpace = company.getCurrentSpace();
+ StockSpace newSpace = company.getCurrentSpace();
if (newSpace.closesCompany() && company.canClose()) {
company.setClosed();
ReportBuffer.add(LocalText.getText("CompanyClosesAt",
diff --git a/rails/game/PublicCompany.java b/rails/game/PublicCompany.java
index 6f022a6..7b9f364 100644
--- a/rails/game/PublicCompany.java
+++ b/rails/game/PublicCompany.java
@@ -279,7 +279,7 @@ public class PublicCompany extends Company implements CashOwner {
protected GameManager gameManager;
protected Bank bank;
- protected StockMarketI stockMarket;
+ protected StockMarket stockMarket;
protected MapManager mapManager;
/** Rights */
@@ -911,7 +911,7 @@ public class PublicCompany extends Company implements CashOwner {
return mustHaveOperatedToTradeShares;
}
- public void start(StockSpaceI startSpace) {
+ public void start(StockSpace startSpace) {
hasStarted.set(true);
if (hasStockPrice) buyable.set(true);
@@ -932,7 +932,7 @@ public class PublicCompany extends Company implements CashOwner {
}
public void start(int price) {
- StockSpaceI startSpace = stockMarket.getStartSpace(price);
+ StockSpace startSpace = stockMarket.getStartSpace(price);
if (startSpace == null) {
log.error("Invalid start price " + Bank.format(price));
} else {
@@ -1099,7 +1099,7 @@ public class PublicCompany extends Company implements CashOwner {
*
* @param spaceI
*/
- public void setParSpace(StockSpaceI space) {
+ public void setParSpace(StockSpace space) {
if (hasStockPrice) {
if (space != null) {
parPrice.setPrice(space);
@@ -1113,7 +1113,7 @@ public class PublicCompany extends Company implements CashOwner {
* @return StockSpace object, which defines the company start position on
* the stock chart.
*/
- public StockSpaceI getStartSpace() {
+ public StockSpace getStartSpace() {
if (hasParPrice) {
return parPrice != null ? parPrice.getPrice() : null;
} else {
@@ -1156,7 +1156,7 @@ public class PublicCompany extends Company implements CashOwner {
* @param price The StockSpace object that defines the new location on the
* stock market.
*/
- public void setCurrentSpace(StockSpaceI price) {
+ public void setCurrentSpace(StockSpace price) {
if (price != null) {
currentPrice.setPrice(price);
}
@@ -1179,7 +1179,7 @@ public class PublicCompany extends Company implements CashOwner {
* @return The StockSpace object that defines the current location on the
* stock market.
*/
- public StockSpaceI getCurrentSpace() {
+ public StockSpace getCurrentSpace() {
return currentPrice != null ? currentPrice.getPrice() : null;
}
diff --git a/rails/game/Round.java b/rails/game/Round.java
index d7151f5..058fd7a 100644
--- a/rails/game/Round.java
+++ b/rails/game/Round.java
@@ -38,7 +38,7 @@ public abstract class Round extends GameItem implements RoundI {
protected Portfolio pool = null;
protected Portfolio unavailable = null;
protected Portfolio scrapHeap = null;
- protected StockMarketI stockMarket = null;
+ protected StockMarket stockMarket = null;
protected MapManager mapManager = null;
//protected Class<? extends RoundI> roundTypeForUI = null;
@@ -272,7 +272,7 @@ public abstract class Round extends GameItem implements RoundI {
Map<Integer, PublicCompany> operatingCompanies =
new TreeMap<Integer, PublicCompany>();
List<PublicCompany> newOperatingCompanies;
- StockSpaceI space;
+ StockSpace space;
int key;
int minorNo = 0;
boolean reorder = gameManager.isDynamicOperatingOrder()
diff --git a/rails/game/ShareSellingRound.java b/rails/game/ShareSellingRound.java
index c01459c..b9308f8 100644
--- a/rails/game/ShareSellingRound.java
+++ b/rails/game/ShareSellingRound.java
@@ -351,7 +351,7 @@ public class ShareSellingRound extends StockRound {
}
// All seems OK, now do the selling.
- StockSpaceI sellPrice;
+ StockSpace sellPrice;
int price;
// Get the sell price (does not change within a turn)
diff --git a/rails/game/StockMarket.java b/rails/game/StockMarket.java
index 6d2bdae..0adf178 100644
--- a/rails/game/StockMarket.java
+++ b/rails/game/StockMarket.java
@@ -1,7 +1,8 @@
-/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/StockMarket.java,v 1.27 2010/03/10 17:26:45 stefanfrey Exp $ */
package rails.game;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
import rails.common.LocalText;
import rails.common.parser.ConfigurableComponentI;
@@ -9,21 +10,28 @@ import rails.common.parser.ConfigurationException;
import rails.common.parser.Tag;
import rails.game.state.GameItem;
import rails.game.state.BooleanState;
-import rails.game.state.PriceTokenMove;
-public class StockMarket extends GameItem implements StockMarketI, ConfigurableComponentI {
+public class StockMarket extends GameItem implements ConfigurableComponentI {
- protected HashMap<String, StockSpaceTypeI> stockSpaceTypes =
- new HashMap<String, StockSpaceTypeI>();
- protected HashMap<String, StockSpaceI> stockChartSpaces =
- new HashMap<String, StockSpaceI>();
- protected StockSpaceI stockChart[][];
- protected StockSpaceI currentSquare;
+ /**
+ * This is the name by which the CompanyManager should be registered with
+ * the ComponentManager.
+ */
+ public static final String COMPONENT_NAME = "StockMarket";
+
+
+ protected HashMap<String, StockSpaceType> stockSpaceTypes =
+ new HashMap<String, StockSpaceType>();
+ protected HashMap<String, StockSpace> stockChartSpaces =
+ new HashMap<String, StockSpace>();
+
+ protected StockSpace stockChart[][];
+ protected StockSpace currentSquare;
protected int numRows = 0;
protected int numCols = 0;
- protected ArrayList<StockSpaceI> startSpaces = new ArrayList<StockSpaceI>();
+ protected ArrayList<StockSpace> startSpaces = new ArrayList<StockSpace>();
protected int[] startPrices;
- protected StockSpaceTypeI defaultType;
+ protected StockSpaceType defaultType;
GameManager gameManager;
@@ -55,19 +63,19 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
stockSpaceTypes.put (DEFAULT, defaultType);
/* Read and configure the stock market space types */
- List<Tag> typeTags = tag.getChildren(StockSpaceTypeI.ELEMENT_ID);
+ List<Tag> typeTags = tag.getChildren(StockSpaceType.ELEMENT_ID);
if (typeTags != null) {
for (Tag typeTag : typeTags) {
/* Extract the attributes of the Stock space type */
String name =
- typeTag.getAttributeAsString(StockSpaceTypeI.NAME_TAG);
+ typeTag.getAttributeAsString(StockSpaceType.NAME_TAG);
if (name == null) {
throw new ConfigurationException(
LocalText.getText("UnnamedStockSpaceType"));
}
String colour =
- typeTag.getAttributeAsString(StockSpaceTypeI.COLOUR_TAG);
+ typeTag.getAttributeAsString(StockSpaceType.COLOUR_TAG);
/* Check for duplicates */
if (stockSpaceTypes.get(name) != null) {
@@ -76,36 +84,36 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
}
/* Create the type */
- StockSpaceTypeI type = new StockSpaceType(name, colour);
+ StockSpaceType type = new StockSpaceType(name, colour);
stockSpaceTypes.put(name, type);
// Check the stock space type flags
- type.setNoBuyLimit(typeTag.getChild(StockSpaceTypeI.NO_BUY_LIMIT_TAG) != null);
- type.setNoCertLimit(typeTag.getChild(StockSpaceTypeI.NO_CERT_LIMIT_TAG) != null);
- type.setNoHoldLimit(typeTag.getChild(StockSpaceTypeI.NO_HOLD_LIMIT_TAG) != null);
+ type.setNoBuyLimit(typeTag.getChild(StockSpaceType.NO_BUY_LIMIT_TAG) != null);
+ type.setNoCertLimit(typeTag.getChild(StockSpaceType.NO_CERT_LIMIT_TAG) != null);
+ type.setNoHoldLimit(typeTag.getChild(StockSpaceType.NO_HOLD_LIMIT_TAG) != null);
}
}
/* Read and configure the stock market spaces */
- List<Tag> spaceTags = tag.getChildren(StockSpaceI.ELEMENT_ID);
- StockSpaceTypeI type;
+ List<Tag> spaceTags = tag.getChildren(StockSpace.ELEMENT_ID);
+ StockSpaceType type;
int row, col;
for (Tag spaceTag : spaceTags) {
type = null;
// Extract the attributes of the Stock space
- String name = spaceTag.getAttributeAsString(StockSpaceI.NAME_TAG);
+ String name = spaceTag.getAttributeAsString(StockSpace.NAME_TAG);
if (name == null) {
throw new ConfigurationException(
LocalText.getText("UnnamedStockSpace"));
}
- String price = spaceTag.getAttributeAsString(StockSpaceI.PRICE_TAG);
+ String price = spaceTag.getAttributeAsString(StockSpace.PRICE_TAG);
if (price == null) {
throw new ConfigurationException(LocalText.getText(
"StockSpaceHasNoPrice", name));
}
String typeName =
- spaceTag.getAttributeAsString(StockSpaceI.TYPE_TAG);
+ spaceTag.getAttributeAsString(StockSpace.TYPE_TAG);
if (typeName != null
&& (type = stockSpaceTypes.get(typeName)) == null) {
throw new ConfigurationException(LocalText.getText(
@@ -115,11 +123,10 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
if (stockChartSpaces.get(name) != null) {
throw new ConfigurationException(LocalText.getText(
- "StockSpaceIsConfiguredTwice", name));
+ "StockSpacesConfiguredTwice", name));
}
- StockSpaceI space =
- new StockSpace(this, name, Integer.parseInt(price), type);
+ StockSpace space = StockSpace.create(this, name, Integer.parseInt(price), type);
stockChartSpaces.put(name, space);
row = Integer.parseInt(name.substring(1));
@@ -128,14 +135,14 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
if (col > numCols) numCols = col;
// Loop through the stock space flags
- if (spaceTag.getChild(StockSpaceI.START_SPACE_TAG) != null) {
+ if (spaceTag.getChild(StockSpace.START_SPACE_TAG) != null) {
space.setStart(true);
startSpaces.add(space);
}
- space.setClosesCompany(spaceTag.getChild(StockSpaceI.CLOSES_COMPANY_TAG) != null);
- space.setEndsGame(spaceTag.getChild(StockSpaceI.GAME_OVER_TAG) != null);
- space.setBelowLedge(spaceTag.getChild(StockSpaceI.BELOW_LEDGE_TAG) != null);
- space.setLeftOfLedge(spaceTag.getChild(StockSpaceI.LEFT_OF_LEDGE_TAG) != null);
+ space.setClosesCompany(spaceTag.getChild(StockSpace.CLOSES_COMPANY_TAG) != null);
+ space.setEndsGame(spaceTag.getChild(StockSpace.GAME_OVER_TAG) != null);
+ space.setBelowLedge(spaceTag.getChild(StockSpace.BELOW_LEDGE_TAG) != null);
+ space.setLeftOfLedge(spaceTag.getChild(StockSpace.LEFT_OF_LEDGE_TAG) != null);
}
@@ -144,8 +151,8 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
startPrices[i] = (startSpaces.get(i)).getPrice();
}
- stockChart = new StockSpaceI[numRows][numCols];
- for (StockSpaceI space : stockChartSpaces.values()) {
+ stockChart = new StockSpace[numRows][numCols];
+ for (StockSpace space : stockChartSpaces.values()) {
stockChart[space.getRow()][space.getColumn()] = space;
}
@@ -172,11 +179,11 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
/**
* @return
*/
- public StockSpaceI[][] getStockChart() {
+ public StockSpace[][] getStockChart() {
return stockChart;
}
- public StockSpaceI getStockSpace(int row, int col) {
+ public StockSpace getStockSpace(int row, int col) {
if (row >= 0 && row < numRows && col >= 0 && col < numCols) {
return stockChart[row][col];
} else {
@@ -190,7 +197,7 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
/*--- Actions ---*/
- public void start(PublicCompany company, StockSpaceI price) {
+ public void start(PublicCompany company, StockSpace price) {
prepareMove(company, null, price);
}
@@ -211,8 +218,8 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
}
public void moveUp(PublicCompany company) {
- StockSpaceI oldsquare = company.getCurrentSpace();
- StockSpaceI newsquare = oldsquare;
+ StockSpace oldsquare = company.getCurrentSpace();
+ StockSpace newsquare = oldsquare;
int row = oldsquare.getRow();
int col = oldsquare.getColumn();
if (row > 0) {
@@ -228,8 +235,8 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
}
protected void moveDown(PublicCompany company, int numberOfSpaces) {
- StockSpaceI oldsquare = company.getCurrentSpace();
- StockSpaceI newsquare = oldsquare;
+ StockSpace oldsquare = company.getCurrentSpace();
+ StockSpace newsquare = oldsquare;
int row = oldsquare.getRow();
int col = oldsquare.getColumn();
@@ -261,8 +268,8 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
protected void moveRightOrUp(PublicCompany company) {
/* Ignore the amount for now */
- StockSpaceI oldsquare = company.getCurrentSpace();
- StockSpaceI newsquare = oldsquare;
+ StockSpace oldsquare = company.getCurrentSpace();
+ StockSpace newsquare = oldsquare;
int row = oldsquare.getRow();
int col = oldsquare.getColumn();
if (col < numCols - 1 && !oldsquare.isLeftOfLedge()
@@ -273,8 +280,8 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
}
protected void moveLeftOrDown(PublicCompany company) {
- StockSpaceI oldsquare = company.getCurrentSpace();
- StockSpaceI newsquare = oldsquare;
+ StockSpace oldsquare = company.getCurrentSpace();
+ StockSpace newsquare = oldsquare;
int row = oldsquare.getRow();
int col = oldsquare.getColumn();
if (col > 0 && (newsquare = getStockSpace(row, col - 1)) != null) {}
@@ -286,8 +293,8 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
prepareMove(company, oldsquare, newsquare);
}
- protected void prepareMove(PublicCompany company, StockSpaceI from,
- StockSpaceI to) {
+ protected void prepareMove(PublicCompany company, StockSpace from,
+ StockSpace to) {
// To be written to a log file in the future.
if (from != null && from == to) {
ReportBuffer.add(LocalText.getText("PRICE_STAYS_LOG",
@@ -313,27 +320,31 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
}
company.setCurrentSpace(to);
- new PriceTokenMove(company, from, to, this);
- }
-
- public void processMove(PublicCompany company, StockSpaceI from,
- StockSpaceI to) {
- if (from != null) from.removeToken(company);
- if (to != null) to.addToken(company);
- company.updatePlayersWorth();
- }
-
- public void processMoveToStackPosition(PublicCompany company, StockSpaceI from,
- StockSpaceI to, int toStackPosition) {
- if (from != null) from.removeToken(company);
- if (to != null) to.addTokenAtStackPosition(company, toStackPosition);
- company.updatePlayersWorth();
+
+ // the following 2 commands replaced: new PriceTokenMove(company, from, to, this);
+ to.addToken(company);
+ from.removeToken(company);
}
+
+ // TODO: Check what states effect players worth and link those
+// public void processMove(PublicCompany company, StockSpace from,
+// StockSpace to) {
+// if (from != null) from.removeToken(company);
+// if (to != null) to.addToken(company);
+// company.updatePlayersWorth();
+// }
+//
+// public void processMoveToStackPosition(PublicCompany company, StockSpace from,
+// StockSpace to, int toStackPosition) {
+// if (from != null) from.removeToken(company);
+// if (to != null) to.addTokenAtStackPosition(company, toStackPosition);
+// company.updatePlayersWorth();
+// }
/**
* @return
*/
- public List<StockSpaceI> getStartSpaces() {
+ public List<StockSpace> getStartSpaces() {
return startSpaces;
}
@@ -346,8 +357,8 @@ public class StockMarket extends GameItem implements StockMarketI, ConfigurableC
return startPrices;
}
- public StockSpaceI getStartSpace(int price) {
- for (StockSpaceI square : startSpaces) {
+ public StockSpace getStartSpace(int price) {
+ for (StockSpace square : startSpaces) {
if (square.getPrice() == price) return square;
}
return null;
diff --git a/rails/game/StockMarketI.java b/rails/game/StockMarketI.java
deleted file mode 100644
index 2596225..0000000
--- a/rails/game/StockMarketI.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/StockMarketI.java,v 1.10 2010/03/10 17:26:49 stefanfrey Exp $ */
-package rails.game;
-
-import java.util.List;
-
-import rails.common.parser.ConfigurableComponentI;
-
-public interface StockMarketI extends ConfigurableComponentI {
-
- /**
- * This is the name by which the CompanyManager should be registered with
- * the ComponentManager.
- */
- static final String COMPONENT_NAME = "StockMarket";
-
- public StockSpaceI[][] getStockChart();
-
- public StockSpaceI getStockSpace(int row, int col);
-
- public StockSpaceI getStockSpace(String name);
-
- public void start(PublicCompany company, StockSpaceI price);
-
- public void payOut(PublicCompany company);
-
- public void withhold(PublicCompany company);
-
- public void sell(PublicCompany company, int numberOfShares);
-
- public void soldOut(PublicCompany company);
-
- public void moveUp(PublicCompany company);
-
- public void close (PublicCompany company);
-
- public int getNumberOfColumns();
-
- public int getNumberOfRows();
-
- public List<StockSpaceI> getStartSpaces();
-
- public int[] getStartPrices();
-
- public StockSpaceI getStartSpace(int price);
-
- public void processMove(PublicCompany company, StockSpaceI from,
- StockSpaceI to);
-
- public void processMoveToStackPosition(PublicCompany company, StockSpaceI from,
- StockSpaceI to, int toStackPosition);
-}
diff --git a/rails/game/StockRound.java b/rails/game/StockRound.java
index 647b101..3940ea9 100644
--- a/rails/game/StockRound.java
+++ b/rails/game/StockRound.java
@@ -39,8 +39,8 @@ public class StockRound extends Round {
protected IntegerState numPasses = IntegerState.create(this, "StockRoundPasses");
- protected Map<PublicCompany, StockSpaceI> sellPrices =
- new HashMap<PublicCompany, StockSpaceI>();
+ protected Map<PublicCompany, StockSpace> sellPrices =
+ new HashMap<PublicCompany, StockSpace>();
/** Records lifted share selling obligations in the current round<p>
* Example: >60% ownership allowed after a merger in 18EU.
@@ -166,7 +166,7 @@ public class StockRound extends Round {
List<PublicCertificate> certs;
PublicCertificate cert;
PublicCompany comp;
- StockSpaceI stockSpace;
+ StockSpace stockSpace;
Portfolio from;
int price;
int number;
@@ -544,7 +544,7 @@ public class StockRound extends Round {
int shares = action.getNumberBought();
String errMsg = null;
- StockSpaceI startSpace = null;
+ StockSpace startSpace = null;
int numberOfCertsToBuy = 0;
PublicCertificate cert = null;
String companyName = company.getId();
@@ -748,7 +748,7 @@ public class StockRound extends Round {
break;
}
- StockSpaceI currentSpace;
+ StockSpace currentSpace;
if (from == ipo && company.hasParPrice()) {
currentSpace = company.getStartSpace();
} else {
@@ -873,7 +873,7 @@ public class StockRound extends Round {
}
/** Allow different price setting in subclasses (i.e. 1835 Nationalisation) */
- protected int getBuyPrice (BuyCertificate action, StockSpaceI currentSpace) {
+ protected int getBuyPrice (BuyCertificate action, StockSpace currentSpace) {
return currentSpace.getPrice();
}
@@ -1163,7 +1163,7 @@ public class StockRound extends Round {
stockMarket.sell(company, numberSold);
- StockSpaceI newSpace = company.getCurrentSpace();
+ StockSpace newSpace = company.getCurrentSpace();
if (newSpace.closesCompany() && company.canClose()) {
company.setClosed();
@@ -1322,9 +1322,9 @@ public class StockRound extends Round {
/* Check if any companies are sold out. */
for (PublicCompany company : gameManager.getCompaniesInRunningOrder()) {
if (company.hasStockPrice() && company.isSoldOut()) {
- StockSpaceI oldSpace = company.getCurrentSpace();
+ StockSpace oldSpace = company.getCurrentSpace();
stockMarket.soldOut(company);
- StockSpaceI newSpace = company.getCurrentSpace();
+ StockSpace newSpace = company.getCurrentSpace();
if (newSpace != oldSpace) {
ReportBuffer.add(LocalText.getText("SoldOut",
company.getId(),
diff --git a/rails/game/StockSpace.java b/rails/game/StockSpace.java
index 5583a02..03afbec 100644
--- a/rails/game/StockSpace.java
+++ b/rails/game/StockSpace.java
@@ -1,20 +1,54 @@
package rails.game;
import java.awt.Color;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.log4j.Logger;
+import com.google.common.c...
[truncated message content] |