|
From: Erik V. <ev...@us...> - 2011-12-08 09:31:21
|
data/1889/CompanyManager.xml | 2
rails/game/specific/_1889/OperatingRound_1889.java | 84 +++++++++++----------
2 files changed, 46 insertions(+), 40 deletions(-)
New commits:
commit 34d72d6fa2232eda46e9545b6f2decfb0038fff0
Author: Erik Vos <eri...@xs...>
Date: Thu Dec 8 10:29:57 2011 +0100
Applied new special tile lay validations to 1889.
diff --git a/data/1889/CompanyManager.xml b/data/1889/CompanyManager.xml
index 83dd566..90af34a 100644
--- a/data/1889/CompanyManager.xml
+++ b/data/1889/CompanyManager.xml
@@ -63,7 +63,7 @@
<SpecialProperties>
<!-- Timing of special property is done in OperatingRound_1889, coded against name "C" -->
<SpecialProperty condition="specific" when="tileLayingStep" class="rails.game.special.SpecialTileLay">
- <SpecialTileLay location="C4" extra="yes" free="yes"/>
+ <SpecialTileLay location="C4" colour="green" extra="yes" free="yes"/>
</SpecialProperty>
</SpecialProperties>
</Company>
diff --git a/rails/game/specific/_1889/OperatingRound_1889.java b/rails/game/specific/_1889/OperatingRound_1889.java
index 8ed363c..12d82bc 100644
--- a/rails/game/specific/_1889/OperatingRound_1889.java
+++ b/rails/game/specific/_1889/OperatingRound_1889.java
@@ -6,8 +6,9 @@ import rails.common.LocalText;
import rails.common.parser.GameOption;
import rails.game.*;
import rails.game.action.*;
-import rails.game.special.*;
-import rails.game.state.*;
+import rails.game.special.SpecialPropertyI;
+import rails.game.special.SpecialTileLay;
+import rails.game.state.BooleanState;
/**
* Adds specific code for 1889 to allow the special timing of the special tile laying private companies
@@ -16,14 +17,14 @@ public class OperatingRound_1889 extends OperatingRound {
private PrivateCompanyI privB;
private BooleanState activeSpPrivB;
-
+
private PrivateCompanyI privC;
private BooleanState activeSpPrivC;
private GameDef.OrStep storeActiveStep;
- private String previousOwnerName;
-
+ private String previousOwnerName;
+
private boolean beginnerGame;
-
+
/**
* Instantiates a new operating round_1889.
*
@@ -31,33 +32,35 @@ public class OperatingRound_1889 extends OperatingRound {
*/
public OperatingRound_1889 (GameManagerI gameManager) {
super (gameManager);
-
+
privB = companyManager.getPrivateCompany("B");
activeSpPrivB = new BooleanState("ActiveSpPrivB", false);
-
+
privC = companyManager.getPrivateCompany("C");
activeSpPrivC = new BooleanState("ActiveSpPrivC", false);
-
+
beginnerGame = GameOption.convertValueToBoolean(getGameOption("BeginnerGame"));
}
-
+
@Override
protected void setGameSpecificPossibleActions() {
-
+
// noMapMode and beginnerGame are not effected
if (noMapMode || beginnerGame) return;
-
+
// private B: lay track at other company tile laying steps
if (getStep() == GameDef.OrStep.LAY_TRACK) {
- if (!privB.isClosed() &&
- privB.getPortfolio().getOwner() instanceof Player &&
+ if (!privB.isClosed() &&
+ privB.getPortfolio().getOwner() instanceof Player &&
privB.getPortfolio().getOwner() != operatingCompany.get().getPresident()) {
SpecialPropertyI spPrivB = privB.getSpecialProperties().get(0);
- if (spPrivB != null && !spPrivB.isExercised()) {
- if (!activeSpPrivB.booleanValue())
+ LayTile layTile = new LayTile((SpecialTileLay)spPrivB);
+ if (spPrivB != null && !spPrivB.isExercised()
+ && validateSpecialTileLay(layTile)) {
+ if (!activeSpPrivB.booleanValue())
possibleActions.add(new UseSpecialProperty(spPrivB));
else {
- possibleActions.add(new LayTile((SpecialTileLay)spPrivB));
+ possibleActions.add(layTile);
DisplayBuffer.add(LocalText.getText("1889PrivateBactive", privB.getPortfolio().getOwner()));
}
}
@@ -65,21 +68,24 @@ public class OperatingRound_1889 extends OperatingRound {
} else {
activeSpPrivB.set(false);
}
-
+
// private C: trigger by purchase of private -- see below
if (activeSpPrivC.booleanValue()) {
- possibleActions.clear();
SpecialTileLay spPrivC = (SpecialTileLay)privC.getSpecialProperties().get(0);
- possibleActions.add(new LayTile(spPrivC));
- possibleActions.add(new NullAction(NullAction.SKIP));
- DisplayBuffer.add(LocalText.getText("1889PrivateCactive", previousOwnerName));
+ LayTile layTile = new LayTile(spPrivC);
+ if (validateSpecialTileLay(layTile)) {
+ possibleActions.clear();
+ possibleActions.add(new LayTile(spPrivC));
+ possibleActions.add(new NullAction(NullAction.SKIP));
+ DisplayBuffer.add(LocalText.getText("1889PrivateCactive", previousOwnerName));
+ }
}
-
+
}
-
+
@Override
public boolean processGameSpecificAction(PossibleAction action) {
-
+
// private B
if (action instanceof UseSpecialProperty) {
UseSpecialProperty spAction=(UseSpecialProperty)action;
@@ -92,30 +98,30 @@ public class OperatingRound_1889 extends OperatingRound {
}
return false;
}
-
-
+
+
@Override
public boolean buyPrivate(BuyPrivate action){
- // store the seller name, playername in action is the owner of the buying company!
- String sellerName = action.getPrivateCompany().getPortfolio().getOwner().getName();
-
- boolean result = super.buyPrivate(action);
-
- if (!(noMapMode || beginnerGame) && result && (action.getPrivateCompany() == privC)) {
- // moveStack identical to buy private action
+ // store the seller name, playername in action is the owner of the buying company!
+ String sellerName = action.getPrivateCompany().getPortfolio().getOwner().getName();
+
+ boolean result = super.buyPrivate(action);
+
+ if (!(noMapMode || beginnerGame) && result && (action.getPrivateCompany() == privC)) {
+ // moveStack identical to buy private action
activeSpPrivC.set(true);
previousOwnerName = sellerName;
log.debug("1889 specific: Activates tile laying step for C after purchase of C");
storeActiveStep = getStep();
stepObject.set(GameDef.OrStep.LAY_TRACK);
}
- return result;
+ return result;
}
-
+
@Override
public boolean layTile(LayTile action) {
-
+
boolean result = super.layTile(action);
if (result && activeSpPrivC.booleanValue()) {
@@ -126,7 +132,7 @@ public class OperatingRound_1889 extends OperatingRound {
}
return(result);
}
-
+
@Override
public void skip() {
if (activeSpPrivC.booleanValue()) {
@@ -138,7 +144,7 @@ public class OperatingRound_1889 extends OperatingRound {
super.skip();
}
}
-
+
}
|