summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-04 23:11:06 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-04 23:11:06 +0100
commite0a06467236303c19690481bf3bc422ed1d8871d (patch)
treeb6141fca31972a747e07ceaa35ce134b2bf2ab1a /core/src/ch
parent5922058a43d20a2af30bf2c0873fa22e3d81b733 (diff)
downloadRustAndDust-e0a06467236303c19690481bf3bc422ed1d8871d.zip
RustAndDust-e0a06467236303c19690481bf3bc422ed1d8871d.tar.gz
PathBuilder: factorise pathCanExit(...) out of canExit()
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
index ca25535..03b194d 100644
--- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
+++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
@@ -266,18 +266,24 @@ public class PathBuilder implements Disposable
ps = filteredPaths;
int mvt = pawn.getMovementPoints();
- int rBonus = pawn.getRoadMarchBonus();
- boolean road = to.road(o);
int cost = to.exitCost();
+ int rBonus = (to.road(o) ? pawn.getRoadMarchBonus() : 0);
for (Path p : ps) {
- int c = (p.cost + cost);
- if ((c <= mvt) || (p.roadMarch && road && (c <= (mvt + rBonus))))
+ if (pathCanExit(p, mvt, cost, rBonus))
return true;
}
return false;
}
+ private boolean pathCanExit(Path p, int mvt, int cost, int rBonus)
+ {
+ int c = (p.cost + cost);
+ if ((c <= mvt) || (p.roadMarch && (c <= (mvt + rBonus))))
+ return true;
+ return false;
+ }
+
public Path getPath(int i)
{
if (ctrlTiles.size() == 0)