blob: 91a31ba72b81ce61132d7a571ba80453730df1a0 (
plain) (
blame)
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
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.fourisland.fourpuzzle.gamestate.mapview.event.precondition;
import com.fourisland.fourpuzzle.util.Comparison;
import com.fourisland.fourpuzzle.Game;
/**
* VariableVariablePrecondition compares two variables together with a specified
* Comparison.
*
* @author hatkirby
*/
public class VariableVariablePrecondition implements Precondition {
private String variableID;
private Comparison comparison;
private String variableID2;
public VariableVariablePrecondition(String variableID, Comparison comparison, String variableID2)
{
this.variableID = variableID;
this.comparison = comparison;
this.variableID2 = variableID2;
}
public boolean match()
{
if (Game.getSaveFile().getVariables().containsKey(variableID))
{
int n1 = Game.getSaveFile().getVariables().get(variableID);
int n2 = Game.getSaveFile().getVariables().get(variableID2);
switch (comparison)
{
case Less: return (n1 < n2);
case Greater: return (n1 > n2);
case Equal: return (n1 == n2);
}
}
return false;
}
}
|