summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-24 23:54:28 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-24 23:54:28 +0100
commitd47b75d0c079583224846a7903328c860b95e36b (patch)
tree94b272fbd12e5b8b8b3b636a1296e252489763d0 /core/src
parent5d0f17b24691308cadeacd2d86774c5b3c8cb7c8 (diff)
downloadRustAndDust-d47b75d0c079583224846a7903328c860b95e36b.zip
RustAndDust-d47b75d0c079583224846a7903328c860b95e36b.tar.gz
Order,OrderList: this.player goes from Order to OrderList
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Order.java10
-rw-r--r--core/src/ch/asynk/rustanddust/game/OrderList.java10
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map4Orders.java14
3 files changed, 17 insertions, 17 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Order.java b/core/src/ch/asynk/rustanddust/game/Order.java
index 07fa19c..552b647 100644
--- a/core/src/ch/asynk/rustanddust/game/Order.java
+++ b/core/src/ch/asynk/rustanddust/game/Order.java
@@ -33,15 +33,13 @@ public class Order implements Disposable, Pool.Poolable, Json.Serializable, Comp
orderPool.clear();
}
- public static Order get(Player player)
+ public static Order get()
{
Order c = orderPool.obtain();
- c.player = player;
return c;
}
public OrderType type;
- public Player player;
public Unit unit;
public Unit.UnitId unitId;
public Unit.UnitType unitType;
@@ -64,7 +62,6 @@ public class Order implements Disposable, Pool.Poolable, Json.Serializable, Comp
public void reset()
{
this.type = OrderType.NONE;
- this.player = null;
this.unit = null;
if (this.move != null) {
this.move.dispose();
@@ -127,11 +124,6 @@ public class Order implements Disposable, Pool.Poolable, Json.Serializable, Comp
public void write(Json json)
{
json.writeValue("type", type);
- json.writeObjectStart("player");
- json.writeValue("army", player.getName());
- json.writeValue("turn", player.getCurrentTurn());
- json.writeValue("aps", player.getAp());
- json.writeObjectEnd();
json.writeObjectStart("unit");
json.writeValue("id", unitId);
json.writeValue("type", unitType);
diff --git a/core/src/ch/asynk/rustanddust/game/OrderList.java b/core/src/ch/asynk/rustanddust/game/OrderList.java
index d6c5b5f..968aeda 100644
--- a/core/src/ch/asynk/rustanddust/game/OrderList.java
+++ b/core/src/ch/asynk/rustanddust/game/OrderList.java
@@ -10,6 +10,8 @@ import ch.asynk.rustanddust.engine.util.IterableArray;
public class OrderList extends IterableArray<Order> implements Json.Serializable
{
+ private Player player;
+
public OrderList(int capacity)
{
super(capacity);
@@ -55,8 +57,9 @@ public class OrderList extends IterableArray<Order> implements Json.Serializable
clear();
}
- public String toJson()
+ public String toJson(final Player player)
{
+ this.player = player;
Json json = new Json();
json.setOutputType(OutputType.json);
return json.toJson(this);
@@ -65,6 +68,11 @@ public class OrderList extends IterableArray<Order> implements Json.Serializable
@Override
public void write(Json json)
{
+ json.writeObjectStart("player");
+ json.writeValue("army", player.getName());
+ json.writeValue("turn", player.getCurrentTurn());
+ json.writeValue("aps", player.getAp());
+ json.writeObjectEnd();
json.writeArrayStart("commands");
for (Order o : this)
json.writeValue(o);
diff --git a/core/src/ch/asynk/rustanddust/game/map/Map4Orders.java b/core/src/ch/asynk/rustanddust/game/map/Map4Orders.java
index 3aa0bbf..5a1f553 100644
--- a/core/src/ch/asynk/rustanddust/game/map/Map4Orders.java
+++ b/core/src/ch/asynk/rustanddust/game/map/Map4Orders.java
@@ -99,14 +99,14 @@ public abstract class Map4Orders extends Map3Animations
{
attack(unit, target, true);
- Order cmd = Order.get(battle.getPlayer());
+ Order cmd = Order.get();
cmd.setEngage(unit, target);
return (process(cmd) == 1);
}
public void promoteUnit(final Unit unit)
{
- Order cmd = Order.get(battle.getPlayer());
+ Order cmd = Order.get();
cmd.setPromote(unit);
process(cmd);
}
@@ -115,7 +115,7 @@ public abstract class Map4Orders extends Map3Animations
private Order getMoveOrder(Unit unit, Move move)
{
- Order cmd = Order.get(battle.getPlayer());
+ Order cmd = Order.get();
cmd.setMove(unit, move);
return cmd;
}
@@ -127,13 +127,13 @@ public abstract class Map4Orders extends Map3Animations
playMoveSound(unit);
}
- private int promoteUnit(final Unit unit, final Player player)
+ private int doPromoteUnit(final Unit unit)
{
activatedUnits.add(unit);
- addPromoteAnimation(unit, player, new Runnable() {
+ addPromoteAnimation(unit, battle.getPlayer(), new Runnable() {
@Override
public void run() {
- player.promote(unit);
+ battle.getPlayer().promote(unit);
}
});
return 1;
@@ -150,7 +150,7 @@ public abstract class Map4Orders extends Map3Animations
r = process(cmd.unit, cmd.move);
break;
case PROMOTE:
- r = promoteUnit(cmd.unit, cmd.player);
+ r = doPromoteUnit(cmd.unit);
break;
case ENGAGE:
r = doEngagement(cmd.engagement);