summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-02-15 13:12:19 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-02-15 13:12:19 -0500
commitcb18193a2b599853813dbc5fc128406250741a3c (patch)
treeed0bdf277412aae7e2da9d1021e9888bb1e1f4fa /src/com/fourisland/fourpuzzle/gamestate/mapview/event
parent370ce6c579828b50651d3636d9502f9c3b87ad15 (diff)
downloadfourpuzzle-cb18193a2b599853813dbc5fc128406250741a3c.tar.gz
fourpuzzle-cb18193a2b599853813dbc5fc128406250741a3c.tar.bz2
fourpuzzle-cb18193a2b599853813dbc5fc128406250741a3c.zip
Engine: Atomicized Maps
Previously, MapViewGameState preformed all of its actions directly on the internal map. However, this would result in the map being exactly the same when reloaded, which was not wanted. So, copy() functions have been added to several places so a copy of the internal map is provided for MapViewGameState.
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/event')
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java12
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java12
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java16
3 files changed, 40 insertions, 0 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java index 8de4e3c..7120a91 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventList.java
@@ -19,6 +19,18 @@ public class EventList extends Vector<LayerEvent> {
19 setParentMap(parentMap); 19 setParentMap(parentMap);
20 } 20 }
21 21
22 public EventList copy(Map parentMap)
23 {
24 EventList temp = new EventList(parentMap);
25
26 for (LayerEvent ev : this)
27 {
28 temp.add(ev.copy());
29 }
30
31 return temp;
32 }
33
22 @Override 34 @Override
23 public boolean add(LayerEvent o) 35 public boolean add(LayerEvent o)
24 { 36 {
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java index 1bbe3bb..b1e9bdc 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/LayerEvent.java
@@ -45,6 +45,18 @@ public class LayerEvent extends AbstractEvent implements Event {
45 this.label = label; 45 this.label = label;
46 } 46 }
47 47
48 public LayerEvent copy()
49 {
50 LayerEvent temp = new LayerEvent(getLocation().x, getLocation().y, getLabel());
51
52 for (PossibleEvent pe : events)
53 {
54 temp.addEvent(pe.copy());
55 }
56
57 return temp;
58 }
59
48 private String label; 60 private String label;
49 public String getLabel() 61 public String getLabel()
50 { 62 {
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java index 62d356a..f8934f4 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/PossibleEvent.java
@@ -96,6 +96,22 @@ public class PossibleEvent {
96 calltime = builder.calltime; 96 calltime = builder.calltime;
97 callback = builder.callback; 97 callback = builder.callback;
98 } 98 }
99
100 public PossibleEvent copy()
101 {
102 PossibleEvent temp = new Builder()
103 .graphic(graphic)
104 .layer(layer)
105 .animation(animation)
106 .movement(movement)
107 .calltime(calltime)
108 .callback(callback)
109 .build();
110
111 temp.getPreconditions().addAll(preconditions);
112
113 return temp;
114 }
99 115
100 public EventGraphic getGraphic() 116 public EventGraphic getGraphic()
101 { 117 {