summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/engine
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-01-19 12:24:25 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-01-19 12:24:25 +0100
commit0b57bfb1840d0020634c413ef6d4a0f2d88ced99 (patch)
tree24d29191dbe5c6b3521e5db481e87e3826a0dc4c /core/src/ch/asynk/tankontank/engine
parent51f534e24dc3406851693990ad2dc748ae642816 (diff)
downloadRustAndDust-0b57bfb1840d0020634c413ef6d4a0f2d88ced99.zip
RustAndDust-0b57bfb1840d0020634c413ef6d4a0f2d88ced99.tar.gz
PossiblePaths: add boolean canExit(Orientation o)
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine')
-rw-r--r--core/src/ch/asynk/tankontank/engine/PossiblePaths.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
index f45b3ac..49a317f 100644
--- a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
+++ b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
@@ -207,6 +207,27 @@ public class PossiblePaths implements Disposable
return move;
}
+ public boolean canExit(Orientation o)
+ {
+ List<Path> ps;
+ if (ctrlTiles.size() == 0)
+ ps = paths;
+ else
+ ps = filteredPaths;
+
+ int mvt = pawn.getMovementPoints();
+ int rBonus = pawn.getRoadMarchBonus();
+ boolean road = to.road(o);
+ int cost = to.exitCost();
+
+ for (Path p : ps) {
+ int c = (p.cost + cost);
+ if ((c <= mvt) || (p.roadMarch && road && (c <= (mvt + rBonus))))
+ return true;
+ }
+ return false;
+ }
+
public Path getPath(int i)
{
if (ctrlTiles.size() == 0)