summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-12-24 00:08:32 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-12-24 00:08:32 +0100
commite344ffce79051254d216c3add363805cd3a4892f (patch)
tree0d5bb88accda9de6d9f8475532473b93f1ed095e /core
parent304923ce266bcfc6c52028b1b9f7342e7d4379a7 (diff)
downloadRustAndDust-e344ffce79051254d216c3add363805cd3a4892f.zip
RustAndDust-e344ffce79051254d216c3add363805cd3a4892f.tar.gz
ObjectiveSet: respond to isObjectiveFor() taking peristence into account
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/Objective.java5
-rw-r--r--core/src/ch/asynk/rustanddust/engine/ObjectiveSet.java12
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map0Hex.java5
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<Tile, Objective>
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