summaryrefslogtreecommitdiff
path: root/server/lib/core/commands/unlock_special_command.dart
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/core/commands/unlock_special_command.dart')
-rw-r--r--server/lib/core/commands/unlock_special_command.dart32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/lib/core/commands/unlock_special_command.dart b/server/lib/core/commands/unlock_special_command.dart
new file mode 100644
index 0000000..546b7ff
--- /dev/null
+++ b/server/lib/core/commands/unlock_special_command.dart
@@ -0,0 +1,32 @@
+import '../state/game_state.dart';
+import 'command_l10n.dart';
+
+class UnlockSpecialCommand extends Command {
+ final GameState _gameState;
+ final String _id;
+ bool _unlock = true;
+
+ UnlockSpecialCommand(this._id, {required GameState gameState})
+ : _gameState = gameState;
+
+ @override
+ void execute() {
+ if (_gameState.unlockedClasses.contains(_id)) {
+ _unlock = false;
+ ScenarioMethods.clearUnlockedClass(stateAccess, _id);
+ } else {
+ ScenarioMethods.unlockClass(stateAccess, _id);
+ }
+ }
+
+ @override
+ void onUndo();
+
+ @override
+ String describe() {
+ if (_unlock) {
+ return commandL10n.cmdUnlock(_id);
+ }
+ return commandL10n.cmdLock(_id);
+ }
+}