Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

assumes a "*" for prior if there was a build prior in the turn.

  • Loading branch information...
commit 73b322f38527bdee21b2c40069ca7b434711d586 1 parent 46af748
@philihp authored
View
23 src/main/java/com/philihp/weblabora/model/CommandParameters.java
@@ -13,16 +13,22 @@
/**
* Everything in the middle
*/
- private List<String> params = new ArrayList<String>(2); //default it to an capacity of 2, since that's what it usually is
+ private List<String> params = new ArrayList<String>(2); // default it to an
+ // capacity of 2,
+ // since that's what
+ // it usually is
/**
* The last token.
*/
private String suffix;
-
+
private boolean placeClergyman;
- public CommandParameters() {
+ private boolean mustBePrior;
+
+ public CommandParameters(boolean mustBePrior) {
+ this.mustBePrior = mustBePrior;
}
public char getCommand() {
@@ -48,11 +54,11 @@ public String getSuffix() {
public void setSuffix(String suffix) {
this.suffix = suffix;
}
-
+
public String get(int i) {
return params.get(i);
}
-
+
public int size() {
return params.size();
}
@@ -60,8 +66,13 @@ public int size() {
public void setPlaceClergyman(boolean placeClergyman) {
this.placeClergyman = placeClergyman;
}
-
+
public boolean getPlaceClergyman() {
return this.placeClergyman;
}
+
+ public boolean isMustBePrior() {
+ return mustBePrior;
+ }
+
}
View
2  src/main/java/com/philihp/weblabora/model/CommandUse.java
@@ -17,7 +17,7 @@ public void execute(Board board, CommandParameters params)
String buildingId = params.get(0);
UsageParam usageParam = null;
- boolean usingPrior = params.getSuffix().contains("*");
+ boolean usingPrior = params.getSuffix().contains("*") || params.isMustBePrior();
if(params.size() == 1) {
usageParam = new UsageParamSingle("");
View
11 src/main/java/com/philihp/weblabora/model/MoveHistory.java
@@ -3,6 +3,7 @@
public class MoveHistory {
private boolean previousUse = false;
private boolean settling;
+ private boolean previousBuild = false;
public MoveHistory(boolean settling) {
this.settling = settling;
@@ -12,8 +13,12 @@ public boolean isSettling() {
return settling;
}
- public String toString() {
- return "{previousUse=" + previousUse + "}";
+ public boolean isPreviousBuild() {
+ return previousBuild;
+ }
+
+ public void setPreviousBuild(boolean previousBuild) {
+ this.previousBuild = this.previousBuild || previousBuild;
}
public boolean isPreviousUse() {
@@ -21,6 +26,6 @@ public boolean isPreviousUse() {
}
public void setPreviousUse(boolean isPreviousUse) {
- this.previousUse = isPreviousUse;
+ this.previousUse = this.previousUse || isPreviousUse;
}
}
View
7 src/main/java/com/philihp/weblabora/model/MoveProcessor.java
@@ -22,8 +22,6 @@ public static void processMoves(Board board, Iterable<String> allMoves) throws W
board.preMove(move);
processActions(board,move);
board.postMove();
- System.out.println("Testing Validity");
- board.testValidity();
}
}
@@ -39,7 +37,7 @@ public static void processActions(Board board, String actions)
public static void processSingleAction(Board board, String move, MoveHistory history)
throws WeblaboraException {
- CommandParameters params = new CommandParameters();
+ CommandParameters params = new CommandParameters(history.isPreviousBuild());
String prefix = move.substring(0, move.indexOf('('));
String inner = move.substring(move.indexOf('(')+1, move.indexOf(')'));
@@ -62,7 +60,8 @@ public static void processSingleAction(Board board, String move, MoveHistory his
MoveCommand moveCommand = pickCommand(params.getCommand(), history);
moveCommand.execute(board, params);
- history.setPreviousUse(moveCommand instanceof CommandUse);
+ history.setPreviousUse(moveCommand instanceof CommandUse);
+ history.setPreviousBuild(moveCommand instanceof CommandBuild);
}
public static MoveCommand pickCommand(char commandChar, MoveHistory history) throws WeblaboraException {
Please sign in to comment.
Something went wrong with that request. Please try again.