[update] save state after action
This commit is contained in:
@@ -6,7 +6,6 @@ import ru.m.puzzlez.core.Game;
|
|||||||
import ru.m.puzzlez.core.GameEvent;
|
import ru.m.puzzlez.core.GameEvent;
|
||||||
import ru.m.puzzlez.core.GameState;
|
import ru.m.puzzlez.core.GameState;
|
||||||
import ru.m.puzzlez.core.IGame;
|
import ru.m.puzzlez.core.IGame;
|
||||||
import ru.m.puzzlez.core.PartLocation;
|
|
||||||
import ru.m.puzzlez.render.IRender;
|
import ru.m.puzzlez.render.IRender;
|
||||||
import ru.m.puzzlez.source.GameStorage;
|
import ru.m.puzzlez.source.GameStorage;
|
||||||
|
|
||||||
@@ -18,6 +17,8 @@ import ru.m.puzzlez.source.GameStorage;
|
|||||||
@:provide var switcher:FrameSwitcher;
|
@:provide var switcher:FrameSwitcher;
|
||||||
@:provide var storage:GameStorage;
|
@:provide var storage:GameStorage;
|
||||||
|
|
||||||
|
private var toSave:Bool;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super(ID);
|
super(ID);
|
||||||
}
|
}
|
||||||
@@ -42,13 +43,18 @@ import ru.m.puzzlez.source.GameStorage;
|
|||||||
|
|
||||||
private function onGameEvent(event:GameEvent):Void {
|
private function onGameEvent(event:GameEvent):Void {
|
||||||
switch event {
|
switch event {
|
||||||
case CHANGE(PART_UPDATE(_, IMAGE)):
|
case ACTION(PART_PUT(_, _)):
|
||||||
storage.save(game.state);
|
toSave = true;
|
||||||
|
case CHANGE(PART_UPDATE(_, _)):
|
||||||
|
if (toSave) {
|
||||||
|
storage.save(game.state);
|
||||||
|
toSave = false;
|
||||||
|
}
|
||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function back():Void {
|
private function back():Void {
|
||||||
switcher.change(ImageListFrame.ID);
|
switcher.change(StartFrame.ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user