blob: c3016e066cd3129234ee955ddaf3bcb707f27deb (
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
|
/*
* 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;
/**
* VariableNumberPrecondition compares a the value of a variable and a number
* together with a specified Comparison.
*
* @author hatkirby
*/
public class VariableNumberPrecondition implements Precondition {
private String variableID;
private Comparison comparison;
private int number;
public VariableNumberPrecondition(String variableID, Comparison comparison, int number)
{
this.variableID = variableID;
this.comparison = comparison;
this.number = number;
}
public boolean match()
{
if (Game.getSaveFile().getVariables().containsKey(variableID))
{
int n1 = Game.getSaveFile().getVariables().get(variableID);
int n2 = number;
return comparison.compare(n1, n2);
}
return false;
}
}
|