+ private int castlePosition;
+ public int getCastlePosition() { return castlePosition; }
+ public void setCastlePosition(int pos) { castlePosition = pos; }
+
+ private int multiplier;
+ public int getMultiplier() { return multiplier; }
+ public void setMultiplier(int m) { multiplier = m; }
+
+ class FailedToThrowStonesAndShouldHave extends Exception {}
+ class ThrewMoreStonesThanHad extends Exception {}
+
+ private int stones;
+ public int getStones() { return stones; }
+ public void consumeStones(int n)
+ throws ThrewMoreStonesThanHad,
+ FailedToThrowStonesAndShouldHave
+ {
+ if (n > stones) {
+ throw new ThrewMoreStonesThanHad();
+ }
+ if (n == 0 && stones > 0) {
+ throw new FailedToThrowStonesAndShouldHave();
+ }
+ setStones(stones - n);
+ }
+ public int consumeMaxStones() {
+ int r = stones;
+ stones = 0;
+ return r;
+ }
+ public int consumeMinStones() {
+ if (stones < 1) {
+ throw new Error("Internal error: tried to consume min stones on an empty heap.");
+ }
+ stones--;
+ return 1;
+ }
+ public void setStones(int n) {
+ stones = n;
+ }
+ public int getOppStones() {
+ return p0.stones + p1.stones - stones;
+ }
+
+ public void adjustScore(int trollPosition) {
+ if (gp.isActive()) {
+ gp.setScore(Math.abs(castlePosition - trollPosition));
+ }
+ }
+
+ public int getTrollDistance() {
+ return Math.abs(castlePosition - trollPosition);
+ }
+ }
+
+ void init() {
+ seed = gameManager.getSeed();