summaryrefslogtreecommitdiff
path: root/server/lib/core/commands/set_init_command.dart
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/core/commands/set_init_command.dart')
-rw-r--r--server/lib/core/commands/set_init_command.dart26
1 files changed, 26 insertions, 0 deletions
diff --git a/server/lib/core/commands/set_init_command.dart b/server/lib/core/commands/set_init_command.dart
new file mode 100644
index 0000000..9ffb279
--- /dev/null
+++ b/server/lib/core/commands/set_init_command.dart
@@ -0,0 +1,26 @@
+import '../state/game_state.dart';
+import 'command_l10n.dart';
+
+class SetInitCommand extends Command {
+ final GameState _gameState;
+ final String _characterId;
+ final int _init;
+
+ SetInitCommand(this._characterId, this._init, {required GameState gameState})
+ : _gameState = gameState;
+
+ @override
+ void execute() {
+ //add new character on top of list
+ for (final item in _gameState.currentList) {
+ if (item.id == _characterId && item is Character) {
+ item.characterState.setInitiative(stateAccess, _init);
+ }
+ }
+ }
+
+ @override
+ String describe() {
+ return commandL10n.cmdSetInitiative(_characterId);
+ }
+}