From e0a06467236303c19690481bf3bc422ed1d8871d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 4 Jan 2016 23:11:06 +0100 Subject: PathBuilder: factorise pathCanExit(...) out of canExit() --- core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 14 ++++++++++---- 1 file 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) -- cgit v1.1-2-g2b99