summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/engine/Objective.java
blob: de1c7d3123218d302c9471d7cbf44ba2b0674e14 (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
49
package ch.asynk.rustanddust.engine;

public class Objective
{
    protected Faction curFaction;
    protected Faction prevFaction;
    private boolean persistent;

    public Objective(Faction faction, boolean persistent)
    {
        this.curFaction = faction;
        this.prevFaction = faction;
        this.persistent = persistent;
    }

    public boolean is(Faction faction)
    {
        return (curFaction == faction);
    }

    public Faction faction()
    {
        return curFaction;
    }

    public boolean set(Faction faction)
    {
        if (faction == curFaction)
            return false;

        prevFaction = curFaction;
        curFaction = faction;
        return true;
    }

    public boolean unset()
    {
        if (persistent)
            return false;
        revert();
        return true;
    }

    public Faction revert()
    {
        curFaction = prevFaction;
        return curFaction;
    }
}