summaryrefslogtreecommitdiff
path: root/server/lib/core/commands/add_perk_command.dart
blob: c961e05abb0f558420328db7d440c75b105b2b94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
  }
}