summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game/Objective.java
blob: f7a6c3beaeb4fd598b0d73efb88066d074d8f7c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;
    }
}