feat(app): add table shuffle and spread actions

This commit is contained in:
2024-05-10 21:46:43 +03:00
parent 05c736ddd1
commit 449936e4c9
7 changed files with 66 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ class PuzzlezTheme extends Theme {
"restore" => "window-restore-solid.svg",
"compress" => "compress-solid.svg",
"expand" => "expand-solid.svg",
"spread" => "clone.svg",
];
public function new() {

View File

@@ -7,7 +7,9 @@ import hw.view.popup.ConfirmView;
import promhx.Promise;
import ru.m.puzzlez.image.Game;
import ru.m.puzzlez.image.IGame;
import ru.m.puzzlez.proto.event.GameAction;
import ru.m.puzzlez.proto.event.GameEvent;
import ru.m.puzzlez.proto.event.gameaction.Action;
import ru.m.puzzlez.proto.game.GameState;
import ru.m.puzzlez.proto.game.GameStatus;
import ru.m.puzzlez.render.IRender;
@@ -91,6 +93,16 @@ import ru.m.puzzlez.view.popup.PreviewPopup;
});
}
private function shuffle():Void {
// TODO: playerId?
game.action(new GameAction().setAction(Action.TABLE_SHUFFLE).setPlayerId("local"));
}
private function spread():Void {
// TODO: playerId?
game.action(new GameAction().setAction(Action.TABLE_SPREAD).setPlayerId("local"));
}
private function back():Void {
(game.state.status == GameStatus.COMPLETE ? Promise.promise(true) : ConfirmView.confirm("Exit?")).then(result -> {
if (result) {

View File

@@ -25,6 +25,12 @@ views:
- $type: hw.view.form.ButtonView
style: icon.restore
+onPress: ~render.manager.reset()
- $type: hw.view.form.ButtonView
style: icon.spread
+onPress: ~shuffle()
- $type: hw.view.form.ButtonView
style: icon.spread
+onPress: ~spread()
- $type: hw.view.form.ButtonView
style: icon.setting
geometry.margin.top: 30