summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/HeroInPartyPrecondition.java27
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/HeroLevelPrecondition.java29
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/Precondition.java16
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/SwitchPrecondition.java27
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableNumberPrecondition.java45
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableVariablePrecondition.java45
6 files changed, 189 insertions, 0 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/HeroInPartyPrecondition.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/HeroInPartyPrecondition.java new file mode 100644 index 0000000..7700674 --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/HeroInPartyPrecondition.java
@@ -0,0 +1,27 @@
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.Game;
9
10/**
11 *
12 * @author hatkirby
13 */
14public class HeroInPartyPrecondition implements Precondition {
15
16 private String heroName;
17
18 public HeroInPartyPrecondition(String heroName)
19 {
20 this.heroName = heroName;
21 }
22
23 public boolean match() {
24 return Game.getSaveFile().getParty().exists(heroName);
25 }
26
27}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/HeroLevelPrecondition.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/HeroLevelPrecondition.java new file mode 100644 index 0000000..1b10e91 --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/HeroLevelPrecondition.java
@@ -0,0 +1,29 @@
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.Game;
9
10/**
11 *
12 * @author hatkirby
13 */
14public class HeroLevelPrecondition implements Precondition {
15
16 private String heroName;
17 private int level;
18
19 public HeroLevelPrecondition(String heroName, int level)
20 {
21 this.heroName = heroName;
22 this.level = level;
23 }
24
25 public boolean match() throws Exception {
26 return (Game.getSaveFile().getParty().exists(heroName) && (Game.getSaveFile().getParty().get(heroName).getLevel() == level));
27 }
28
29}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/Precondition.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/Precondition.java new file mode 100644 index 0000000..3f75984 --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/Precondition.java
@@ -0,0 +1,16 @@
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
8/**
9 *
10 * @author hatkirby
11 */
12public interface Precondition {
13
14 public boolean match() throws Exception;
15
16}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/SwitchPrecondition.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/SwitchPrecondition.java new file mode 100644 index 0000000..794eae4 --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/SwitchPrecondition.java
@@ -0,0 +1,27 @@
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.Game;
9
10/**
11 *
12 * @author hatkirby
13 */
14public class SwitchPrecondition implements Precondition {
15
16 private String switchID;
17
18 public SwitchPrecondition(String switchID)
19 {
20 this.switchID = switchID;
21 }
22
23 public boolean match() {
24 return (Game.getSaveFile().getSwitches().containsKey(switchID) && Game.getSaveFile().getSwitches().get(switchID));
25 }
26
27}
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}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableVariablePrecondition.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableVariablePrecondition.java new file mode 100644 index 0000000..1eb9b0c --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/VariableVariablePrecondition.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 VariableVariablePrecondition implements Precondition {
16
17 private String variableID;
18 private Comparison comparison;
19 private String variableID2;
20
21 public VariableVariablePrecondition(String variableID, Comparison comparison, String variableID2)
22 {
23 this.variableID = variableID;
24 this.comparison = comparison;
25 this.variableID2 = variableID2;
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 = Game.getSaveFile().getVariables().get(variableID2);
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}