diff options
Diffstat (limited to 'server/lib/core/commands/track_standees_command.dart')
| -rw-r--r-- | server/lib/core/commands/track_standees_command.dart | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/server/lib/core/commands/track_standees_command.dart b/server/lib/core/commands/track_standees_command.dart new file mode 100644 index 0000000..6ca8211 --- /dev/null +++ b/server/lib/core/commands/track_standees_command.dart @@ -0,0 +1,48 @@ +import '../settings.dart'; +import '../state/game_state.dart'; +import 'command_l10n.dart'; + +class TrackStandeesCommand extends Command { + final GameState _gameState; + final Settings _settings; + final bool track; + + TrackStandeesCommand( + this.track, { + required GameState gameState, + required Settings settings, + }) : _gameState = gameState, + _settings = settings; + + @override + void execute() { + _settings.noStandees = !track; + _handleNoStandeesSettingChange(); + } + + @override + String describe() { + if (!track) { + return commandL10n.cmdDontTrackStandees; + } + return commandL10n.cmdTrackStandees; + } + + void _handleNoStandeesSettingChange() { + if (_settings.noStandees) { + for (final item in _gameState.currentList) { + if (item is Monster) { + item.clearMonsterInstances(stateAccess); + item.notifyMonsterInstances(stateAccess); + } + } + } else { + for (final item in _gameState.currentList) { + if (item is Monster && item.isActive) { + item.setActive(stateAccess, false); + } + } + } + _gameState.notifyListeners(); + } +} |
