summaryrefslogtreecommitdiff
path: root/server/lib/core/commands/set_as_summon_command.dart
blob: 0337001bf0c047db6ac820b04cfce97aa5bd5bdd (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
35
36
37
import '../game_methods.dart';
import '../state/game_state.dart';
import 'command_l10n.dart';

class SetAsSummonCommand extends Command {
  final bool summoned;
  final String? ownerId;
  final String figureId;
  final GameState _gameState;

  SetAsSummonCommand(
    this.summoned,
    this.figureId,
    this.ownerId, {
    required GameState gameState,
  }) : _gameState = gameState;

  @override
  void execute() {
    final figure = GameMethods.getFigure(ownerId, figureId);
    if (figure is! MonsterInstance) return;
    if (summoned) {
      figure.setRoundSummoned(stateAccess, _gameState.round);
    } else {
      figure.setRoundSummoned(stateAccess, -1);
    }
    _gameState.notifyListeners();
  }

  @override
  String describe() {
    if (summoned) {
      return commandL10n.cmdMarkAsSummon(ownerId ?? '');
    }
    return commandL10n.cmdRemoveSummonMark(ownerId ?? '');
  }
}