summaryrefslogtreecommitdiff
path: root/server/lib/core/commands/add_faction_card_command.dart
blob: 6848c9db0c88023a8d28566c5a24e025d3f9ba87 (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
29
30
31
32
33
34
import '../game_methods.dart';
import '../state/game_state.dart';
import 'command_l10n.dart';

class AddFactionCardCommand extends Command {
  final String characterId;
  final String cardId;
  final bool add;
  final GameState _gameState;

  AddFactionCardCommand(
    this.characterId,
    this.cardId,
    this.add, {
    required GameState gameState,
  }) : _gameState = gameState;

  @override
  void execute() {
    final ModifierDeck deck = GameMethods.getModifierDeck(characterId, _gameState);
    if (add) {
      deck.addCard(stateAccess, cardId, CardType.add);
    } else {
      deck.removeCard(stateAccess, cardId);
    }
  }

  @override
  String describe() {
    return add
        ? commandL10n.cmdAddFactionCard(characterId)
        : commandL10n.cmdRemoveFactionCard(characterId);
  }
}