From 7f1b60094b5d351c58194feabad1fef903d1d3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 21 Dec 2015 19:46:54 +0100 Subject: Map0Hex: isObjective(Tile) -> isObjectiveFor(Tile,Pawn) : says no if already owned --- core/src/ch/asynk/rustanddust/engine/Board.java | 2 +- core/src/ch/asynk/rustanddust/engine/PathBuilder.java | 2 +- core/src/ch/asynk/rustanddust/game/map/Map0Hex.java | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java index b934030..83dbd86 100644 --- a/core/src/ch/asynk/rustanddust/engine/Board.java +++ b/core/src/ch/asynk/rustanddust/engine/Board.java @@ -66,7 +66,7 @@ public abstract class Board implements Disposable, Animation protected SelectedTile selectedTile; abstract protected Config getConfig(); - abstract protected boolean isObjective(Tile tile); + abstract protected boolean isObjectiveFor(Tile tile, Pawn pawn); 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 bc51ab6..bebb045 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -152,7 +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; + if (board.isObjectiveFor(next, pawn)) 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 0d28829..41270d1 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Texture; import ch.asynk.rustanddust.RustAndDust; import ch.asynk.rustanddust.engine.Tile; +import ch.asynk.rustanddust.engine.Pawn; import ch.asynk.rustanddust.engine.Board; import ch.asynk.rustanddust.engine.Faction; import ch.asynk.rustanddust.engine.SelectedTile; @@ -76,9 +77,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) + public boolean isObjectiveFor(Tile tile, Pawn pawn) { - return objectives.containsKey(tile); + if (!objectives.containsKey(tile)) + return false; + + return (objectives.get(tile).faction() != pawn.getFaction()); } @Override -- cgit v1.1-2-g2b99