summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-12-21 19:32:25 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-12-21 19:32:25 +0100
commitb8d524c48af7b38eaec7d2547844c8b76b7009d6 (patch)
tree32c224fb7571478634b6584d5f7342096b343f56 /core/src/ch
parentbccade845e568c5fd893e7567efb17d0bb7e8ea7 (diff)
downloadRustAndDust-b8d524c48af7b38eaec7d2547844c8b76b7009d6.zip
RustAndDust-b8d524c48af7b38eaec7d2547844c8b76b7009d6.tar.gz
PathBuilder: fitness takes objectives into account
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/Board.java1
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathBuilder.java1
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map0Hex.java6
3 files changed, 8 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java
index ba9e1a1..b934030 100644
--- a/core/src/ch/asynk/rustanddust/engine/Board.java
+++ b/core/src/ch/asynk/rustanddust/engine/Board.java
@@ -66,6 +66,7 @@ public abstract class Board implements Disposable, Animation
protected SelectedTile selectedTile;
abstract protected Config getConfig();
+ abstract protected boolean isObjective(Tile tile);
protected Board(int cols, int rows)
{
diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
index 2f8017c..bc51ab6 100644
--- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
+++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java
@@ -152,6 +152,7 @@ public class PathBuilder implements Disposable
int n = next.costFrom(pawn, o);
boolean r = next.road(o);
int f = (fitness + 1 + (r ? 0 : 1));
+ if (board.isObjective(next)) f -= 2;
int m = (mvtLeft - n);
r &= roadMarch;
diff --git a/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java b/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java
index c1ab73a..0d28829 100644
--- a/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java
+++ b/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java
@@ -76,6 +76,12 @@ public abstract class Map0Hex extends Board implements ObjectiveSet.ObjectiveCb
public void hexExitHide(Hex hex) { enableOverlayOn(hex, Hex.EXIT, false); }
@Override
+ public boolean isObjective(Tile tile)
+ {
+ return objectives.containsKey(tile);
+ }
+
+ @Override
public void showObjective(Tile tile, Faction faction)
{
showObjective((Hex) tile, (Army) faction);