diff options
Diffstat (limited to 'core')
5 files changed, 31 insertions, 31 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index b069e89..ad8c37f 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -55,7 +55,7 @@ public class Ctrl implements Disposable this.hud = new Hud(this, game); - currentPlayer().turnStart(); + player().turnStart(); } @Override @@ -65,12 +65,12 @@ public class Ctrl implements Disposable map.dispose(); } - public Player currentPlayer() + public Player player() { return this.players[player]; } - public Player otherPlayer() + public Player opponent() { return this.players[((player + 1) % 2)]; } @@ -102,11 +102,26 @@ public class Ctrl implements Disposable private void nextPlayer() { - currentPlayer().turnEnd(); + player().turnEnd(); player = ((player + 1) % 2); - currentPlayer().turnStart(); - hud.updatePlayer(); + player().turnStart(); + hud.nextTurn(); + } + + private void checkTurnEnd() + { + if (map.activatedPawnsCount() > 0) { + player().burnDownOneAp(); + hud.update(); + } + if (player().apExhausted()) + nextPlayer(); + } + public void endPlayerTurn() + { + state.abort(); + nextPlayer(); } public void setState(State.StateType state) @@ -146,21 +161,6 @@ public class Ctrl implements Disposable this.state.enter(normal); } - private void checkTurnEnd() - { - if (map.activatedPawnsCount() > 0) { - currentPlayer().burnDownOneAp(); - } - if (currentPlayer().apExhausted()) - nextPlayer(); - } - - public void endTurn() - { - state.abort(); - nextPlayer(); - } - public void abort() { state.abort(); diff --git a/core/src/ch/asynk/tankontank/game/states/StateAttack.java b/core/src/ch/asynk/tankontank/game/states/StateAttack.java index d68afe0..ab37da9 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateAttack.java +++ b/core/src/ch/asynk/tankontank/game/states/StateAttack.java @@ -19,7 +19,7 @@ public class StateAttack extends StateCommon // use selectedHex and selectedPawn from.set(selectedHex); map.showPossibleTargets(false); - map.buildPossibleTargets(selectedPawn, from, ctrl.otherPlayer().unitIterator()); + map.buildPossibleTargets(selectedPawn, from, ctrl.opponent().unitIterator()); map.showPossibleTargets(true); if (to.x != -1) { // quick fire -> replay touchUp @@ -54,7 +54,7 @@ public class StateAttack extends StateCommon to.set(upHex); activePawn = map.getTopPawnAt(to); map.showTarget(to, true); - map.buildAttackAssists(selectedPawn, activePawn, to, ctrl.currentPlayer().unitIterator()); + map.buildAttackAssists(selectedPawn, activePawn, to, ctrl.player().unitIterator()); map.showAttackAssists(true); ctrl.hud.show(false, false, false, true, true, ctrl.cfg.canCancel); } @@ -79,11 +79,11 @@ public class StateAttack extends StateCommon @Override public void done() { - int d1 = ctrl.currentPlayer().d6(); - int d2 = ctrl.currentPlayer().d6(); + int d1 = ctrl.player().d6(); + int d2 = ctrl.player().d6(); System.err.print(" attack (" + from.x + ";" + from.y + ") -> (" + to.x + ";" + to.y + ") : 2D6 -> (" + d1 + " + " + d2 + ")"); if (map.attackPawn(selectedPawn, activePawn, from, to, d1 + d2)) - ctrl.currentPlayer().casualty(activePawn); + ctrl.player().casualty(activePawn); ctrl.setState(StateType.ANIMATION); super.done(); diff --git a/core/src/ch/asynk/tankontank/game/states/StateCommon.java b/core/src/ch/asynk/tankontank/game/states/StateCommon.java index 9a647d4..416dfaf 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateCommon.java +++ b/core/src/ch/asynk/tankontank/game/states/StateCommon.java @@ -110,7 +110,7 @@ public abstract class StateCommon implements State selectedPawn = map.getTopPawnAt(selectedHex); map.selectHex(selectedHex, true); if (selectedPawn != null) - isEnemy = ctrl.currentPlayer().isEnemy(selectedPawn); + isEnemy = ctrl.player().isEnemy(selectedPawn); else isEnemy = false; System.err.println(" select (" + selectedHex.x + ";" + selectedHex.y + ") " + selectedPawn + (isEnemy ? " enemy " : " friend ")); diff --git a/core/src/ch/asynk/tankontank/game/states/StatePromote.java b/core/src/ch/asynk/tankontank/game/states/StatePromote.java index cb86fd9..b481eee 100644 --- a/core/src/ch/asynk/tankontank/game/states/StatePromote.java +++ b/core/src/ch/asynk/tankontank/game/states/StatePromote.java @@ -9,7 +9,7 @@ public class StatePromote extends StateCommon public void enter(boolean flag) { ctrl.hud.hide(); - Pawn p = ctrl.currentPlayer().promote(selectedPawn); + Pawn p = ctrl.player().promote(selectedPawn); if (p != null) { map.promote(selectedPawn, p); } diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java index 7db0c2d..a06a6c0 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java +++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java @@ -55,13 +55,13 @@ public class StateSelect extends StateCommon int moves = map.buildPossibleMoves(selectedPawn, selectedHex); int targets = 0; if (isEnemy) - targets = map.buildPossibleTargets(selectedPawn, selectedHex, ctrl.currentPlayer().unitIterator()); + targets = map.buildPossibleTargets(selectedPawn, selectedHex, ctrl.player().unitIterator()); else - targets = map.buildPossibleTargets(selectedPawn, selectedHex, ctrl.otherPlayer().unitIterator()); + targets = map.buildPossibleTargets(selectedPawn, selectedHex, ctrl.opponent().unitIterator()); int assists = map.buildMoveAssists(selectedPawn, selectedHex); showPossibleTargetsMovesAssists(selectedPawn); ctrl.hud.show( - ctrl.currentPlayer().canPromote(selectedPawn), + ctrl.player().canPromote(selectedPawn), selectedPawn.canMove(), (selectedPawn.canMove() && (moves > 0)), (selectedPawn.canAttack() && (targets > 0)), |