summaryrefslogtreecommitdiff
path: root/server/lib/core/commands/remove_amd_card_command.dart
blob: 270066004f86cea0626d2e0d45d97bf095fa45d9 (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
import '../game_methods.dart';
import '../state/game_state.dart';
import 'command_l10n.dart';

class RemoveAMDCardCommand extends Command {
  final int index;
  final String name;
  final GameState _gameState;
  final bool fromDrawPile;

  RemoveAMDCardCommand({
    required this.index,
    required this.name,
    required GameState gameState,
    this.fromDrawPile = false,
  }) : _gameState = gameState;
  @override
  void execute() {
    final deck = GameMethods.getModifierDeck(name, _gameState);
    if (fromDrawPile) {
      if (index >= deck.drawPileSize) return;
      deck.removeCardFromDrawPile(stateAccess, index);
    } else {
      if (index >= deck.discardPileSize) return;
      deck.removeCardFromDiscard(stateAccess, index);
    }
  }

  @override
  String describe() {
    return commandL10n.cmdRemoveAmdCard;
  }
}