summaryrefslogtreecommitdiff
path: root/server/lib/core/commands/turn_done_command.dart
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/core/commands/turn_done_command.dart')
-rw-r--r--server/lib/core/commands/turn_done_command.dart34
1 files changed, 34 insertions, 0 deletions
diff --git a/server/lib/core/commands/turn_done_command.dart b/server/lib/core/commands/turn_done_command.dart
new file mode 100644
index 0000000..d9c756a
--- /dev/null
+++ b/server/lib/core/commands/turn_done_command.dart
@@ -0,0 +1,34 @@
+import '../game_event.dart';
+import '../state/game_state.dart';
+import 'command_l10n.dart';
+
+class TurnDoneCommand extends Command {
+ int index = 0;
+ final String id;
+ final GameState _gameState;
+
+ TurnDoneCommand(this.id, {required GameState gameState})
+ : _gameState = gameState {
+ index = 0;
+ for (int i = 0; i < _gameState.currentList.length; i++) {
+ if (id == _gameState.currentList[i].id) {
+ index = i;
+ break;
+ }
+ }
+ }
+
+ @override
+ void execute() {
+ RoundMethods.setTurnDone(stateAccess, index);
+ _gameState.notifyListeners();
+ }
+
+ @override
+ GameEvent get event => TurnDoneEvent(id);
+
+ @override
+ String describe() {
+ return commandL10n.cmdTurnDone(id);
+ }
+}