|
From: Stefan F. <ste...@us...> - 2012-07-17 05:36:40
|
.project | 8
junit/rails/game/state/BooleanStateTest.java | 7
junit/rails/game/state/GenericStateTest.java | 33 -
junit/rails/game/state/IntegerStateTest.java | 85 +++
junit/rails/game/state/StateTest.java | 8
junit/rails/game/state/StringStateTest.java | 99 ++++
src/rails/common/GuiHints.java | 4
src/rails/game/GameManager.java | 14
src/rails/game/OperatingRound.java | 366 ++++++++---------
src/rails/game/PhaseManager.java | 2
src/rails/game/PublicCompany.java | 8
src/rails/game/StartRound_1830.java | 6
src/rails/game/StockRound.java | 14
src/rails/game/Stop.java | 8
src/rails/game/Train.java | 6
src/rails/game/model/PriceModel.java | 6
src/rails/game/special/SellBonusToken.java | 2
src/rails/game/specific/_1825/StockRound_1825.java | 2
src/rails/game/specific/_1835/OperatingRound_1835.java | 14
src/rails/game/specific/_1835/StockRound_1835.java | 2
src/rails/game/specific/_1856/OperatingRound_1856.java | 128 ++---
src/rails/game/specific/_1856/PublicCompany_CGR.java | 2
src/rails/game/specific/_1880/StartRound_1880.java | 10
src/rails/game/specific/_1889/OperatingRound_1889.java | 2
src/rails/game/specific/_18AL/NameableTrain.java | 2
src/rails/game/specific/_18AL/OperatingRound_18AL.java | 10
src/rails/game/specific/_18EU/GameManager_18EU.java | 6
src/rails/game/specific/_18EU/OperatingRound_18EU.java | 24 -
src/rails/game/specific/_18EU/StartRound_18EU.java | 16
src/rails/game/specific/_18EU/StockRound_18EU.java | 4
src/rails/game/specific/_18GA/OperatingRound_18GA.java | 2
src/rails/game/specific/_18TN/OperatingRound_18TN.java | 4
src/rails/game/state/GenericState.java | 3
src/rails/game/state/GenericStateChange.java | 2
src/rails/game/state/IntegerState.java | 2
src/rails/game/state/StringState.java | 12
36 files changed, 562 insertions(+), 361 deletions(-)
New commits:
commit bded8d45322af638b3c80f244070adc00a620b4e
Author: Stefan Frey <ste...@we...>
Date: Mon Jul 16 15:47:52 2012 +0200
added state_id for init test state
diff --git a/junit/rails/game/state/BooleanStateTest.java b/junit/rails/game/state/BooleanStateTest.java
index 1e4b6f5..51427af 100644
--- a/junit/rails/game/state/BooleanStateTest.java
+++ b/junit/rails/game/state/BooleanStateTest.java
@@ -8,7 +8,8 @@ import org.junit.Test;
public class BooleanStateTest {
- private final static String STATE_ID = "Boolean";
+ private final static String DEFAULT_ID = "Default";
+ private final static String INIT_ID = "Init";
private Root root;
private ChangeStack stack;
@@ -18,8 +19,8 @@ public class BooleanStateTest {
@Before
public void setUp() {
root = StateTestUtils.setUpRoot();
- state_default = BooleanState.create(root, STATE_ID);
- state_init = BooleanState.create(root, null, true);
+ state_default = BooleanState.create(root, DEFAULT_ID);
+ state_init = BooleanState.create(root, INIT_ID, true);
stack = root.getStateManager().getChangeStack();
}
diff --git a/junit/rails/game/state/GenericStateTest.java b/junit/rails/game/state/GenericStateTest.java
index cbceb30..aaccd90 100644
--- a/junit/rails/game/state/GenericStateTest.java
+++ b/junit/rails/game/state/GenericStateTest.java
@@ -8,7 +8,8 @@ import org.junit.Test;
public class GenericStateTest {
- private final static String STATE_ID = "Generic";
+ private final static String DEFAULT_ID = "Default";
+ private final static String INIT_ID = "Init";
private final static String ITEM_ID = "Item";
private final static String ANOTHER_ID = "Another";
@@ -27,8 +28,8 @@ public class GenericStateTest {
item = new AbstractItemImpl(root, ITEM_ID);
another_item = new AbstractItemImpl(root, ANOTHER_ID);
- state_default = GenericState.create(root, STATE_ID);
- state_init = GenericState.create(root, null, item);
+ state_default = GenericState.create(root, DEFAULT_ID);
+ state_init = GenericState.create(root, INIT_ID, item);
}
@Test
diff --git a/junit/rails/game/state/IntegerStateTest.java b/junit/rails/game/state/IntegerStateTest.java
index aaac06d..9c183a3 100644
--- a/junit/rails/game/state/IntegerStateTest.java
+++ b/junit/rails/game/state/IntegerStateTest.java
@@ -8,7 +8,8 @@ import org.junit.Test;
public class IntegerStateTest {
- private final static String STATE_ID = "Integer";
+ private final static String DEFAULT_ID = "Default";
+ private final static String INIT_ID = "Init";
private final static int INIT = 10;
private final static int OTHER = -5;
@@ -23,8 +24,8 @@ public class IntegerStateTest {
root = StateTestUtils.setUpRoot();
stack = root.getStateManager().getChangeStack();
- state_default = IntegerState.create(root, STATE_ID);
- state_init = IntegerState.create(root, null, INIT);
+ state_default = IntegerState.create(root, DEFAULT_ID);
+ state_init = IntegerState.create(root, INIT_ID, INIT);
}
@Test
commit 88aa9f9c92c473d67ce216759534e0fbe90b2a2d
Author: Stefan Frey <ste...@we...>
Date: Mon Jul 16 15:45:42 2012 +0200
added tests for StringState
diff --git a/junit/rails/game/state/IntegerStateTest.java b/junit/rails/game/state/IntegerStateTest.java
index c09803e..aaac06d 100644
--- a/junit/rails/game/state/IntegerStateTest.java
+++ b/junit/rails/game/state/IntegerStateTest.java
@@ -25,7 +25,6 @@ public class IntegerStateTest {
state_default = IntegerState.create(root, STATE_ID);
state_init = IntegerState.create(root, null, INIT);
- stack.closeCurrentChangeSet();
}
@Test
diff --git a/junit/rails/game/state/StringStateTest.java b/junit/rails/game/state/StringStateTest.java
new file mode 100644
index 0000000..814706d
--- /dev/null
+++ b/junit/rails/game/state/StringStateTest.java
@@ -0,0 +1,99 @@
+package rails.game.state;
+
+
+import static org.fest.assertions.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class StringStateTest {
+
+ private final static String DEFAULT_ID = "Default";
+ private final static String INIT_ID = "Init";
+ private final static String INIT = "INIT";
+ private final static String OTHER = "OTHER";
+
+ private Root root;
+ private ChangeStack stack;
+ private StringState state_default;
+ private StringState state_init;
+
+
+ @Before
+ public void setUp() {
+ root = StateTestUtils.setUpRoot();
+ stack = root.getStateManager().getChangeStack();
+
+ state_default = StringState.create(root, DEFAULT_ID);
+ state_init = StringState.create(root, INIT_ID, INIT);
+ }
+
+ @Test
+ public void testValue() {
+ assertEquals(state_default.value(), "");
+ assertEquals(state_init.value(), INIT);
+ }
+
+ @Test
+ public void testSet() {
+ state_default.set(OTHER);
+ assertEquals(state_default.value(), OTHER);
+ state_init.set("");
+ assertEquals(state_init.value(), "");
+ state_init.set(null);
+ assertEquals(state_init.value(), null);
+ }
+
+ @Test
+ public void testAppend() {
+ state_default.append(OTHER, null);
+ assertEquals(state_default.value(), OTHER);
+ state_default.append(OTHER, "");
+ assertEquals(state_default.value(), OTHER + OTHER);
+
+ state_init.append(OTHER, ",");
+ assertEquals(state_init.value(), INIT + "," + OTHER);
+ }
+
+
+ @Test
+ public void testSetSameIgnored() {
+ state_default.set("");
+ state_init.set(null);
+ stack.closeCurrentChangeSet();
+ assertThat(stack.getLastClosedChangeSet().getStates()).doesNotContain(state_default);
+ assertThat(stack.getLastClosedChangeSet().getStates()).contains(state_init);
+
+ state_default.set(null);
+ state_init.set(null);
+ stack.closeCurrentChangeSet();
+ assertThat(stack.getLastClosedChangeSet().getStates()).contains(state_default);
+ assertThat(stack.getLastClosedChangeSet().getStates()).doesNotContain(state_init);
+ }
+
+ @Test
+ public void testUndoRedo() {
+
+ state_default.set(OTHER);
+ state_default.append(OTHER, null);
+
+ state_init.append(OTHER, "");
+ state_init.set(null);
+ stack.closeCurrentChangeSet();
+
+ assertEquals(state_default.value(), OTHER+OTHER);
+ assertNull(state_init.value());
+
+ stack.undo();
+ assertEquals(state_default.value(), "");
+ assertEquals(state_init.value(), INIT);
+
+ stack.redo();
+ assertEquals(state_default.value(), OTHER+OTHER);
+ assertNull(state_init.value());
+ }
+
+
+}
diff --git a/src/rails/game/PublicCompany.java b/src/rails/game/PublicCompany.java
index 683c471..ae98342 100644
--- a/src/rails/game/PublicCompany.java
+++ b/src/rails/game/PublicCompany.java
@@ -1644,7 +1644,7 @@ public class PublicCompany extends Company implements CashOwner, PortfolioOwner,
String tileLaid =
"#" + tile.getExternalId() + "/" + hex.getId() + "/"
+ hex.getOrientationName(orientation);
- tilesLaidThisTurn.appendWithDelimiter(tileLaid, ", ");
+ tilesLaidThisTurn.append(tileLaid, ", ");
if (cost > 0) tilesCostThisTurn.change(cost);
@@ -1655,7 +1655,7 @@ public class PublicCompany extends Company implements CashOwner, PortfolioOwner,
public void layTilenNoMapMode(int cost) {
if (cost > 0) tilesCostThisTurn.change(cost);
- tilesLaidThisTurn.appendWithDelimiter(Bank.format(cost), ",");
+ tilesLaidThisTurn.append(Bank.format(cost), ",");
}
public StringState getTilesLaidThisTurnModel() {
@@ -1669,13 +1669,13 @@ public class PublicCompany extends Company implements CashOwner, PortfolioOwner,
public void layBaseToken(MapHex hex, int cost) {
String tokenLaid = hex.getId();
- tokensLaidThisTurn.appendWithDelimiter(tokenLaid, ", ");
+ tokensLaidThisTurn.append(tokenLaid, ", ");
if (cost > 0) tokensCostThisTurn.change(cost);
}
public void layBaseTokennNoMapMode(int cost) {
if (cost > 0) tokensCostThisTurn.change(cost);
- tokensLaidThisTurn.appendWithDelimiter(Bank.format(cost), ",");
+ tokensLaidThisTurn.append(Bank.format(cost), ",");
}
/**
diff --git a/src/rails/game/state/StringState.java b/src/rails/game/state/StringState.java
index 4cb7308..f069f19 100644
--- a/src/rails/game/state/StringState.java
+++ b/src/rails/game/state/StringState.java
@@ -27,7 +27,15 @@ public final class StringState extends State {
}
public void set(String value) {
- new StringChange(this, value);
+ if (value == null) {
+ if (this.value != null) {
+ new StringChange(this, value);
+ } // otherwise both are null
+ } else {
+ if (this.value == null || !value.equals(this.value)) {
+ new StringChange(this, value);
+ } // otherwise the non-null current value is unequal to the new value
+ }
}
/**
@@ -37,7 +45,7 @@ public final class StringState extends State {
* @param value string to append
* @param delimiter to use before appending (only for non-empty value)
*/
- public void appendWithDelimiter(String value, String delimiter) {
+ public void append(String value, String delimiter) {
if (value == null || value.equals("") ) return;
String newValue;
commit e986c281fa5a2b55a74a02805e4478b076aec0e3
Author: Stefan Frey <ste...@we...>
Date: Mon Jul 16 15:18:25 2012 +0200
added test for IntegerState, fixed missing check for identical values
diff --git a/junit/rails/game/state/IntegerStateTest.java b/junit/rails/game/state/IntegerStateTest.java
new file mode 100644
index 0000000..c09803e
--- /dev/null
+++ b/junit/rails/game/state/IntegerStateTest.java
@@ -0,0 +1,85 @@
+package rails.game.state;
+
+import static org.fest.assertions.api.Assertions.assertThat;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class IntegerStateTest {
+
+ private final static String STATE_ID = "Integer";
+ private final static int INIT = 10;
+ private final static int OTHER = -5;
+
+ private Root root;
+ private ChangeStack stack;
+ private IntegerState state_default;
+ private IntegerState state_init;
+
+
+ @Before
+ public void setUp() {
+ root = StateTestUtils.setUpRoot();
+ stack = root.getStateManager().getChangeStack();
+
+ state_default = IntegerState.create(root, STATE_ID);
+ state_init = IntegerState.create(root, null, INIT);
+ stack.closeCurrentChangeSet();
+ }
+
+ @Test
+ public void testValue() {
+ assertEquals(state_default.value(), 0);
+ assertEquals(state_init.value(), INIT);
+ }
+
+ @Test
+ public void testSet() {
+ state_default.set(OTHER);
+ assertEquals(state_default.value(), OTHER);
+ state_init.set(0);
+ assertEquals(state_init.value(), 0);
+
+ }
+
+ @Test
+ public void testAdd() {
+ state_default.add(OTHER);
+ assertEquals(state_default.value(), OTHER);
+ state_init.add(OTHER);
+ assertEquals(state_init.value(), INIT + OTHER);
+ }
+
+
+ @Test
+ public void testSetSameIgnored() {
+ state_default.set(0);
+ state_init.set((INIT));
+ stack.closeCurrentChangeSet();
+ assertThat(stack.getLastClosedChangeSet().getStates()).doesNotContain(state_default, state_init);
+ }
+
+ @Test
+ public void testUndoRedo() {
+
+ state_default.set(INIT);
+ state_default.add(OTHER);
+
+ state_init.add(OTHER);
+ state_init.set(0);
+ stack.closeCurrentChangeSet();
+
+ assertEquals(state_default.value(), INIT+OTHER);
+ assertEquals(state_init.value(), 0);
+
+ stack.undo();
+ assertEquals(state_default.value(), 0);
+ assertEquals(state_init.value(), INIT);
+
+ stack.redo();
+ assertEquals(state_default.value(), INIT+OTHER);
+ assertEquals(state_init.value(), 0);
+ }
+
+}
diff --git a/junit/rails/game/state/StateTest.java b/junit/rails/game/state/StateTest.java
index 0fb56a5..dcc2bef 100644
--- a/junit/rails/game/state/StateTest.java
+++ b/junit/rails/game/state/StateTest.java
@@ -46,9 +46,9 @@ public class StateTest {
}
@Test
- public void testObserverText() {
- assertNull(state.observerText());
- assertEquals(STATE_TEXT, state_wo_id.observerText());
- }
+ public void testObserverText() {
+ assertNull(state.observerText());
+ assertEquals(STATE_TEXT, state_wo_id.observerText());
+ }
}
diff --git a/src/rails/game/state/IntegerState.java b/src/rails/game/state/IntegerState.java
index cb3286a..4a03f7e 100644
--- a/src/rails/game/state/IntegerState.java
+++ b/src/rails/game/state/IntegerState.java
@@ -27,7 +27,7 @@ public final class IntegerState extends State {
}
public void set(int value) {
- new IntegerChange(this, value);
+ if (value != this.value) new IntegerChange(this, value);
}
public int add(int value) {
commit 60f9ec44f5b48c01845eb7065d18fa80d73be3da
Author: Stefan Frey <ste...@we...>
Date: Mon Jul 16 14:48:23 2012 +0200
rename GenericState.get() to GenericState.value()
diff --git a/.project b/.project
index 8f28e06..a2abb72 100644
--- a/.project
+++ b/.project
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Rails</name>
- <comment></comment>
+ <comment>@key 32303037303533312D31303030205261696C732F6672657973746566 </comment>
<projects>
</projects>
<buildSpec>
@@ -10,10 +10,16 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>com.soyatec.additional.Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
+ <nature>com.soyatec.additional.Nature</nature>
</natures>
</projectDescription>
diff --git a/junit/rails/game/state/GenericStateTest.java b/junit/rails/game/state/GenericStateTest.java
index 36926f9..cbceb30 100644
--- a/junit/rails/game/state/GenericStateTest.java
+++ b/junit/rails/game/state/GenericStateTest.java
@@ -33,18 +33,18 @@ public class GenericStateTest {
@Test
public void testValue() {
- assertNull(state_default.get());
- assertSame(item, state_init.get());
+ assertNull(state_default.value());
+ assertSame(item, state_init.value());
}
@Test
public void testSet() {
state_default.set(item);
- assertSame(item, state_default.get());
+ assertSame(item, state_default.value());
state_default.set(null);
- assertNull(state_default.get());
+ assertNull(state_default.value());
state_init.set(another_item);
- assertSame(another_item, state_init.get());
+ assertSame(another_item, state_init.value());
}
@Test
@@ -57,25 +57,25 @@ public class GenericStateTest {
@Test
public void testUndoRedo() {
- assertNull(state_default.get());
- assertSame(item, state_init.get());
+ assertNull(state_default.value());
+ assertSame(item, state_init.value());
state_default.set(item);
state_init.set(another_item);
- assertSame(item, state_default.get());
- assertSame(another_item, state_init.get());
+ assertSame(item, state_default.value());
+ assertSame(another_item, state_init.value());
stack.closeCurrentChangeSet();
// remark: state_init is an internal (isObservable = false)
assertThat(stack.getLastClosedChangeSet().getStates()).contains(state_default);
stack.undo();
- assertNull(state_default.get());
- assertSame(item, state_init.get());
+ assertNull(state_default.value());
+ assertSame(item, state_init.value());
stack.redo();
- assertSame(item, state_default.get());
- assertSame(another_item, state_init.get());
+ assertSame(item, state_default.value());
+ assertSame(another_item, state_init.value());
}
}
diff --git a/src/rails/common/GuiHints.java b/src/rails/common/GuiHints.java
index ddd3d1b..562af79 100644
--- a/src/rails/common/GuiHints.java
+++ b/src/rails/common/GuiHints.java
@@ -39,7 +39,7 @@ public final class GuiHints extends AbstractItem implements Serializable{
}
public Class<? extends Round> getCurrentRoundType() {
- return currentRoundType.get();
+ return currentRoundType.value();
}
public void setCurrentRoundType(Class<? extends Round> currentRoundType) {
@@ -66,7 +66,7 @@ public final class GuiHints extends AbstractItem implements Serializable{
}
public GuiDef.Panel getActivePanel() {
- return (GuiDef.Panel)activePanel.get();
+ return (GuiDef.Panel)activePanel.value();
}
public void setActivePanel(GuiDef.Panel activePanel) {
diff --git a/src/rails/game/GameManager.java b/src/rails/game/GameManager.java
index 083fba6..6aea545 100644
--- a/src/rails/game/GameManager.java
+++ b/src/rails/game/GameManager.java
@@ -914,7 +914,7 @@ public class GameManager extends AbstractItem implements ConfigurableComponent,
// logging of game actions activated
for (PossibleAction pa : possibleActions.getList()) {
- log.debug(((Player) currentPlayer.get()).getId() + " may: "
+ log.debug(((Player) currentPlayer.value()).getId() + " may: "
+ pa.toString());
}
@@ -1031,8 +1031,8 @@ public class GameManager extends AbstractItem implements ConfigurableComponent,
if (skipNextDone) {
if (action instanceof NullAction
&& ((NullAction)action).getMode() == NullAction.DONE) {
- if (currentRound.get() instanceof OperatingRound
- && ((OperatingRound)currentRound.get()).getStep() == skippedStep) {
+ if (currentRound.value() instanceof OperatingRound
+ && ((OperatingRound)currentRound.value()).getStep() == skippedStep) {
doProcess = false;
}
}
@@ -1407,7 +1407,7 @@ public class GameManager extends AbstractItem implements ConfigurableComponent,
* @see rails.game.GameManager#getCurrentRound()
*/
public Round getCurrentRound() {
- return (Round) currentRound.get();
+ return (Round) currentRound.value();
}
/* (non-Javadoc)
@@ -1432,7 +1432,7 @@ public class GameManager extends AbstractItem implements ConfigurableComponent,
*/
public void setCurrentPlayer(Player player) {
// transfer messages for the next player to the display buffer
- if ((Player)currentPlayer.get() != player && !nextPlayerMessages.isEmpty()) {
+ if ((Player)currentPlayer.value() != player && !nextPlayerMessages.isEmpty()) {
DisplayBuffer.add(
LocalText.getText("NextPlayerMessage", getCurrentPlayer().getId()));
for (String s:nextPlayerMessages.view())
@@ -1465,14 +1465,14 @@ public class GameManager extends AbstractItem implements ConfigurableComponent,
* @see rails.game.GameManager#getPriorityPlayer()
*/
public Player getPriorityPlayer() {
- return (Player) priorityPlayer.get();
+ return (Player) priorityPlayer.value();
}
/* (non-Javadoc)
* @see rails.game.GameManager#getCurrentPlayer()
*/
public Player getCurrentPlayer() {
- return (Player) currentPlayer.get();
+ return (Player) currentPlayer.value();
}
/* (non-Javadoc)
diff --git a/src/rails/game/OperatingRound.java b/src/rails/game/OperatingRound.java
index b5b56ad..6596ade 100644
--- a/src/rails/game/OperatingRound.java
+++ b/src/rails/game/OperatingRound.java
@@ -232,10 +232,10 @@ public class OperatingRound extends Round implements Observer {
if (action instanceof PossibleORAction
&& !(action instanceof DiscardTrain)) {
PublicCompany company = ((PossibleORAction) action).getCompany();
- if (company != operatingCompany.get()) {
+ if (company != operatingCompany.value()) {
DisplayBuffer.add(LocalText.getText("WrongCompany",
company.getId(),
- operatingCompany.get().getId() ));
+ operatingCompany.value().getId() ));
return false;
}
}
@@ -369,14 +369,14 @@ public class OperatingRound extends Round implements Observer {
GameDef.OrStep step = getStep();
if (step == GameDef.OrStep.LAY_TRACK) {
- if (!operatingCompany.get().hasLaidHomeBaseTokens()) {
+ if (!operatingCompany.value().hasLaidHomeBaseTokens()) {
// This can occur if the home hex has two cities and track,
// such as the green OO tile #59
// BR: as this is a home token, need to call LayBaseToken with a MapHex, not a list
// to avoid the LayBaseToken action from being a regular token lay
// I am not sure that this will work with multiple home hexes.
- for (MapHex home : operatingCompany.get().getHomeHexes()) {
+ for (MapHex home : operatingCompany.value().getHomeHexes()) {
possibleActions.add(new LayBaseToken (home) );
}
forced = true;
@@ -407,7 +407,7 @@ public class OperatingRound extends Round implements Observer {
// || operatingCompany.getObject().getPortfolio().getNumberOfTrains() > 0) {
doneAllowed = true;
//}
- if (noMapMode && (operatingCompany.get().getLastRevenue() == 0))
+ if (noMapMode && (operatingCompany.value().getLastRevenue() == 0))
prepareNoMapActions();
} else if (step == GameDef.OrStep.DISCARD_TRAINS) {
@@ -436,7 +436,7 @@ public class OperatingRound extends Round implements Observer {
if (isPrivateSellingAllowed()) {
// Create a list of players with the current one in front
- int currentPlayerIndex = operatingCompany.get().getPresident().getIndex();
+ int currentPlayerIndex = operatingCompany.value().getPresident().getIndex();
Player player;
int minPrice, maxPrice;
List<Player> players = getPlayers();
@@ -462,7 +462,7 @@ public class OperatingRound extends Round implements Observer {
}
}
- if (operatingCompany.get().canUseSpecialProperties()) {
+ if (operatingCompany.value().canUseSpecialProperties()) {
// Are there any "common" special properties,
// i.e. properties that are available to everyone?
@@ -473,8 +473,8 @@ public class OperatingRound extends Round implements Observer {
if (sp instanceof SellBonusToken) {
sbt = (SellBonusToken) sp;
// Can't buy if already owned
- if (operatingCompany.get().getBonuses() != null) {
- for (Bonus bonus : operatingCompany.get().getBonuses()) {
+ if (operatingCompany.value().getBonuses() != null) {
+ for (Bonus bonus : operatingCompany.value().getBonuses()) {
if (bonus.getName().equals(sp.getId())) continue loop;
}
}
@@ -484,7 +484,7 @@ public class OperatingRound extends Round implements Observer {
}
// Are there other step-independent special properties owned by the company?
- List<SpecialProperty> orsps = operatingCompany.get().getPortfolioModel().getAllSpecialProperties();
+ List<SpecialProperty> orsps = operatingCompany.value().getPortfolioModel().getAllSpecialProperties();
// TODO: Do we still need this directly from the operating company?
// List<SpecialProperty> compsps = operatingCompany.get().getSpecialProperties();
@@ -529,7 +529,7 @@ public class OperatingRound extends Round implements Observer {
for (PossibleAction pa : possibleActions.getList()) {
try {
- log.debug(operatingCompany.get().getId() + " may: " + pa.toString());
+ log.debug(operatingCompany.value().getId() + " may: " + pa.toString());
} catch (Exception e) {
log.error("Error in toString() of " + pa.getClass(), e);
}
@@ -548,36 +548,36 @@ public class OperatingRound extends Round implements Observer {
*=======================================*/
protected void initTurn() {
- log.debug("Starting turn of "+operatingCompany.get().getId());
+ log.debug("Starting turn of "+operatingCompany.value().getId());
ReportBuffer.add(" ");
ReportBuffer.add(LocalText.getText("CompanyOperates",
- operatingCompany.get().getId(),
- operatingCompany.get().getPresident().getId()));
- setCurrentPlayer(operatingCompany.get().getPresident());
+ operatingCompany.value().getId(),
+ operatingCompany.value().getPresident().getId()));
+ setCurrentPlayer(operatingCompany.value().getPresident());
- if (noMapMode && !operatingCompany.get().hasLaidHomeBaseTokens()){
+ if (noMapMode && !operatingCompany.value().hasLaidHomeBaseTokens()){
// Lay base token in noMapMode
- BaseToken token = operatingCompany.get().getFreeToken();
+ BaseToken token = operatingCompany.value().getFreeToken();
if (token == null) {
- log.error("Company " + operatingCompany.get().getId() + " has no free token to lay base token");
+ log.error("Company " + operatingCompany.value().getId() + " has no free token to lay base token");
} else {
- log.debug("Company " + operatingCompany.get().getId() + " lays base token in nomap mode");
+ log.debug("Company " + operatingCompany.value().getId() + " lays base token in nomap mode");
// FIXME: This has to be rewritten
// Where are the nomap base tokens to be stored?
// bank.getUnavailable().addBonusToken(token);
}
}
- operatingCompany.get().initTurn();
+ operatingCompany.value().initTurn();
trainsBoughtThisTurn.clear();
}
protected void finishTurn() {
- if (!operatingCompany.get().isClosed()) {
- operatingCompany.get().setOperated();
- companiesOperatedThisRound.add(operatingCompany.get());
+ if (!operatingCompany.value().isClosed()) {
+ operatingCompany.value().setOperated();
+ companiesOperatedThisRound.add(operatingCompany.value());
- for (PrivateCompany priv : operatingCompany.get().getPortfolioModel().getPrivateCompanies()) {
+ for (PrivateCompany priv : operatingCompany.value().getPortfolioModel().getPrivateCompanies()) {
priv.checkClosingIfExercised(true);
}
}
@@ -603,18 +603,18 @@ public class OperatingRound extends Round implements Observer {
protected boolean setNextOperatingCompany(boolean initial) {
while (true) {
- if (initial || operatingCompany.get() == null || operatingCompany == null) {
+ if (initial || operatingCompany.value() == null || operatingCompany == null) {
setOperatingCompany(operatingCompanies.get(0));
initial = false;
} else {
- int index = operatingCompanies.indexOf(operatingCompany.get());
+ int index = operatingCompanies.indexOf(operatingCompany.value());
if (++index >= operatingCompanies.size()) {
return false;
}
// Check if the operating order has changed
List<PublicCompany> newOperatingCompanies
- = setOperatingCompanies (operatingCompanies.view(), operatingCompany.get());
+ = setOperatingCompanies (operatingCompanies.view(), operatingCompany.value());
PublicCompany company;
for (int i=0; i<newOperatingCompanies.size(); i++) {
company = newOperatingCompanies.get(i);
@@ -629,7 +629,7 @@ public class OperatingRound extends Round implements Observer {
setOperatingCompany(operatingCompanies.get(index));
}
- if (operatingCompany.get().isClosed()) continue;
+ if (operatingCompany.value().isClosed()) continue;
return true;
}
@@ -645,7 +645,7 @@ public class OperatingRound extends Round implements Observer {
* @return The currently operating company object.
*/
public PublicCompany getOperatingCompany() {
- return operatingCompany.get();
+ return operatingCompany.value();
}
public List<PublicCompany> getOperatingCompanies() {
@@ -668,7 +668,7 @@ public class OperatingRound extends Round implements Observer {
* @return The number that defines the next action.
*/
public GameDef.OrStep getStep() {
- return (GameDef.OrStep) stepObject.get();
+ return (GameDef.OrStep) stepObject.value();
}
/**
@@ -697,7 +697,7 @@ public class OperatingRound extends Round implements Observer {
/** Take the next step after a given one (see nextStep()) */
protected void nextStep(GameDef.OrStep step) {
- PublicCompany company = operatingCompany.get();
+ PublicCompany company = operatingCompany.value();
// Cycle through the steps until we reach one where a user action is
// expected.
@@ -795,7 +795,7 @@ public class OperatingRound extends Round implements Observer {
* updateStatus(), which is called after each user action)
*/
protected void prepareStep() {
- GameDef.OrStep step = stepObject.get();
+ GameDef.OrStep step = stepObject.value();
if (step == GameDef.OrStep.LAY_TRACK) {
// getNormalTileLays();
@@ -813,7 +813,7 @@ public class OperatingRound extends Round implements Observer {
*=======================================*/
public void skip() {
- log.debug("Skip step " + stepObject.get());
+ log.debug("Skip step " + stepObject.value());
// TODO: Check if this is ok
// FIXME: changeStack.start(true);
nextStep();
@@ -827,8 +827,8 @@ public class OperatingRound extends Round implements Observer {
*/
public boolean done() {
- if (operatingCompany.get().getPortfolioModel().getNumberOfTrains() == 0
- && operatingCompany.get().mustOwnATrain()) {
+ if (operatingCompany.value().getPortfolioModel().getNumberOfTrains() == 0
+ && operatingCompany.value().mustOwnATrain()) {
// FIXME: Need to check for valid route before throwing an
// error.
/* Check TEMPORARILY disabled
@@ -918,7 +918,7 @@ public class OperatingRound extends Round implements Observer {
// otherwise continue train buying
if (!checkForExcessTrains()) {
// Trains may have been discarded by other players
- setCurrentPlayer (operatingCompany.get().getPresident());
+ setCurrentPlayer (operatingCompany.value().getPresident());
stepObject.set(GameDef.OrStep.BUY_TRAIN);
}
@@ -1023,11 +1023,11 @@ public class OperatingRound extends Round implements Observer {
break;
}
// Does the company have the money?
- if (price > operatingCompany.get().getCash()) {
+ if (price > operatingCompany.value().getCash()) {
errMsg =
LocalText.getText("NotEnoughMoney",
publicCompanyName,
- Bank.format(operatingCompany.get().getCash()),
+ Bank.format(operatingCompany.value().getCash()),
Bank.format(price) );
break;
}
@@ -1053,7 +1053,7 @@ public class OperatingRound extends Round implements Observer {
// TODO: changeStack.start(true);
- operatingCompany.get().buyPrivate(privateCompany, player.getPortfolioModel(),
+ operatingCompany.value().buyPrivate(privateCompany, player.getPortfolioModel(),
price);
return true;
@@ -1075,7 +1075,7 @@ public class OperatingRound extends Round implements Observer {
protected int getPrivateMaximumPrice (PrivateCompany privComp) {
int maxPrice = privComp.getUpperPrice();
if (maxPrice == PrivateCompany.NO_PRICE_LIMIT) {
- maxPrice = operatingCompany.get().getCash();
+ maxPrice = operatingCompany.value().getCash();
}
return maxPrice;
}
@@ -1191,7 +1191,7 @@ public class OperatingRound extends Round implements Observer {
// Checks
// Is company operating?
- if (company != operatingCompany.get()) {
+ if (company != operatingCompany.value()) {
errMsg =
LocalText.getText("WrongCompany",
companyName,
@@ -1224,31 +1224,31 @@ public class OperatingRound extends Round implements Observer {
int number = action.getNumberTaken();
int amount = calculateLoanAmount (number);
- operatingCompany.get().addLoans(number);
- MoneyModel.cashMove (bank, operatingCompany.get(), amount);
+ operatingCompany.value().addLoans(number);
+ MoneyModel.cashMove (bank, operatingCompany.value(), amount);
if (number == 1) {
ReportBuffer.add(LocalText.getText("CompanyTakesLoan",
- operatingCompany.get().getId(),
- Bank.format(operatingCompany.get().getValuePerLoan()),
+ operatingCompany.value().getId(),
+ Bank.format(operatingCompany.value().getValuePerLoan()),
Bank.format(amount)
));
} else {
ReportBuffer.add(LocalText.getText("CompanyTakesLoans",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
number,
- Bank.format(operatingCompany.get().getValuePerLoan()),
+ Bank.format(operatingCompany.value().getValuePerLoan()),
Bank.format(amount)
));
}
- if (operatingCompany.get().getMaxLoansPerRound() > 0) {
+ if (operatingCompany.value().getMaxLoansPerRound() > 0) {
int oldLoansThisRound = 0;
if (loansThisRound == null) {
loansThisRound = HashMapState.create(this, "loansThisRound");
- } else if (loansThisRound.containsKey(operatingCompany.get())){
- oldLoansThisRound = loansThisRound.get(operatingCompany.get());
+ } else if (loansThisRound.containsKey(operatingCompany.value())){
+ oldLoansThisRound = loansThisRound.get(operatingCompany.value());
}
- loansThisRound.put(operatingCompany.get(),
+ loansThisRound.put(operatingCompany.value(),
new Integer (oldLoansThisRound + number));
}
}
@@ -1267,11 +1267,11 @@ public class OperatingRound extends Round implements Observer {
return false;
}
- int repayment = action.getNumberRepaid() * operatingCompany.get().getValuePerLoan();
- if (repayment > 0 && repayment > operatingCompany.get().getCash()) {
+ int repayment = action.getNumberRepaid() * operatingCompany.value().getValuePerLoan();
+ if (repayment > 0 && repayment > operatingCompany.value().getCash()) {
// President must contribute
- int remainder = repayment - operatingCompany.get().getCash();
- Player president = operatingCompany.get().getPresident();
+ int remainder = repayment - operatingCompany.value().getCash();
+ Player president = operatingCompany.value().getPresident();
int presCash = president.getCashValue();
if (remainder > presCash) {
// Start a share selling round
@@ -1281,8 +1281,8 @@ public class OperatingRound extends Round implements Observer {
log.info("President has $"+presCash+", so $"+cashToBeRaisedByPresident+" must be added");
savedAction = action;
// TODO: changeStack.start(true);
- gameManager.startShareSellingRound(operatingCompany.get().getPresident(),
- cashToBeRaisedByPresident, operatingCompany.get(), false);
+ gameManager.startShareSellingRound(operatingCompany.value().getPresident(),
+ cashToBeRaisedByPresident, operatingCompany.value(), false);
return true;
}
}
@@ -1307,50 +1307,50 @@ public class OperatingRound extends Round implements Observer {
int payment;
int remainder = 0;
- operatingCompany.get().addLoans(-number);
- int amount = number * operatingCompany.get().getValuePerLoan();
- payment = Math.min(amount, operatingCompany.get().getCash());
+ operatingCompany.value().addLoans(-number);
+ int amount = number * operatingCompany.value().getValuePerLoan();
+ payment = Math.min(amount, operatingCompany.value().getCash());
remainder = amount - payment;
if (payment > 0) {
- MoneyModel.cashMove (operatingCompany.get(), bank, payment);
+ MoneyModel.cashMove (operatingCompany.value(), bank, payment);
ReportBuffer.add (LocalText.getText("CompanyRepaysLoans",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
Bank.format(payment),
Bank.format(amount),
number,
- Bank.format(operatingCompany.get().getValuePerLoan())));
+ Bank.format(operatingCompany.value().getValuePerLoan())));
}
if (remainder > 0) {
- Player president = operatingCompany.get().getPresident();
+ Player president = operatingCompany.value().getPresident();
if (president.getCashValue() >= remainder) {
payment = remainder;
MoneyModel.cashMove (president, bank, payment);
ReportBuffer.add (LocalText.getText("CompanyRepaysLoansWithPresCash",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
Bank.format(payment),
Bank.format(amount),
number,
- Bank.format(operatingCompany.get().getValuePerLoan()),
+ Bank.format(operatingCompany.value().getValuePerLoan()),
president.getId()));
}
}
}
protected int calculateLoanAmount (int numberOfLoans) {
- return numberOfLoans * operatingCompany.get().getValuePerLoan();
+ return numberOfLoans * operatingCompany.value().getValuePerLoan();
}
// TODO UNUSED??
public void payLoanInterest () {
- int amount = operatingCompany.get().getCurrentLoanValue()
- * operatingCompany.get().getLoanInterestPct() / 100;
- MoneyModel.cashMove (operatingCompany.get(), bank, amount);
+ int amount = operatingCompany.value().getCurrentLoanValue()
+ * operatingCompany.value().getLoanInterestPct() / 100;
+ MoneyModel.cashMove (operatingCompany.value(), bank, amount);
DisplayBuffer.add(LocalText.getText("CompanyPaysLoanInterest",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
Bank.format(amount),
- operatingCompany.get().getLoanInterestPct(),
- operatingCompany.get().getCurrentNumberOfLoans(),
- Bank.format(operatingCompany.get().getValuePerLoan())));
+ operatingCompany.value().getLoanInterestPct(),
+ operatingCompany.value().getCurrentNumberOfLoans(),
+ Bank.format(operatingCompany.value().getValuePerLoan())));
}
/*=======================================
@@ -1382,11 +1382,11 @@ public class OperatingRound extends Round implements Observer {
// TODO: changeStack.start(true);
- operatingCompany.get().setRight(rightName, rightValue);
- MoneyModel.cashMove (operatingCompany.get(), bank, right.getCost());
+ operatingCompany.value().setRight(rightName, rightValue);
+ MoneyModel.cashMove (operatingCompany.value(), bank, right.getCost());
ReportBuffer.add(LocalText.getText("BuysRight",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
rightName,
Bank.format(right.getCost())));
@@ -1416,11 +1416,11 @@ public class OperatingRound extends Round implements Observer {
while (true) {
// Checks
// Must be correct company.
- if (!companyName.equals(operatingCompany.get().getId())) {
+ if (!companyName.equals(operatingCompany.value().getId())) {
errMsg =
LocalText.getText("WrongCompany",
companyName,
- operatingCompany.get().getId() );
+ operatingCompany.value().getId() );
break;
}
// Must be correct step
@@ -1495,11 +1495,11 @@ public class OperatingRound extends Round implements Observer {
break;
}
// Does the company have the money?
- if (cost > operatingCompany.get().getCash()) {
+ if (cost > operatingCompany.value().getCash()) {
errMsg =
LocalText.getText("NotEnoughMoney",
companyName,
- Bank.format(operatingCompany.get().getCash()),
+ Bank.format(operatingCompany.value().getCash()),
Bank.format(cost) );
break;
}
@@ -1520,8 +1520,8 @@ public class OperatingRound extends Round implements Observer {
if (tile != null) {
if (cost > 0)
- MoneyModel.cashMove(operatingCompany.get(), bank, cost);
- operatingCompany.get().layTile(hex, tile, orientation, cost);
+ MoneyModel.cashMove(operatingCompany.value(), bank, cost);
+ operatingCompany.value().layTile(hex, tile, orientation, cost);
if (cost == 0) {
ReportBuffer.add(LocalText.getText("LaysTileAt",
@@ -1628,7 +1628,7 @@ public class OperatingRound extends Round implements Observer {
// duplicate the phase colours
Map<String, Integer> newTileColours = new HashMap<String, Integer>(getCurrentPhase().getTileColours());
for (String colour : newTileColours.keySet()) {
- int allowedNumber = operatingCompany.get().getNumberOfTileLays(colour);
+ int allowedNumber = operatingCompany.value().getNumberOfTileLays(colour);
// Replace the null map value with the allowed number of lays
newTileColours.put(colour, new Integer(allowedNumber));
}
@@ -1679,7 +1679,7 @@ public class OperatingRound extends Round implements Observer {
/* Special-property tile lays */
List<LayTile> currentSpecialTileLays = new ArrayList<LayTile>();
- if (operatingCompany.get().canUseSpecialProperties()) {
+ if (operatingCompany.value().canUseSpecialProperties()) {
for (SpecialTileLay stl : getSpecialProperties(SpecialTileLay.class)) {
if (stl.isExtra()
@@ -1750,7 +1750,7 @@ public class OperatingRound extends Round implements Observer {
MapHex hex = action.getChosenHex();
int station = action.getChosenStation();
- String companyName = operatingCompany.get().getId();
+ String companyName = operatingCompany.value().getId();
// Dummy loop to enable a quick jump out.
while (true) {
@@ -1764,12 +1764,12 @@ public class OperatingRound extends Round implements Observer {
break;
}
- if (operatingCompany.get().getNumberOfFreeBaseTokens() == 0) {
+ if (operatingCompany.value().getNumberOfFreeBaseTokens() == 0) {
errMsg = LocalText.getText("HasNoTokensLeft", companyName);
break;
}
- if (!isTokenLayAllowed (operatingCompany.get(), hex, station)) {
+ if (!isTokenLayAllowed (operatingCompany.value(), hex, station)) {
errMsg = LocalText.getText("BaseTokenSlotIsReserved");
break;
}
@@ -1784,7 +1784,7 @@ public class OperatingRound extends Round implements Observer {
* cities on one tile may hold tokens of the same company; this case
* is not yet covered.
*/
- if (hex.hasTokenOfCompany(operatingCompany.get())) {
+ if (hex.hasTokenOfCompany(operatingCompany.value())) {
errMsg =
LocalText.getText("TileAlreadyHasToken",
hex.getId(),
@@ -1806,14 +1806,14 @@ public class OperatingRound extends Round implements Observer {
if (stl != null) extra = stl.isExtra();
}
- cost = operatingCompany.get().getBaseTokenLayCost(hex);
+ cost = operatingCompany.value().getBaseTokenLayCost(hex);
if (stl != null && stl.isFree()) cost = 0;
// Does the company have the money?
- if (cost > operatingCompany.get().getCash()) {
+ if (cost > operatingCompany.value().getCash()) {
errMsg = LocalText.getText("NotEnoughMoney",
companyName,
- Bank.format(operatingCompany.get().getCash()),
+ Bank.format(operatingCompany.value().getCash()),
Bank.format(cost));
break;
}
@@ -1831,10 +1831,10 @@ public class OperatingRound extends Round implements Observer {
/* End of validation, start of execution */
// TODO: changeStack.start(true);
- if (hex.layBaseToken(operatingCompany.get(), station)) {
+ if (hex.layBaseToken(operatingCompany.value(), station)) {
/* TODO: the false return value must be impossible. */
- operatingCompany.get().layBaseToken(hex, cost);
+ operatingCompany.value().layBaseToken(hex, cost);
// If this is a home base token lay, stop here
if (action.getType() == LayBaseToken.HOME_CITY) {
@@ -1842,7 +1842,7 @@ public class OperatingRound extends Round implements Observer {
}
if (cost > 0) {
- MoneyModel.cashMove(operatingCompany.get(), bank, cost);
+ MoneyModel.cashMove(operatingCompany.value(), bank, cost);
ReportBuffer.add(LocalText.getText("LAYS_TOKEN_ON",
companyName,
hex.getId(),
@@ -1872,7 +1872,7 @@ public class OperatingRound extends Round implements Observer {
if (currentNormalTokenLays.isEmpty()) {
log.debug("No more normal token lays are allowed");
- } else if (operatingCompany.get().getNumberOfFreeBaseTokens() == 0) {
+ } else if (operatingCompany.value().getNumberOfFreeBaseTokens() == 0) {
log.debug("Normal token lay allowed by no more tokens");
currentNormalTokenLays.clear();
} else {
@@ -1916,7 +1916,7 @@ public class OperatingRound extends Round implements Observer {
currentNormalTokenLays.clear();
/* For now, we allow one token of the currently operating company */
- if (operatingCompany.get().getNumberOfFreeBaseTokens() > 0) {
+ if (operatingCompany.value().getNumberOfFreeBaseTokens() > 0) {
currentNormalTokenLays.add(new LayBaseToken((List<MapHex>) null));
}
@@ -1933,13 +1933,13 @@ public class OperatingRound extends Round implements Observer {
/* Special-property tile lays */
currentSpecialTokenLays.clear();
- if (!operatingCompany.get().canUseSpecialProperties()) return;
+ if (!operatingCompany.value().canUseSpecialProperties()) return;
/*
* In 1835, this only applies to major companies. TODO: For now,
* hardcode this, but it must become configurable later.
*/
- if (operatingCompany.get().getType().getId().equals("Minor")) return;
+ if (operatingCompany.value().getType().getId().equals("Minor")) return;
for (SpecialTokenLay stl : getSpecialProperties(SpecialTokenLay.class)) {
log.debug("Spec.prop:" + stl);
@@ -1988,10 +1988,10 @@ public class OperatingRound extends Round implements Observer {
if (stl != null && stl.isFree()) cost = 0;
// Does the company have the money?
- if (cost > operatingCompany.get().getCash()) {
+ if (cost > operatingCompany.value().getCash()) {
errMsg =
LocalText.getText("NotEnoughMoney",
- operatingCompany.get().getId());
+ operatingCompany.value().getId());
break;
}
break;
@@ -2011,13 +2011,13 @@ public class OperatingRound extends Round implements Observer {
if (hex.layBonusToken(token, gameManager.getPhaseManager())) {
/* TODO: the false return value must be impossible. */
- operatingCompany.get().addBonus(new Bonus(operatingCompany.get(),
+ operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),
token.getId(),
token.getValue(), Collections.singletonList(hex)));
- token.setUser(operatingCompany.get());
+ token.setUser(operatingCompany.value());
ReportBuffer.add(LocalText.getText("LaysBonusTokenOn",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
token.getId(),
Bank.format(token.getValue()),
hex.getId() ));
@@ -2052,11 +2052,11 @@ public class OperatingRound extends Round implements Observer {
seller = (CashOwner)sbt.getSeller(); // TODO: Remove the cast?
// Does the company have the money?
- if (cost > operatingCompany.get().getCash()) {
+ if (cost > operatingCompany.value().getCash()) {
errMsg =
LocalText.getText("NotEnoughMoney",
- operatingCompany.get().getId(),
- Bank.format(operatingCompany.get().getCash()),
+ operatingCompany.value().getId(),
+ Bank.format(operatingCompany.value().getCash()),
Bank.format(cost));
break;
}
@@ -2064,7 +2064,7 @@ public class OperatingRound extends Round implements Observer {
}
if (errMsg != null) {
DisplayBuffer.add(LocalText.getText("CannotBuyBonusToken",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
sbt.getId(),
seller.getId(),
Bank.format(cost),
@@ -2075,14 +2075,14 @@ public class OperatingRound extends Round implements Observer {
/* End of validation, start of execution */
// TODO: changeStack.start(true);
- MoneyModel.cashMove(operatingCompany.get(), seller, cost);
- operatingCompany.get().addBonus(new Bonus(operatingCompany.get(),
+ MoneyModel.cashMove(operatingCompany.value(), seller, cost);
+ operatingCompany.value().addBonus(new Bonus(operatingCompany.value(),
sbt.getId(),
sbt.getValue(),
sbt.getLocations()));
ReportBuffer.add(LocalText.getText("BuysBonusTokenFrom",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
sbt.getId(),
Bank.format(sbt.getValue()),
seller.getId(),
@@ -2160,11 +2160,11 @@ public class OperatingRound extends Round implements Observer {
// Must be correct company.
company = action.getCompany();
companyName = company.getId();
- if (company != operatingCompany.get()) {
+ if (company != operatingCompany.value()) {
errMsg =
LocalText.getText("WrongCompany",
companyName,
- operatingCompany.get().getId() );
+ operatingCompany.value().getId() );
break;
}
// Must be correct step
@@ -2220,9 +2220,9 @@ public class OperatingRound extends Round implements Observer {
action.setRevenueAllocation(SetDividend.WITHHOLD);
}
- if (amount == 0 && operatingCompany.get().getNumberOfTrains() == 0) {
+ if (amount == 0 && operatingCompany.value().getNumberOfTrains() == 0) {
DisplayBuffer.add(LocalText.getText("RevenueWithNoTrains",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
Bank.format(0) ));
}
@@ -2237,8 +2237,8 @@ public class OperatingRound extends Round implements Observer {
int amount = action.getActualRevenue();
int revenueAllocation = action.getRevenueAllocation();
- operatingCompany.get().setLastRevenue(amount);
- operatingCompany.get().setLastRevenueAllocation(revenueAllocation);
+ operatingCompany.value().setLastRevenue(amount);
+ operatingCompany.value().setLastRevenueAllocation(revenueAllocation);
// Pay any debts from treasury, revenue and/or president's cash
// The remaining dividend may be less that the original income
@@ -2247,27 +2247,27 @@ public class OperatingRound extends Round implements Observer {
if (amount == 0) {
ReportBuffer.add(LocalText.getText("CompanyDoesNotPayDividend",
- operatingCompany.get().getId()));
+ operatingCompany.value().getId()));
withhold(amount);
} else if (revenueAllocation == SetDividend.PAYOUT) {
ReportBuffer.add(LocalText.getText("CompanyPaysOutFull",
- operatingCompany.get().getId(), Bank.format(amount) ));
+ operatingCompany.value().getId(), Bank.format(amount) ));
payout(amount);
} else if (revenueAllocation == SetDividend.SPLIT) {
ReportBuffer.add(LocalText.getText("CompanySplits",
- operatingCompany.get().getId(), Bank.format(amount) ));
+ operatingCompany.value().getId(), Bank.format(amount) ));
splitRevenue(amount);
} else if (revenueAllocation == SetDividend.WITHHOLD) {
ReportBuffer.add(LocalText.getText("CompanyWithholds",
- operatingCompany.get().getId(),
+ operatingCompany.value().getId(),
Bank.format(amount) ));
withhold(amount);
@@ -2275,7 +2275,7 @@ public class OperatingRound extends Round implements Observer {
}
// Rust any obsolete trains
- operatingCompany.get().getPortfolioModel().rustObsoleteTrains();
+ operatingCompany.value().getPortfolioModel().rustObsoleteTrains();
// We have done the payout step, so continue from there
nextStep(GameDef.OrStep.PAYOUT);
@@ -2303,17 +2303,17 @@ public class OperatingRound extends Round implements Observer {
if (recipient instanceof Bank) continue;
shares = (sharesPerRecipient.get(recipient));
if (shares == 0) continue;
- part = (int) Math.ceil(amount * shares * operatingCompany.get().getShareUnit() / 100.0);
+ part = (int) Math.ceil(amount * shares * operatingCompany.value().getShareUnit() / 100.0);
ReportBuffer.add(LocalText.getText("Payout",
...
[truncated message content] |