diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 23:16:44 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 23:16:44 +0100 |
commit | 6145c7004e2a6da0958be3068fc193f5dda7423e (patch) | |
tree | 392365a66120ccae91d27ff0a1b6a7e2cd2b594e | |
parent | e0a06467236303c19690481bf3bc422ed1d8871d (diff) | |
download | RustAndDust-6145c7004e2a6da0958be3068fc193f5dda7423e.zip RustAndDust-6145c7004e2a6da0958be3068fc193f5dda7423e.tar.gz |
PathBuilder: factorise getPaths(...) out of canExit()
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java index 03b194d..524e353 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -259,17 +259,11 @@ public class PathBuilder implements Disposable public boolean canExit(Orientation o) { - List<Path> ps; - if (ctrlTiles.size() == 0) - ps = paths; - else - ps = filteredPaths; - int mvt = pawn.getMovementPoints(); int cost = to.exitCost(); int rBonus = (to.road(o) ? pawn.getRoadMarchBonus() : 0); - for (Path p : ps) { + for (Path p : getPaths()) { if (pathCanExit(p, mvt, cost, rBonus)) return true; } @@ -284,6 +278,13 @@ public class PathBuilder implements Disposable return false; } + private List<Path> getPaths() + { + if (ctrlTiles.size() == 0) + return paths; + return filteredPaths; + } + public Path getPath(int i) { if (ctrlTiles.size() == 0) |