summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-01 19:34:18 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-01 19:34:18 +0100
commitfc1d6b90a218fd7072206e6e693e8cd8ac105e2f (patch)
treea8725e93da8bdbceb92e66b8c6aa01fc8b086333 /core/src/ch/asynk/tankontank
parent4f0fa554282cb32d1b46356acd0a0daeda91c705 (diff)
downloadRustAndDust-fc1d6b90a218fd7072206e6e693e8cd8ac105e2f.zip
RustAndDust-fc1d6b90a218fd7072206e6e693e8cd8ac105e2f.tar.gz
Battle: add public boolean checkVictory(Ctrl ctrl); and implement it
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/game/Battle.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/Ctrl.java3
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleFake.java30
3 files changed, 34 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Battle.java b/core/src/ch/asynk/tankontank/game/Battle.java
index 2f13108..e59db41 100644
--- a/core/src/ch/asynk/tankontank/game/Battle.java
+++ b/core/src/ch/asynk/tankontank/game/Battle.java
@@ -14,5 +14,5 @@ public interface Battle
public void setup(Map map, Player firstPlayer, Player secondPlayer);
- // public boolean checkVictory(Map map, Player player);
+ public boolean checkVictory(Ctrl ctrl);
}
diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java
index f7b1b9c..6957c5e 100644
--- a/core/src/ch/asynk/tankontank/game/Ctrl.java
+++ b/core/src/ch/asynk/tankontank/game/Ctrl.java
@@ -96,6 +96,9 @@ public class Ctrl implements Disposable
private void nextPlayer()
{
+ if (battle.checkVictory(this)) {
+ // TODO goto victory State
+ }
player.turnEnd();
Player tmp = player;
player = opponent;
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleFake.java b/core/src/ch/asynk/tankontank/game/battles/BattleFake.java
index da298c1..fc6e922 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleFake.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleFake.java
@@ -4,9 +4,11 @@ import java.util.Random;
import com.badlogic.gdx.math.GridPoint2;
+import ch.asynk.tankontank.game.Ctrl;
import ch.asynk.tankontank.game.Map;
import ch.asynk.tankontank.game.Army;
import ch.asynk.tankontank.game.Player;
+import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Unit.UnitId;
import ch.asynk.tankontank.engine.Orientation;
@@ -18,6 +20,30 @@ public class BattleFake extends BattleCommon
randomizeArmies();
}
+ public boolean checkVictory(Ctrl ctrl)
+ {
+ if (ctrl.opponent.unitsLeft() == 0)
+ return true;
+
+ if ((ctrl.player.getTurn() < 10) || (ctrl.opponent.getTurn() < 10))
+ return false;
+
+ Unit unit;
+ int objectives = 0;
+
+ unit = ctrl.map.getHex(7, 7).getUnit();
+ if ((unit != null) && (!ctrl.player.isEnemy(unit)))
+ objectives += 1;
+ unit = ctrl.map.getHex(6, 4).getUnit();
+ if ((unit != null) && (!ctrl.player.isEnemy(unit)))
+ objectives += 1;
+ unit = ctrl.map.getHex(6, 1).getUnit();
+ if ((unit != null) && (!ctrl.player.isEnemy(unit)))
+ objectives += 1;
+
+ return (objectives > 1);
+ }
+
@Override
public Map getMap()
{
@@ -50,6 +76,10 @@ public class BattleFake extends BattleCommon
gePlayer = a;
}
+ map.showObjective(map.getHex(7, 7));
+ map.showObjective(map.getHex(6, 4));
+ map.showObjective(map.getHex(6, 1));
+
Orientation o = Orientation.NORTH;
gePlayer.addUnit(map.setPawnOnto(factory.getUnit(UnitId.GE_TIGER), map.getHex(4, 7), o));
gePlayer.addUnit(map.setPawnOnto(factory.getUnit(UnitId.GE_TIGER), map.getHex(3, 6), o));