diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-20 15:29:58 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-20 15:29:58 +0100 |
commit | 29044f762ade5424bdef22b8757bf50a8d3e4f85 (patch) | |
tree | 8b862e1e2c62973e2ee29fd7eb23e04237d9b1c3 /core/src/ch/asynk/tankontank | |
parent | 10311c96e531df6869f78fe9c9c92052798f8753 (diff) | |
download | RustAndDust-29044f762ade5424bdef22b8757bf50a8d3e4f85.zip RustAndDust-29044f762ade5424bdef22b8757bf50a8d3e4f85.tar.gz |
Command: register unit, AP and turn info at Command creation
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Command.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Command.java b/core/src/ch/asynk/tankontank/game/Command.java index 0d39e6c..b942b4b 100644 --- a/core/src/ch/asynk/tankontank/game/Command.java +++ b/core/src/ch/asynk/tankontank/game/Command.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.utils.JsonValue; import ch.asynk.tankontank.engine.Order; import ch.asynk.tankontank.engine.Move; import ch.asynk.tankontank.engine.Pawn; +import ch.asynk.tankontank.engine.Tile; public class Command extends Order { @@ -36,12 +37,19 @@ public class Command extends Order { Command c = commandPool.obtain(); c.player = player; + c.ap = player.getAp(); + c.turn = player.getCurrentTurn(); return c; } public CommandType type; public Player player; + public int ap; + public int turn; public Unit unit; + public Unit.UnitId unitId; + public Unit.UnitType unitType; + public Tile unitTile; public Move move; public Engagement engagement; @@ -95,21 +103,29 @@ public class Command extends Order public void setMove(Unit unit, Move move) { this.type = CommandType.MOVE; - this.unit = unit; this.move = move; + setUnit(unit); } public void setPromote(Unit unit) { this.type = CommandType.PROMOTE; - this.unit = unit; + setUnit(unit); } public void setEngage(Unit unit, Unit target) { this.type = CommandType.ENGAGE; - this.unit = unit; this.engagement = Engagement.get(unit, target); + setUnit(unit); + } + + private void setUnit(Unit unit) + { + this.unit = unit; + this.unitId = unit.id; + this.unitType = unit.type; + this.unitTile = unit.getTile(); } @Override |