summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch')
-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;
+ }
+}