summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Battle.java8
-rw-r--r--core/src/ch/asynk/rustanddust/game/Ctrl.java3
-rw-r--r--core/src/ch/asynk/rustanddust/game/battles/Battle00.java16
-rw-r--r--core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java48
-rw-r--r--core/src/ch/asynk/rustanddust/game/battles/BattleTest.java16
-rw-r--r--core/src/ch/asynk/rustanddust/game/ctrl/Solo.java6
6 files changed, 54 insertions, 43 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Battle.java b/core/src/ch/asynk/rustanddust/game/Battle.java
index 84a8e78..c8063d1 100644
--- a/core/src/ch/asynk/rustanddust/game/Battle.java
+++ b/core/src/ch/asynk/rustanddust/game/Battle.java
@@ -21,9 +21,11 @@ public interface Battle
public Player getOpponent();
- public void init(Ctrl ctrl, int idA, int idB);
+ public void init();
- public void init(Ctrl ctrl, String payload);
+ public void desinit();
+
+ public void initialDeployment();
public boolean actionDone();
@@ -35,5 +37,7 @@ public interface Battle
public State.StateType getState();
+ public void load(String payload);
+
public String unload(boolean full);
}
diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java
index 4a4c4f6..81ac268 100644
--- a/core/src/ch/asynk/rustanddust/game/Ctrl.java
+++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java
@@ -86,6 +86,8 @@ public abstract class Ctrl implements Disposable
this.state = selectState;
this.stateType = StateType.DONE;
+ battle.init();
+ this.map = battle.getMap();
init();
StateCommon.set(game);
hud.update();
@@ -99,6 +101,7 @@ public abstract class Ctrl implements Disposable
{
hud.dispose();
map.dispose();
+ battle.desinit();
}
// INPUTS
diff --git a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java
index c3ea89f..949ca04 100644
--- a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java
+++ b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java
@@ -25,13 +25,6 @@ public class Battle00 extends BattleCommon
}
@Override
- protected void setPlayers()
- {
- players[0] = factory.getPlayer(Army.US);
- players[1] = factory.getPlayer(Army.GE);
- }
-
- @Override
public Position getHudPosition()
{
return (currentPlayer.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT);
@@ -49,15 +42,20 @@ public class Battle00 extends BattleCommon
return false;
}
+ // SETUP
+
@Override
- protected void setupMap()
+ protected void setup()
{
+ players[0] = factory.getPlayer(Army.US);
+ players[1] = factory.getPlayer(Army.GE);
+
map.addHoldObjective(5, 2, Army.NONE);
map.addObjective(11, 7, Army.US);
}
@Override
- protected void setupPlayer()
+ protected void deployPlayer()
{
if (currentPlayer.army == Army.US)
setupUS(currentPlayer);
diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
index 0e6b00b..4a705ed 100644
--- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
+++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
@@ -30,9 +30,8 @@ public abstract class BattleCommon implements Battle
protected Player[] players;
protected abstract Player getWinner();
- protected abstract void setupMap();
- protected abstract void setupPlayer();
- protected abstract void setPlayers();
+ protected abstract void setup();
+ protected abstract void deployPlayer();
private int d6()
{
@@ -56,12 +55,6 @@ public abstract class BattleCommon implements Battle
this.players = new Player[2];
}
- @Override
- public String unload(boolean full)
- {
- return map.unload(full, getPlayer(), getOpponent());
- }
-
@Override public int getId() { return _id; }
@Override public String toString() { return getName(); }
@Override public String getName() { return name; }
@@ -70,21 +63,31 @@ public abstract class BattleCommon implements Battle
@Override public Factory.MapType getMapType() { return mapType; }
@Override
- public void init(Ctrl ctrl, int idA, int idB)
+ public void init()
{
- ctrl.map = this.map = factory.getMap(getMapType());
- setPlayers();
- players[0].id = idA;
- players[1].id = idB;
+ this.map = factory.getMap(getMapType());
+ setup();
+ this.currentPlayer = players[0];
+ }
- setupMap();
+ @Override
+ public void desinit()
+ {
+ this.map = null;
+ this.players[0] = null;
+ this.players[1] = null;
+ this.currentPlayer = null;
+ }
+ @Override
+ public void initialDeployment()
+ {
this.currentPlayer = players[0];
- setupPlayer();
+ deployPlayer();
currentPlayer.turnEnd();
this.currentPlayer = players[1];
- setupPlayer();
+ deployPlayer();
currentPlayer.turnEnd();
this.currentPlayer = players[0];
@@ -92,12 +95,15 @@ public abstract class BattleCommon implements Battle
}
@Override
- public void init(Ctrl ctrl, String payload)
+ public void load(String payload)
{
- ctrl.map = this.map = factory.getMap(getMapType());
- setupMap();
map.load(payload, players);
- currentPlayer = players[0];
+ }
+
+ @Override
+ public String unload(boolean full)
+ {
+ return map.unload(full, getPlayer(), getOpponent());
}
@Override
diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java
index 8255722..d66dae6 100644
--- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java
+++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java
@@ -22,13 +22,6 @@ public class BattleTest extends BattleCommon
}
@Override
- protected void setPlayers()
- {
- players[0] = factory.getPlayer(Army.GE);
- players[1] = factory.getPlayer(Army.US);
- }
-
- @Override
public Position getHudPosition()
{
return (currentPlayer.is(Army.US) ? Position.TOP_RIGHT: Position.TOP_LEFT);
@@ -57,9 +50,14 @@ public class BattleTest extends BattleCommon
return true;
}
+ // SETUP
+
@Override
- protected void setupMap()
+ protected void setup()
{
+ players[0] = factory.getPlayer(Army.GE);
+ players[1] = factory.getPlayer(Army.US);
+
map.addObjective(5, 2, Army.NONE);
map.addHoldObjective(5, 3, Army.NONE);
map.addObjective(3, 4, Army.NONE);
@@ -67,7 +65,7 @@ public class BattleTest extends BattleCommon
}
@Override
- protected void setupPlayer()
+ protected void deployPlayer()
{
if (currentPlayer.army == Army.US)
setupUS(currentPlayer);
diff --git a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java
index f7d5540..bd9f74c 100644
--- a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java
+++ b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java
@@ -21,9 +21,11 @@ public class Solo extends Ctrl
int me = game.backend.getMyId();
int other = game.backend.getOpponentId();
gameId = game.db.storeGameGetId(me, other, battle.getId(), game.config.gameMode.i);
- battle.init(this, me, other);
+ battle.getPlayer().id = me;
+ battle.getOpponent().id = other;
+ battle.initialDeployment();
} else {
- battle.init(this, game.db.loadState(gameId));
+ battle.load(game.db.loadState(gameId));
}
}