diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-18 21:03:47 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-18 21:03:47 +0100 |
commit | 13bac1f16fb2706320943a397bdd2ffdf9aaba71 (patch) | |
tree | dc3558834b3e7c3458754758e456b3386d535d34 /core/src/ch/asynk/tankontank | |
parent | 9b79116e69a318f0cf45f2d69d2f505a8dbb4835 (diff) | |
download | RustAndDust-13bac1f16fb2706320943a397bdd2ffdf9aaba71.zip RustAndDust-13bac1f16fb2706320943a397bdd2ffdf9aaba71.tar.gz |
Pawn: use move(Move) only, do not dispose of Move, it is owned by Command
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-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(); } |