diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 43 |
2 files changed, 16 insertions, 29 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 764fccd..b307ee7 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -446,7 +446,7 @@ public abstract class Board implements Disposable, Animation protected void enterPawn(final Pawn pawn, Move move) { - pawn.enter(move); + pawn.move(move); setPawnOnto(pawn, move.to, move.orientation); } diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index b471406..3209cc1 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -104,41 +104,28 @@ public abstract class Pawn implements Moveable, Disposable public void reset() { + move = null; attack.reset(); - if (move != null) { - move.dispose(); - move = null; - } } public void move(Move move) { - if (move.isEnter()) - throw new RuntimeException("wrong MoveType"); - - if (this.move != null) { - if (this.move.isEnter()) - this.move.dispose(); - else - throw new RuntimeException("try to override an existing move instance"); + switch(move.type) + { + case REGULAR: + if ((this.move != null) && (!this.move.isEnter())) + throw new RuntimeException("try to override an existing move instance"); + break; + case ENTER: + if (this.move != null) + throw new RuntimeException("try to override an existing move instance"); + break; + case SET: + break; + default: + throw new RuntimeException("unsupported MoveType"); } - setMove(move); - } - - public void enter(Move move) - { - if (!move.isEnter()) - throw new RuntimeException("wrong MoveType"); - - if (this.move != null) - throw new RuntimeException("try to override an existing move instance"); - - setMove(move); - } - - private void setMove(Move move) - { this.move = move; move(); } |