summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-12 22:31:19 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-12 22:31:19 +0100
commit60e6f04e48b1b232632dfd579247e8a15c9635f6 (patch)
tree10fb9c8632889b16a87e91532f30d8e651950f3f /core/src/ch/asynk/tankontank/game
parentcc96310a9a8bb040f3af7f8f4f5a1c9225dd6933 (diff)
downloadRustAndDust-60e6f04e48b1b232632dfd579247e8a15c9635f6.zip
RustAndDust-60e6f04e48b1b232632dfd579247e8a15c9635f6.tar.gz
Board,Map...: fix findEntryPoint(...)
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/Battle.java7
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java9
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleCommon.java13
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java8
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateReinforcement.java7
5 files changed, 18 insertions, 26 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Battle.java b/core/src/ch/asynk/tankontank/game/Battle.java
index 4970df6..507a13a 100644
--- a/core/src/ch/asynk/tankontank/game/Battle.java
+++ b/core/src/ch/asynk/tankontank/game/Battle.java
@@ -1,7 +1,6 @@
package ch.asynk.tankontank.game;
-import ch.asynk.tankontank.engine.TileSet;
-import ch.asynk.tankontank.engine.Orientation;
+import ch.asynk.tankontank.engine.EntryPoint;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.Player;
import ch.asynk.tankontank.game.hud.Position;
@@ -22,9 +21,7 @@ public interface Battle
public Player checkVictory(Ctrl ctrl);
- public TileSet getEntryPoint(Unit unit);
-
- public Orientation getEntryOrientation(Player player);
+ public EntryPoint getEntryPoint(Unit unit);
public Position getHudPosition(Player player);
}
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 8e5f893..526b1e4 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -167,11 +167,14 @@ public abstract class Map extends Board
// ACTIONS
- public void enterBoard(Pawn pawn, Hex to, Orientation o)
+ public boolean enterBoard(Pawn pawn, Hex to, int allowedMoves)
{
- Orientation entry = findBestEntry(pawn, to, o);
+ Orientation entry = findBestEntry(pawn, to, allowedMoves);
+ if (entry == Orientation.KEEP)
+ return false;
pawn.enterBoard(to, entry);
- setPawnOnto(pawn, to, o);
+ setPawnOnto(pawn, to, entry.opposite());
+ return true;
}
public void leaveBoard(Pawn pawn)
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java b/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java
index 8d2c5fc..c39b2b4 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleCommon.java
@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.ArrayList;
import ch.asynk.tankontank.engine.TileSet;
+import ch.asynk.tankontank.engine.EntryPoint;
import ch.asynk.tankontank.game.Army;
import ch.asynk.tankontank.game.Battle;
import ch.asynk.tankontank.game.Player;
@@ -20,8 +21,8 @@ public abstract class BattleCommon implements Battle
protected Army firstArmy;
protected Army secondArmy;
protected Factory factory;
- protected ArrayList<TileSet> entryPoints = new ArrayList<TileSet>();
- protected HashMap<Unit, TileSet> pawnEntry = new HashMap<Unit, TileSet>();
+ protected ArrayList<EntryPoint> entryPoints = new ArrayList<EntryPoint>();
+ protected HashMap<Unit, EntryPoint> pawnEntry = new HashMap<Unit, EntryPoint>();
protected TileSet objectives;
public BattleCommon(Factory factory)
@@ -50,19 +51,19 @@ public abstract class BattleCommon implements Battle
}
}
- public void addEntryPoint(TileSet tiles)
+ public void addEntryPoint(EntryPoint entry)
{
- entryPoints.add(tiles);
+ entryPoints.add(entry);
}
- public void addReinforcement(Player player, TileSet entryPoint, UnitId unitId)
+ public void addReinforcement(Player player, EntryPoint entryPoint, UnitId unitId)
{
Unit unit = factory.getUnit(unitId);
player.addReinforcement(unit);
pawnEntry.put(unit, entryPoint);
}
- public TileSet getEntryPoint(Unit unit)
+ public EntryPoint getEntryPoint(Unit unit)
{
return pawnEntry.get(unit);
}
diff --git a/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java b/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java
index ab3e5fb..ae35df2 100644
--- a/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java
+++ b/core/src/ch/asynk/tankontank/game/battles/BattleHeadToHead.java
@@ -79,14 +79,6 @@ public class BattleHeadToHead extends BattleCommon
}
@Override
- public Orientation getEntryOrientation(Player player)
- {
- if (player.isEnemy(Army.GE))
- return Orientation.SOUTH;
- return Orientation.NORTH;
- }
-
- @Override
public void setup(Map map, Player a, Player b)
{
Player gePlayer;
diff --git a/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java b/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java
index a66973e..c8cb901 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java
@@ -2,15 +2,14 @@ package ch.asynk.tankontank.game.states;
import com.badlogic.gdx.math.Vector3;
-import ch.asynk.tankontank.engine.TileSet;
-import ch.asynk.tankontank.engine.Orientation;
+import ch.asynk.tankontank.engine.EntryPoint;
import ch.asynk.tankontank.game.Hex;
import ch.asynk.tankontank.game.Unit;
import ch.asynk.tankontank.game.hud.ActionButtons.Buttons;
public class StateReinforcement extends StateCommon
{
- private TileSet entryPoint;
+ private EntryPoint entryPoint;
@Override
public void enter(boolean fromSelect)
@@ -75,7 +74,7 @@ public class StateReinforcement extends StateCommon
map.selectHex(selectedHex);
entryPoint.enable(Hex.AREA, false);
ctrl.player.unitEntry(unit);
- map.enterBoard(unit, upHex, ctrl.battle.getEntryOrientation(ctrl.player));
+ map.enterBoard(unit, upHex, entryPoint.allowedMoves);
if (unit.getMovementPoints() > 0)
ctrl.setState(StateType.MOVE, true);
else