summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableNumberPrecondition.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableNumberPrecondition.java')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableNumberPrecondition.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableNumberPrecondition.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableNumberPrecondition.java new file mode 100644 index 0000000..a3ce086 --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableNumberPrecondition.java
@@ -0,0 +1,45 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package com.fourisland.fourpuzzle.gamestate.mapview.event.precondition;
7
8import com.fourisland.fourpuzzle.util.Comparison;
9import com.fourisland.fourpuzzle.Game;
10
11/**
12 *
13 * @author hatkirby
14 */
15public class VariableNumberPrecondition implements Precondition {
16
17 private String variableID;
18 private Comparison comparison;
19 private int number;
20
21 public VariableNumberPrecondition(String variableID, Comparison comparison, int number)
22 {
23 this.variableID = variableID;
24 this.comparison = comparison;
25 this.number = number;
26 }
27
28 public boolean match() {
29 if (Game.getSaveFile().getVariables().containsKey(variableID))
30 {
31 int n1 = Game.getSaveFile().getVariables().get(variableID);
32 int n2 = number;
33
34 switch (comparison)
35 {
36 case Less: return (n1 < n2);
37 case Greater: return (n1 > n2);
38 case Equal: return (n1 == n2);
39 }
40 }
41
42 return false;
43 }
44
45}