diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-04-13 23:44:53 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-04-13 23:48:54 +0200 |
commit | 95d0131cb9733d273b81bf63a8778dc2b8e0a414 (patch) | |
tree | be0bca04dc39f66ce1ffbeb5f22e191123e5facf /core/src/ch/asynk/rustanddust/game/Order.java | |
parent | 513938e9b1731308535ef45336239f9209e2e396 (diff) | |
download | RustAndDust-keep.zip RustAndDust-keep.tar.gz |
WIPkeep
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game/Order.java')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/Order.java | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Order.java b/core/src/ch/asynk/rustanddust/game/Order.java index aac0825..96b2bb7 100644 --- a/core/src/ch/asynk/rustanddust/game/Order.java +++ b/core/src/ch/asynk/rustanddust/game/Order.java @@ -7,12 +7,17 @@ import ch.asynk.rustanddust.engine.Move; public class Order implements Disposable, Pool.Poolable, Comparable<Unit> { + public static int orderId = 1; + + public static final Order END = new Order(OrderType.END); + public enum OrderType { NONE, MOVE, ENGAGE, - PROMOTE; + PROMOTE, + END, } private static final Pool<Order> orderPool = new Pool<Order>() @@ -36,6 +41,7 @@ public class Order implements Disposable, Pool.Poolable, Comparable<Unit> public int id; public int cost; + public boolean replay; public Unit unit; public OrderType type; public Move move; @@ -47,6 +53,12 @@ public class Order implements Disposable, Pool.Poolable, Comparable<Unit> reset(); } + private Order(OrderType type) + { + this(); + this.type = type; + } + @Override public void dispose() { @@ -56,8 +68,12 @@ public class Order implements Disposable, Pool.Poolable, Comparable<Unit> @Override public void reset() { - this.type = OrderType.NONE; + this.id = orderId; + orderId += 1; + this.cost = 1; + this.replay = false; this.unit = null; + this.type = OrderType.NONE; this.activable.clear(); if (this.move != null) { this.move.dispose(); @@ -85,27 +101,30 @@ public class Order implements Disposable, Pool.Poolable, Comparable<Unit> @Override public String toString() { - return String.format("[%d] %s : %s", id, type, unit.code); + if (type == OrderType.END) + return String.format("[00] END"); + else + return String.format("[%d] %s(%d) : %s", id, type, cost, unit.code); } public void setMove(Unit unit, Move move) { + this.unit = unit; this.type = OrderType.MOVE; this.move = move; - this.unit = unit; } public void setPromote(Unit unit) { - this.type = OrderType.PROMOTE; this.unit = unit; + this.type = OrderType.PROMOTE; } public void setEngage(Unit unit, Unit target) { + this.unit = unit; this.type = OrderType.ENGAGE; this.engagement = Engagement.get(unit, target); - this.unit = unit; } public void setActivable(UnitList l) |