|
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.collect.ImmutableList;
+
import rails.game.model.Model;
-import rails.game.state.GameItem;
+import rails.game.state.ArrayListState;
+import rails.game.state.Item;
/**
* Objects of this class represent a square on the StockMarket.
*/
-public class StockSpace extends Model implements StockSpaceI {
+public class StockSpace extends Model {
/*--- Class attributes ---*/
+ /*--- Constants ---*/
+ /** The name of the XML tag used to configure a stock space. */
+ public static final String ELEMENT_ID = "StockSpace";
+
+ /**
+ * The name of the XML attribute for the stock price's name (like "A1" -
+ * naming is like spreadsheet cells.
+ */
+ public static final String NAME_TAG = "name";
+
+ /** The name of the XML attribute for the stock price. */
+ public static final String PRICE_TAG = "price";
+
+ /** The name of the XML attribute for the stock price type (optional). */
+ public static final String TYPE_TAG = "type";
+
+ /**
+ * The name of the XML tag for the "startSpace" property. (indicating an
+ * allowed PAR price)
+ */
+ public static final String START_SPACE_TAG = "StartSpace";
+
+ /** The name of the XML tag for the "below ledge" property. */
+ public static final String BELOW_LEDGE_TAG = "BelowLedge";
+
+ /** The name of the XML tag for the "left of ledge" property. */
+ public static final String LEFT_OF_LEDGE_TAG = "LeftOfLedge";
+
+ /** The name of the XML tag for the "closes company" property. */
+ public static final String CLOSES_COMPANY_TAG = "ClosesCompany";
+
+ /** The name of the XML tag for the "gamn over" property. */
+ public static final String GAME_OVER_TAG = "GameOver";
/*--- Instance attributes ---*/
protected String name;
@@ -27,27 +61,46 @@ public class StockSpace extends Model implements StockSpaceI {
protected boolean closesCompany = false;// For 1856 and other games
protected boolean endsGame = false; // For 1841 and other games
protected boolean start = false; // Company may start here
- protected StockSpaceTypeI type = null;
- protected ArrayList<PublicCompany> tokens =
- new ArrayList<PublicCompany>();
- protected ArrayList<PublicCompany> fixedStartPrices =
- new ArrayList<PublicCompany>();
+ protected StockSpaceType type = null;
+
+
+ /*--- State fields */
+ protected final ArrayListState<PublicCompany> tokens = ArrayListState.create("tokens");
+ protected final ArrayListState<PublicCompany> fixedStartPrices = ArrayListState.create("fixedStartPrices");
protected static Logger log =
Logger.getLogger(StockSpace.class.getPackage().getName());
/*--- Contructors ---*/
- public StockSpace(GameItem owner, String name, int price, StockSpaceTypeI type) {
- super(owner, name);
- this.name = name;
+ private StockSpace(String id, int price, StockSpaceType type) {
+ super(id);
+ this.name = id;
this.price = price;
this.type = type;
- this.row = Integer.parseInt(name.substring(1)) - 1;
- this.column = (name.toUpperCase().charAt(0) - '@') - 1;
+ this.row = Integer.parseInt(id.substring(1)) - 1;
+ this.column = (id.toUpperCase().charAt(0) - '@') - 1;
}
- public StockSpace(GameItem owner, String name, int price) {
- this(owner, name, price, null);
+ /**
+ * Factory method for initialized StockSpace
+ */
+ public static StockSpace create(Item parent, String id, int price, StockSpaceType type) {
+ return new StockSpace(id, price, type).init(parent);
+ }
+
+ /**
+ * Factory method for initialized StockSpace with default StockSpaceType
+ */
+ public static StockSpace create (Item parent, String id, int price) {
+ return create(parent, id, price, null);
+ }
+
+ @Override
+ public StockSpace init(Item parent){
+ super.init(parent);
+ tokens.init(this);
+ fixedStartPrices.init(this);
+ return this;
}
@@ -64,16 +117,12 @@ public class StockSpace extends Model implements StockSpaceI {
public boolean addToken(PublicCompany company) {
log.debug(company.getId() + " price token added to " + name);
tokens.add(company);
- // TODO: is this still required?
- update();
return true;
}
public boolean addTokenAtStackPosition(PublicCompany company, int stackPosition) {
log.debug(company.getId() + " price token added to " + name + " at stack position "+stackPosition);
tokens.add(stackPosition, company);
- // TODO: is this still required?
- update();
return true;
}
@@ -85,22 +134,11 @@ public class StockSpace extends Model implements StockSpaceI {
*/
public boolean removeToken(PublicCompany company) {
log.debug(company.getId() + " price token removed from " + name);
- int index = tokens.indexOf(company);
- if (index >= 0) {
- tokens.remove(index);
- // TODO: is this still required?
- update();
- return true;
- } else {
- return false;
- }
+ return tokens.remove(company);
}
- /**
- * @return
- */
- public List<PublicCompany> getTokens() {
- return tokens;
+ public ImmutableList<PublicCompany> getTokens() {
+ return tokens.view();
}
/**
@@ -118,8 +156,8 @@ public class StockSpace extends Model implements StockSpaceI {
fixedStartPrices.add(company);
}
- public List<PublicCompany> getFixedStartPrices() {
- return fixedStartPrices;
+ public ImmutableList<PublicCompany> getFixedStartPrices() {
+ return fixedStartPrices.view();
}
/*--- Getters ---*/
@@ -179,7 +217,7 @@ public class StockSpace extends Model implements StockSpaceI {
/**
* @return
*/
- public StockSpaceTypeI getType() {
+ public StockSpaceType getType() {
return type;
}
diff --git a/rails/game/StockSpaceI.java b/rails/game/StockSpaceI.java
deleted file mode 100644
index c6dfbdd..0000000
--- a/rails/game/StockSpaceI.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/StockSpaceI.java,v 1.6 2010/03/10 17:26:49 stefanfrey Exp $ */
-package rails.game;
-
-import java.awt.Color;
-import java.util.*;
-
-import rails.game.model.Model;
-
-public interface StockSpaceI extends Model<String> // extends HolderModel<Token>I
-{
-
- /*--- Constants ---*/
- /** The name of the XML tag used to configure a stock space. */
- public static final String ELEMENT_ID = "StockSpace";
-
- /**
- * The name of the XML attribute for the stock price's name (like "A1" -
- * naming is like spreadsheet cells.
- */
- public static final String NAME_TAG = "name";
-
- /** The name of the XML attribute for the stock price. */
- public static final String PRICE_TAG = "price";
-
- /** The name of the XML attribute for the stock price type (optional). */
- public static final String TYPE_TAG = "type";
-
- /**
- * The name of the XML tag for the "startSpace" property. (indicating an
- * allowed PAR price)
- */
- public static final String START_SPACE_TAG = "StartSpace";
-
- /** The name of the XML tag for the "below ledge" property. */
- public static final String BELOW_LEDGE_TAG = "BelowLedge";
-
- /** The name of the XML tag for the "left of ledge" property. */
- public static final String LEFT_OF_LEDGE_TAG = "LeftOfLedge";
-
- /** The name of the XML tag for the "closes company" property. */
- public static final String CLOSES_COMPANY_TAG = "ClosesCompany";
-
- /** The name of the XML tag for the "gamn over" property. */
- public static final String GAME_OVER_TAG = "GameOver";
-
- // No constructors (yet) for the booleans, which are rarely needed. Use the
- // setters.
- public abstract boolean isBelowLedge();
-
- /**
- * @return TRUE if the square closes companies landing on it.
- */
- public abstract boolean closesCompany();
-
- /**
- * @return The square's colour.
- */
- public abstract Color getColour();
-
- /**
- * @return TRUE if the rails.game ends if a company lands on this square.
- */
- public abstract boolean endsGame();
-
- /**
- * @return The stock price associated with the square.
- */
- public abstract int getPrice();
-
- /**
- * @return
- */
- public abstract int getColumn();
-
- /**
- * @return
- */
- public abstract String getName();
-
- /**
- * @return
- */
- public abstract int getRow();
-
- /**
- * @return
- */
- public abstract StockSpaceTypeI getType();
-
- /**
- * @param b
- */
- public abstract boolean isStart();
-
- /*--- Setters ---*/
- public abstract void setBelowLedge(boolean b);
-
- /**
- * @param b See isClosesCompany.
- */
- public abstract void setClosesCompany(boolean b);
-
- /**
- * @param b See isEndsGame.
- */
- public abstract void setEndsGame(boolean b);
-
- /**
- * @return
- */
- public abstract void setStart(boolean b);
-
- /**
- * Find the stack position of a company token
- *
- * @return Stock position: 0 = top, increasing towards the bottom. -1 if not
- * found.
- */
- public int getStackPosition(PublicCompany company);
-
- public void addFixedStartPrice(PublicCompany company);
-
- public List<PublicCompany> getFixedStartPrices();
-
- /**
- * @return
- */
- public abstract boolean isLeftOfLedge();
-
- /**
- * @param b
- */
- public abstract void setLeftOfLedge(boolean b);
-
- /**
- * @return
- */
- public boolean isNoBuyLimit();
-
- /**
- * @return
- */
- public boolean isNoCertLimit();
-
- /**
- * @return
- */
- public boolean isNoHoldLimit();
-
- public boolean addToken(PublicCompany company);
-
- public boolean addTokenAtStackPosition(PublicCompany company, int stackPosition);
-
- public boolean removeToken(PublicCompany company);
-
- public boolean hasTokens();
-
- public List<PublicCompany> getTokens();
-
-}
diff --git a/rails/game/StockSpaceType.java b/rails/game/StockSpaceType.java
index 6e5295f..a0accd9 100644
--- a/rails/game/StockSpaceType.java
+++ b/rails/game/StockSpaceType.java
@@ -1,4 +1,3 @@
-/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/StockSpaceType.java,v 1.4 2009/12/13 16:39:49 evos Exp $ */
package rails.game;
import java.awt.Color;
@@ -11,9 +10,43 @@ import rails.util.Util;
* special properties,usually represented by a non-white square colour. The
* default type is "white", which has no special properties.
*/
-public class StockSpaceType implements StockSpaceTypeI {
+public class StockSpaceType {
/*--- Class attributes ---*/
+ /*--- Constants ---*/
+ /** The name of the XML tag used to configure a stock space. */
+ public static final String ELEMENT_ID = "StockSpaceType";
+
+ /**
+ * The name of the XML attribute for the stock price type's name (any
+ * string, usually the space colour).
+ */
+ public static final String NAME_TAG = "name";
+
+ /**
+ * The name of the XML attribute for the stock price's colour. (optional;
+ * only provided as a possible help to the UI, which is free to redefine the
+ * colour as it seems fit).
+ */
+ public static final String COLOUR_TAG = "colour";
+
+ /**
+ * The name of the XML tag for the "NoCertLimit" property. (1830: yellow
+ * stock market area)
+ */
+ public static final String NO_CERT_LIMIT_TAG = "NoCertLimit";
+
+ /**
+ * The name of the XML tag for the "NoHoldLimit" property. (1830: orange
+ * area)
+ */
+ public static final String NO_HOLD_LIMIT_TAG = "NoHoldLimit";
+
+ /**
+ * The name of the XML tag for the "NoBuyLimit" property. (1830: brown area)
+ */
+ public static final String NO_BUY_LIMIT_TAG = "NoBuyLimit";
+
/*--- Instance attributes ---*/
protected String name;
diff --git a/rails/game/StockSpaceTypeI.java b/rails/game/StockSpaceTypeI.java
deleted file mode 100644
index ca896f7..0000000
--- a/rails/game/StockSpaceTypeI.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/StockSpaceTypeI.java,v 1.4 2009/12/13 16:39:48 evos Exp $ */
-package rails.game;
-
-import java.awt.Color;
-
-/**
- * The interface for StockSpaceType.
- */
-public interface StockSpaceTypeI {
-
- /*--- Constants ---*/
- /** The name of the XML tag used to configure a stock space. */
- public static final String ELEMENT_ID = "StockSpaceType";
-
- /**
- * The name of the XML attribute for the stock price type's name (any
- * string, usually the space colour).
- */
- public static final String NAME_TAG = "name";
-
- /**
- * The name of the XML attribute for the stock price's colour. (optional;
- * only provided as a possible help to the UI, which is free to redefine the
- * colour as it seems fit).
- */
- public static final String COLOUR_TAG = "colour";
-
- /**
- * The name of the XML tag for the "NoCertLimit" property. (1830: yellow
- * stock market area)
- */
- public static final String NO_CERT_LIMIT_TAG = "NoCertLimit";
-
- /**
- * The name of the XML tag for the "NoHoldLimit" property. (1830: orange
- * area)
- */
- public static final String NO_HOLD_LIMIT_TAG = "NoHoldLimit";
-
- /**
- * The name of the XML tag for the "NoBuyLimit" property. (1830: brown area)
- */
- public static final String NO_BUY_LIMIT_TAG = "NoBuyLimit";
-
- /**
- * @return Color
- */
- public abstract Color getColour();
-
- /**
- * @return Name
- */
- public abstract String getName();
-
- /**
- * @return if space triggers No Purchase Limit for stock
- */
- public boolean isNoBuyLimit();
-
- /**
- * @return if space triggers Stock not counting toward certificate ownership
- * limit
- */
- public boolean isNoCertLimit();
-
- /**
- * @return if space triggers Stock not counting toward certificate limit
- */
- public boolean isNoHoldLimit();
-
- /**
- * @param b
- */
- public void setNoBuyLimit(boolean b);
-
- /**
- * @param b
- */
- public void setNoCertLimit(boolean b);
-
- /**
- * @param b
- */
- public void setNoHoldLimit(boolean b);
-
-}
diff --git a/rails/game/TreasuryShareRound.java b/rails/game/TreasuryShareRound.java
index b74ac95..73a5f13 100644
--- a/rails/game/TreasuryShareRound.java
+++ b/rails/game/TreasuryShareRound.java
@@ -474,7 +474,7 @@ public class TreasuryShareRound 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/model/PriceModel.java b/rails/game/model/PriceModel.java
index 3af0a20..ea74079 100644
--- a/rails/game/model/PriceModel.java
+++ b/rails/game/model/PriceModel.java
@@ -2,18 +2,19 @@ package rails.game.model;
import rails.game.Bank;
import rails.game.PublicCompany;
-import rails.game.StockSpaceI;
+import rails.game.StockSpace;
+import rails.game.state.GenericState;
import rails.game.state.Item;
-import rails.game.state.PriceMove;
-
-// TODO: Requires a complete rewrite
public class PriceModel extends Model {
- private StockSpaceI stockPrice = null;
+ // fields
private PublicCompany company = null;
- private String name = null;
+ // states
+ private final GenericState<StockSpace> stockPrice = GenericState.create("stockPrice");
+
+
private PriceModel(String id) {
super(id);
}
@@ -36,17 +37,16 @@ public class PriceModel extends Model {
} else {
throw new IllegalArgumentException("PriceModel init() only works for PublicCompanies");
}
+ stockPrice.init(this);
return this;
}
-
- // TODO: This has to be changed
- public void setPrice(StockSpaceI price) {
- new PriceMove(this, stockPrice, price);
+ public void setPrice(StockSpace price) {
+ stockPrice.set(price);
}
- public StockSpaceI getPrice() {
- return stockPrice;
+ public StockSpace getPrice() {
+ return stockPrice.get();
}
public PublicCompany getCompany() {
@@ -54,45 +54,23 @@ public class PriceModel extends Model {
}
// FIXME: This is a reference to the usage of ViewUpdate
- public Object getUpdate() {
- if (stockPrice != null) {
- return new ViewUpdate(getText())
- .addObject(ViewUpdate.BGCOLOUR, stockPrice.getColour());
- } else {
- return getText();
- }
- }
+ // TODO: The color reference has to be taken care of, remove view update
+// public Object getUpdate() {
+// if (stockPrice != null) {
+// return new ViewUpdate(getText())
+// .addObject(ViewUpdate.BGCOLOUR, stockPrice.getColour());
+// } else {
+// return getText();
+// }
+// }
@Override
public String toString() {
if (stockPrice != null) {
- return Bank.format(stockPrice.getPrice()) + " ("
- + stockPrice.getName() + ")";
+ return Bank.format(stockPrice.get().getPrice()) + " ("
+ + stockPrice.get().getName() + ")";
}
return "";
}
- // StateI required methods
- public Object get() {
- return stockPrice;
- }
-
- public void setState(Object object) {
- if (object == null) {
- stockPrice = null;
- update();
- } else if (object instanceof StockSpaceI) {
- stockPrice = (StockSpaceI) object;
- update();
- } else {
- new Exception("Incompatible object type "
- + object.getClass().getName()
- + "passed to PriceModel " + name).printStackTrace();
- }
- }
-
- public String getName() {
- return name;
- }
-
}
diff --git a/rails/game/model/ViewUpdate.java b/rails/game/model/ViewUpdate.java
index a6ec674..5a5e068 100644
--- a/rails/game/model/ViewUpdate.java
+++ b/rails/game/model/ViewUpdate.java
@@ -9,6 +9,8 @@ import java.util.*;
* <p> The current version has text, background colour and foreground colour.
* Receiving view objects must be prepared to handle extensions.
* @author VosE
+ *
+ * TODO: Replace all previous use cases for this class
*
*/
@Deprecated
diff --git a/rails/game/specific/_1825/PublicCompany_1825.java b/rails/game/specific/_1825/PublicCompany_1825.java
index a0187c9..260e8cb 100644
--- a/rails/game/specific/_1825/PublicCompany_1825.java
+++ b/rails/game/specific/_1825/PublicCompany_1825.java
@@ -1,14 +1,14 @@
package rails.game.specific._1825;
import rails.game.PublicCompany;
-import rails.game.StockSpaceI;
+import rails.game.StockSpace;
import rails.game.state.IntegerState;
public class PublicCompany_1825 extends PublicCompany {
protected IntegerState formationOrderIndex;
- public void start(StockSpaceI startSpace) {
+ public void start(StockSpace startSpace) {
super.start(startSpace);
//PD: used to track flotation order
formationOrderIndex = IntegerState.create(this, name+"_formationOrderIndex");
diff --git a/rails/game/specific/_1835/StockRound_1835.java b/rails/game/specific/_1835/StockRound_1835.java
index fd117f5..3383520 100644
--- a/rails/game/specific/_1835/StockRound_1835.java
+++ b/rails/game/specific/_1835/StockRound_1835.java
@@ -47,7 +47,7 @@ public class StockRound_1835 extends StockRound {
for (PublicCertificate cert : company.getCertificates()) {
owner = cert.getHolder().getOwner();
/* Would the player exceed the total certificate limit? */
- StockSpaceI stockSpace = company.getCurrentSpace();
+ StockSpace stockSpace = company.getCurrentSpace();
if ((stockSpace == null || !stockSpace.isNoCertLimit()) && !mayPlayerBuyCertificate(
currentPlayer, company, cert.getCertificateCount())) continue;
// only nationalize other players
@@ -75,7 +75,7 @@ public class StockRound_1835 extends StockRound {
}
@Override
- protected int getBuyPrice (BuyCertificate action, StockSpaceI currentSpace) {
+ protected int getBuyPrice (BuyCertificate action, StockSpace currentSpace) {
int price = currentSpace.getPrice();
if (action.getFromPortfolio().getOwner() instanceof Player) {
price *= 1.5;
diff --git a/rails/game/specific/_1856/CGRFormationRound.java b/rails/game/specific/_1856/CGRFormationRound.java
index d79e51d..173ddf9 100644
--- a/rails/game/specific/_1856/CGRFormationRound.java
+++ b/rails/game/specific/_1856/CGRFormationRound.java
@@ -484,7 +484,7 @@ public class CGRFormationRound extends SwitchableUIRound {
} else {
int prevColPrice = 100;
int colPrice;
- StockSpaceI startSpace;
+ StockSpace startSpace;
for (int col=6; col <= stockMarket.getNumberOfColumns(); col++) {
colPrice = stockMarket.getStockSpace(1, col).getPrice();
if (cgrPrice > colPrice) continue;
diff --git a/rails/game/specific/_1856/PublicCompany_1856.java b/rails/game/specific/_1856/PublicCompany_1856.java
index 92220bc..70044b3 100644
--- a/rails/game/specific/_1856/PublicCompany_1856.java
+++ b/rails/game/specific/_1856/PublicCompany_1856.java
@@ -13,7 +13,7 @@ public class PublicCompany_1856 extends PublicCompany {
private boolean hadPermanentTrain = false;
@Override
- public void start(StockSpaceI startSpace) {
+ public void start(StockSpace startSpace) {
super.start(startSpace);
diff --git a/rails/game/specific/_18EU/StockRound_18EU.java b/rails/game/specific/_18EU/StockRound_18EU.java
index 09cd691..47debdc 100644
--- a/rails/game/specific/_18EU/StockRound_18EU.java
+++ b/rails/game/specific/_18EU/StockRound_18EU.java
@@ -73,7 +73,7 @@ public class StockRound_18EU extends StockRound {
List<PublicCertificate> certs;
PublicCertificate cert;
PublicCompany comp;
- StockSpaceI stockSpace;
+ StockSpace stockSpace;
Portfolio from;
int price;
@@ -282,7 +282,7 @@ public class StockRound_18EU extends StockRound {
int shares = action.getNumberBought();
String errMsg = null;
- StockSpaceI startSpace = null;
+ StockSpace startSpace = null;
int numberOfCertsToBuy = 0;
PublicCertificate cert = null;
String companyName = company.getId();
diff --git a/rails/game/state/PriceMove.java b/rails/game/state/PriceMove.java
deleted file mode 100644
index dfc26ee..0000000
--- a/rails/game/state/PriceMove.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/move/PriceMove.java,v 1.5 2008/06/04 19:00:33 evos Exp $
- *
- * Created on 18-Jul-2006
- * Change Log:
- */
-package rails.game.state;
-
-import rails.game.StockSpaceI;
-import rails.game.model.PriceModel;
-
-/**
- * @author Erik Vos
- */
-@Deprecated
-//FIXME: Rewrite this mechanism
-public class PriceMove {
-
- protected StockSpaceI from, to;
- protected PriceModel price;
-
- public PriceMove(PriceModel price, StockSpaceI from, StockSpaceI to) {
- this.from = from;
- this.to = to;
- this.price = price;
-// MoveSet.add(this);
- }
-
- public boolean execute() {
- price.setState(to);
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see rails.rails.game.action.Move#undo()
- */
- public boolean undo() {
- price.setState(from);
- return true;
- }
-
- public Object getObject() {
- return price;
- }
-
- public String toString() {
- return "PriceMove: " + price.getName() + " from " + from + " to " + to;
- }
-
-}
diff --git a/rails/game/state/PriceTokenMove.java b/rails/game/state/PriceTokenMove.java
deleted file mode 100644
index 21b0f9c..0000000
--- a/rails/game/state/PriceTokenMove.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/game/move/PriceTokenMove.java,v 1.7 2010/03/10 17:26:49 stefanfrey Exp $
- *
- * Created on 22-Jul-2006
- * Change Log:
- */
-package rails.game.state;
-
-import rails.game.*;
-
-/**
- * @author Erik Vos
- */
-@Deprecated
-//FIXME: Rewrite this mechanism
-public class PriceTokenMove {
-
- private PublicCompany company;
- private StockSpaceI from, to;
- private int fromStackPosition;
- private StockMarketI stockMarket = null;
-
- public PriceTokenMove(PublicCompany company, StockSpaceI from,
- StockSpaceI to, StockMarketI stockMarket) {
- this.company = company;
- this.from = from;
- this.to = to;
- if (from != null)
- fromStackPosition = from.getStackPosition(company);
- else
- fromStackPosition = 0;
- this.stockMarket = stockMarket;
-
-// MoveSet.add(this);
- }
-
- public boolean execute() {
- stockMarket.processMove(company, from, to);
- return true;
- }
-
- public boolean undo() {
- stockMarket.processMoveToStackPosition(company, to, from, fromStackPosition);
- return true;
- }
-
- @Override
- public String toString() {
- return "PriceTokenMove: " + company.getId() + " from " + from + " (at stack "
- + fromStackPosition + ") to " + to;
- }
-
-}
diff --git a/rails/ui/swing/StartRoundWindow.java b/rails/ui/swing/StartRoundWindow.java
index 6389f79..888a269 100644
--- a/rails/ui/swing/StartRoundWindow.java
+++ b/rails/ui/swing/StartRoundWindow.java
@@ -604,15 +604,15 @@ public class StartRoundWindow extends JFrame implements ActionListener,
if (activeItem.hasSharePriceToSet()) {
String compName = activeItem.getCompanyToSetPriceFor();
- StockMarketI stockMarket = gameUIManager.getGameManager().getStockMarket();
+ StockMarket stockMarket = gameUIManager.getGameManager().getStockMarket();
// Get a sorted prices List
// TODO: should be included in BuyStartItem
- List<StockSpaceI> startSpaces = stockMarket.getStartSpaces();
- Map<Integer, StockSpaceI> spacePerPrice =
- new HashMap<Integer, StockSpaceI>();
+ List<StockSpace> startSpaces = stockMarket.getStartSpaces();
+ Map<Integer, StockSpace> spacePerPrice =
+ new HashMap<Integer, StockSpace>();
int[] prices = new int[startSpaces.size()];
- StockSpaceI[] options = new StockSpaceI[startSpaces.size()];
+ StockSpace[] options = new StockSpace[startSpaces.size()];
for (int i = 0; i < startSpaces.size(); i++) {
prices[i] = startSpaces.get(i).getPrice();
spacePerPrice.put(prices[i], startSpaces.get(i));
diff --git a/rails/ui/swing/StockChart.java b/rails/ui/swing/StockChart.java
index 379fa03..a88dab1 100644
--- a/rails/ui/swing/StockChart.java
+++ b/rails/ui/swing/StockChart.java
@@ -6,7 +6,7 @@ import java.awt.event.*;
import javax.swing.*;
-import rails.game.StockSpaceI;
+import rails.game.StockSpace;
import rails.ui.swing.elements.GUIStockSpace;
/**
@@ -20,7 +20,7 @@ public class StockChart extends JFrame implements KeyListener {
private GridLayout stockGrid;
private GridBagConstraints gc;
- private StockSpaceI[][] market;
+ private StockSpace[][] market;
private GameUIManager gameUIManager;
public StockChart(GameUIManager gameUIManager) {
diff --git a/rails/ui/swing/elements/GUIStockSpace.java b/rails/ui/swing/elements/GUIStockSpace.java
index f880cb5..0608ec7 100644
--- a/rails/ui/swing/elements/GUIStockSpace.java
+++ b/rails/ui/swing/elements/GUIStockSpace.java
@@ -14,7 +14,7 @@ import javax.swing.SwingConstants;
import org.apache.log4j.Logger;
import rails.game.PublicCompany;
-import rails.game.StockSpaceI;
+import rails.game.StockSpace;
import rails.game.model.Model;
import rails.game.state.Observable;
import rails.game.state.Observer;
@@ -26,7 +26,7 @@ import rails.util.Util;
public class GUIStockSpace extends JLayeredPane implements Observer {
private static final long serialVersionUID = 1L;
- StockSpaceI model;
+ StockSpace model;
JLabel priceLabel;
int depth = 0;
@@ -43,7 +43,7 @@ public class GUIStockSpace extends JLayeredPane implements Observer {
protected static Logger log =
Logger.getLogger(GUIStockSpace.class.getPackage().getName());
- public GUIStockSpace(int x, int y, StockSpaceI model) {
+ public GUIStockSpace(int x, int y, StockSpace model) {
this.model = model;
diff --git a/test/GameTestServlet.java b/test/GameTestServlet.java
index 29dd5a9..3c3deaf 100644
--- a/test/GameTestServlet.java
+++ b/test/GameTestServlet.java
@@ -33,7 +33,7 @@
*
* private static final String servletName = "test.GameTestServlet";
*
- * private StockMarketI stockMarket = null;
+ * private StockMarket stockMarket = null;
*
* private Game game = null;
*
@@ -91,7 +91,7 @@
* protected void doWork(HttpServletRequest request, HttpServletResponse
* response) throws ServletException, IOException {
*
- * int row, col; StockSpaceI square; Company comp; PublicCompany company;
+ * int row, col; StockSpace square; Company comp; PublicCompany company;
* String companyName; PublicCertificate cert; int companyNumber; Iterator
* iterator, iterator2; int i; List startSpaces; int price;
*
@@ -333,7 +333,7 @@
* out.append("<input type=hidden name=Company value=\"")
* .append(currCo.getName()).append("\">\n"); out.append("<select
* name=StartPrice>\n"); Iterator it = Game.getStockMarket()...
[truncated message content] |