summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-21 17:04:38 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-21 17:04:38 +0100
commitb2c746a1340f44056d27c11e25a835f5e5feef8e (patch)
treecacf6d6ee15ad8fc9e8a6609a1eec20caec21419
parent13c9f21be040b203c4f81cf34f43f128972ee276 (diff)
downloadRustAndDust-b2c746a1340f44056d27c11e25a835f5e5feef8e.zip
RustAndDust-b2c746a1340f44056d27c11e25a835f5e5feef8e.tar.gz
add game.Objective
-rw-r--r--core/src/ch/asynk/tankontank/game/Objective.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Objective.java b/core/src/ch/asynk/tankontank/game/Objective.java
new file mode 100644
index 0000000..f7a6c3b
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/game/Objective.java
@@ -0,0 +1,48 @@
+package ch.asynk.tankontank.game;
+
+public class Objective
+{
+ protected Army curArmy;
+ protected Army prevArmy;
+ private boolean persistent;
+
+ public Objective(Army army, boolean persistent)
+ {
+ this.curArmy = army;
+ this.prevArmy = army;
+ this.persistent = persistent;
+ }
+
+ public boolean is(Army army)
+ {
+ return (curArmy == army);
+ }
+
+ public Army army()
+ {
+ return curArmy;
+ }
+
+ public boolean set(Army army)
+ {
+ if (army == curArmy)
+ return false;
+ prevArmy = curArmy;
+ curArmy = army;
+ return true;
+ }
+
+ public boolean unset()
+ {
+ if (persistent)
+ return false;
+ revert();
+ return true;
+ }
+
+ public Army revert()
+ {
+ curArmy = prevArmy;
+ return curArmy;
+ }
+}