summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-01-18 22:06:22 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-01-18 22:06:22 +0100
commite60b3d647b9eff905977fd9f5a7760ce0b0113ea (patch)
tree2a2be7fd724f3534cfeb818ebffa275f7e90c55f /core/src/ch/asynk/tankontank/game
parent28ebacf54e013690337a754522616ca909a440f5 (diff)
downloadRustAndDust-e60b3d647b9eff905977fd9f5a7760ce0b0113ea.zip
RustAndDust-e60b3d647b9eff905977fd9f5a7760ce0b0113ea.tar.gz
remove Pawn.Movement class, use Move instead
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java21
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java18
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateMove.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateRotate.java4
4 files changed, 31 insertions, 14 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index bc3bd43..f32b8d2 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import ch.asynk.tankontank.TankOnTank;
import ch.asynk.tankontank.engine.Pawn;
import ch.asynk.tankontank.engine.Board;
+import ch.asynk.tankontank.engine.Move;
import ch.asynk.tankontank.engine.SelectedTile;
import ch.asynk.tankontank.engine.Orientation;
import ch.asynk.tankontank.engine.Meteorology;
@@ -206,7 +207,7 @@ public abstract class Map extends Board
public int collectMoveableUnits(Unit unit)
{
- if (unit.isHq() && !unit.movement.entryMove) {
+ if (unit.canHQMove()) {
collectMoveAssists(unit, moveableUnits.asPawns());
} else {
moveableUnits.clear();
@@ -271,8 +272,11 @@ public abstract class Map extends Board
Orientation entry = findBestEntry(unit, to, allowedMoves);
if (entry == Orientation.KEEP)
return false;
- unit.enterBoard(to, entry);
- setPawnOnto(unit, to, entry);
+
+ Move move = Move.get(unit, null, to, entry, null);
+ move.setEnter();
+
+ enterPawn(unit, move);
objectives.claim(to, unit.getArmy());
return true;
}
@@ -280,7 +284,11 @@ public abstract class Map extends Board
public boolean setOnBoard(Unit unit, Hex to, Orientation entry)
{
TankOnTank.debug("Map", String.format("set %s %s %s", to.toShort(), unit, entry));
- setPawnOnto(unit, to, entry);
+
+ Move move = Move.get(unit, null, to, entry, null);
+ move.setSet();
+
+ setPawnOnto(unit, move);
objectives.claim(to, unit.getArmy());
return true;
}
@@ -288,7 +296,7 @@ public abstract class Map extends Board
public void leaveBoard(Unit unit)
{
Hex hex = unit.getHex();
- if (unit.movement.entryMove) {
+ if (unit.justEntered()) {
objectives.revert();
unit.reset();
}
@@ -315,8 +323,7 @@ public abstract class Map extends Board
public int moveUnit(Unit unit)
{
- possiblePaths.applyToPawn(0);
- movePawn(unit, possiblePaths, notifyDoneAnimation(unit), objectives);
+ movePawn(unit, possiblePaths.getMove(), notifyDoneAnimation(unit), objectives);
return startMove(unit);
}
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index 12cac1f..87ba3cd 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -285,6 +285,11 @@ public class Unit extends HeadedPawn
return (isEnemy(other) && canEngage());
}
+ public boolean canHQMove()
+ {
+ return (isHq() && ((move == null) || (!move.isEntry())));
+ }
+
public void setMoved()
{
hasMoved = true;
@@ -294,13 +299,18 @@ public class Unit extends HeadedPawn
@Override
public void move()
{
- TankOnTank.debug(movement.toString());
- if (movement.cost > mpLeft) TankOnTank.debug("ERROR: Movement point exceeded: " + movement.cost + "/" + mpLeft + " please report");
+ int cost = move.cost;
+
+ if (move.roadMarch && (cost > mpLeft))
+ cost -= getRoadMarchBonus();
+
+ if (cost > mpLeft)
+ TankOnTank.debug("ERROR: Movement point exceeded: " + cost + "/" + mpLeft + " please report");
- if (movement.isComplete())
+ if (move.isComplete())
setMoved();
- mpLeft -= movement.cost;
+ mpLeft -= cost;
}
@Override
diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java
index 7ab8be8..0ed1b2a 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateMove.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java
@@ -69,7 +69,7 @@ public class StateMove extends StateCommon
public StateType abort()
{
hideAssists();
- if (activeUnit.movement.entryMove) {
+ if (activeUnit.justEntered()) {
map.leaveBoard(activeUnit);
ctrl.player.revertUnitEntry(activeUnit);
return StateType.ABORT;
diff --git a/core/src/ch/asynk/tankontank/game/states/StateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
index 2e1e822..2b45512 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
@@ -54,7 +54,7 @@ public class StateRotate extends StateCommon
{
StateType nextState = StateType.ABORT;
ctrl.hud.actionButtons.hide();
- if (activeUnit.movement.entryMove) {
+ if (activeUnit.justEntered()) {
map.leaveBoard(activeUnit);
ctrl.player.revertUnitEntry(activeUnit);
nextState = StateType.ABORT;
@@ -95,7 +95,7 @@ public class StateRotate extends StateCommon
return;
}
- if (!activeUnit.movement.entryMove && rotateOnly && (o == activeUnit.getOrientation()))
+ if (!activeUnit.justEntered() && rotateOnly && (o == activeUnit.getOrientation()))
return;
map.possiblePaths.orientation = o;