From e344ffce79051254d216c3add363805cd3a4892f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 24 Dec 2015 00:08:32 +0100 Subject: ObjectiveSet: respond to isObjectiveFor() taking peristence into account --- core/src/ch/asynk/rustanddust/engine/Objective.java | 5 +++++ core/src/ch/asynk/rustanddust/engine/ObjectiveSet.java | 12 ++++++++++++ core/src/ch/asynk/rustanddust/game/map/Map0Hex.java | 5 +---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/engine/Objective.java b/core/src/ch/asynk/rustanddust/engine/Objective.java index de1c7d3..d10f446 100644 --- a/core/src/ch/asynk/rustanddust/engine/Objective.java +++ b/core/src/ch/asynk/rustanddust/engine/Objective.java @@ -23,6 +23,11 @@ public class Objective return curFaction; } + public boolean persistent() + { + return persistent; + } + public boolean set(Faction faction) { if (faction == curFaction) diff --git a/core/src/ch/asynk/rustanddust/engine/ObjectiveSet.java b/core/src/ch/asynk/rustanddust/engine/ObjectiveSet.java index 1536360..61feba6 100644 --- a/core/src/ch/asynk/rustanddust/engine/ObjectiveSet.java +++ b/core/src/ch/asynk/rustanddust/engine/ObjectiveSet.java @@ -34,6 +34,18 @@ public class ObjectiveSet extends HashMap return n; } + public boolean isObjectiveFor(Tile tile, Pawn pawn) + { + Objective objective = get(tile); + if (objective == null) + return false; + + if (objective.faction() == pawn.getFaction()) + return false; + + return (objective.persistent()); + } + public Faction claim(Tile tile, Faction faction) { Objective objective = get(tile); diff --git a/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java b/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java index 41270d1..77780cd 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map0Hex.java @@ -79,10 +79,7 @@ public abstract class Map0Hex extends Board implements ObjectiveSet.ObjectiveCb @Override public boolean isObjectiveFor(Tile tile, Pawn pawn) { - if (!objectives.containsKey(tile)) - return false; - - return (objectives.get(tile).faction() != pawn.getFaction()); + return objectives.isObjectiveFor(tile, pawn); } @Override -- cgit v1.1-2-g2b99