summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java index 530af6f..e57d7f8 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java
@@ -10,6 +10,7 @@ import java.awt.Graphics;
10import java.util.ArrayList; 10import java.util.ArrayList;
11import com.fourisland.fourpuzzle.Direction; 11import com.fourisland.fourpuzzle.Direction;
12import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic; 12import com.fourisland.fourpuzzle.gamestate.mapview.event.graphic.BlankEventGraphic;
13import com.fourisland.fourpuzzle.gamestate.mapview.event.precondition.Precondition;
13 14
14/** 15/**
15 * 16 *
@@ -50,24 +51,22 @@ public class LayerEvent extends AbstractEvent implements Event {
50 private ArrayList<PossibleEvent> events; 51 private ArrayList<PossibleEvent> events;
51 public void addEvent(PossibleEvent pe) 52 public void addEvent(PossibleEvent pe)
52 { 53 {
53 events.add(pe); 54 events.add(0, pe);
54 } 55 }
55 56
56 private PossibleEvent getPossibleEvent() 57 private PossibleEvent getPossibleEvent()
57 { 58 {
58 int i; 59 for (PossibleEvent event : events)
59 for (i=(events.size()-1);i>-1;i--)
60 { 60 {
61 boolean good = true; 61 boolean good = true;
62 int j; 62 for (Precondition pre : event.getPreconditions())
63 for (j=0;j<events.get(i).preconditions();j++)
64 { 63 {
65 good = (good ? events.get(i).getPrecondition(j).match() : false); 64 good = (good ? pre.match() : false);
66 } 65 }
67 66
68 if (good) 67 if (good)
69 { 68 {
70 return events.get(i); 69 return event;
71 } 70 }
72 } 71 }
73 72
@@ -79,7 +78,7 @@ public class LayerEvent extends AbstractEvent implements Event {
79 PossibleEvent toDraw = getPossibleEvent(); 78 PossibleEvent toDraw = getPossibleEvent();
80 if (!(toDraw.getGraphic() instanceof BlankEventGraphic)) 79 if (!(toDraw.getGraphic() instanceof BlankEventGraphic))
81 { 80 {
82 g.drawImage(toDraw.getImage(), getRenderX(), getRenderY(), null); 81 g.drawImage(toDraw.getGraphic().getImage(), getRenderX(), getRenderY(), null);
83 } 82 }
84 } 83 }
85 84
@@ -97,6 +96,7 @@ public class LayerEvent extends AbstractEvent implements Event {
97 { 96 {
98 return getPossibleEvent().getDirection(); 97 return getPossibleEvent().getDirection();
99 } 98 }
99
100 public void setDirection(Direction direction) 100 public void setDirection(Direction direction)
101 { 101 {
102 getPossibleEvent().setDirection(direction); 102 getPossibleEvent().setDirection(direction);
@@ -117,7 +117,8 @@ public class LayerEvent extends AbstractEvent implements Event {
117 return getPossibleEvent().getCallback(); 117 return getPossibleEvent().getCallback();
118 } 118 }
119 119
120 public void setLabel(String string) { 120 public void setLabel(String string)
121 {
121 this.label = string; 122 this.label = string;
122 } 123 }
123 124