diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-18 16:49:51 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-18 16:49:51 +0100 |
commit | b66b04cbbd0ce67f8d7fb8aa588807ea93b1295f (patch) | |
tree | 622dfd57ae9b8bd5e353b7cf8ef1f302204d73fe /core/src/ch | |
parent | ef47f56db6871f5b5b84dc5123d8fad4a5173975 (diff) | |
download | RustAndDust-b66b04cbbd0ce67f8d7fb8aa588807ea93b1295f.zip RustAndDust-b66b04cbbd0ce67f8d7fb8aa588807ea93b1295f.tar.gz |
add game.Command extends engine.Order
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Command.java | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Command.java b/core/src/ch/asynk/tankontank/game/Command.java new file mode 100644 index 0000000..903c18b --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/Command.java @@ -0,0 +1,88 @@ +package ch.asynk.tankontank.game; + +import com.badlogic.gdx.utils.Pool; +import com.badlogic.gdx.utils.Json; +import com.badlogic.gdx.utils.JsonValue; + +import ch.asynk.tankontank.engine.Order; +import ch.asynk.tankontank.engine.Move; + +public class Command extends Order +{ + public enum CommandType + { + NONE, + MOVE, + ENGAGE, + PROMOTE, + END_OF_TURN; + } + + private static final Pool<Command> orderPool = new Pool<Command>() + { + @Override + protected Command newObject() { + return new Command(); + } + }; + + public static Command get(Player player) + { + Command c = orderPool.obtain(); + c.player = player; + return c; + } + + public CommandType type; + public Player player; + public Unit unit; + public Move move; + + private Command() + { + reset(); + } + + @Override + public void dispose() + { + orderPool.free(this); + } + + @Override + public void reset() + { + this.type = CommandType.NONE; + this.player = null; + this.unit = null; + if (this.move != null) { + this.move.dispose(); + this.move = null; + } + } + + @Override + public String toString() + { + return String.format("%s %s : ", type, unit.id); + } + + public void setMove(Unit unit, Move move) + { + this.type = CommandType.MOVE; + this.unit = unit; + this.move = move; + } + + @Override + public void write(Json json) + { + // FIXME Command.write(Json); + } + + @Override + public void read(Json json, JsonValue jsonMap) + { + // FIXME Command.read(Json, JsonValue); + } +} |