diff options
Diffstat (limited to 'server/lib/core/commands/add_perk_command.dart')
| -rw-r--r-- | server/lib/core/commands/add_perk_command.dart | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/lib/core/commands/add_perk_command.dart b/server/lib/core/commands/add_perk_command.dart new file mode 100644 index 0000000..c961e05 --- /dev/null +++ b/server/lib/core/commands/add_perk_command.dart @@ -0,0 +1,28 @@ +import '../game_methods.dart'; +import '../state/game_state.dart'; +import 'command_l10n.dart'; + +class AddPerkCommand extends Command { + final String characterId; + final int index; + + AddPerkCommand(this.characterId, this.index); + + @override + void execute() { + Character? character = GameMethods.getCharacterByName(characterId); + if (character != null) { + character.flipPerk(stateAccess, index); + } + } + + @override + String describe() { + Character? character = GameMethods.getCharacterByName(characterId); + final charId = character?.id ?? characterId; + if (character != null && !character.characterState.perkList[index]) { + return commandL10n.cmdRemovePerk(charId, index); + } + return commandL10n.cmdAddPerk(charId, index); + } +} |
