blob: c7bfa3e6a0cd5f71a52ce4235b106f0749a80463 (
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
38
39
40
41
42
43
44
45
46
47
|
import '../enums.dart';
import '../game_methods.dart';
import '../state/game_state.dart';
import 'command_l10n.dart';
class RemoveConditionCommand extends Command {
final Condition condition;
final String figureId;
final String? ownerId;
final GameState _gameState;
RemoveConditionCommand(
this.condition,
this.figureId,
this.ownerId, {
required GameState gameState,
}) : _gameState = gameState;
@override
void execute() {
final FigureState? figure = GameMethods.getFigure(ownerId, figureId);
if (figure != null) {
final List<Condition> newList = [];
newList.addAll(figure.conditions);
newList.remove(condition);
figure.setConditions(stateAccess, newList);
if (condition != Condition.chill ||
!figure.conditions.contains(Condition.chill)) {
figure.removeFromConditionsThisTurn(stateAccess, condition);
}
if (condition == Condition.chill) {
figure.setChill(stateAccess, figure.chill - 1);
}
if (condition == Condition.plague) {
figure.setPlague(stateAccess, figure.plague - 1);
}
figure.removeFromConditionsPreviousTurn(stateAccess, condition);
_gameState.notifyListeners();
}
}
@override
String describe() {
return commandL10n.cmdRemoveCondition(condition.getName());
}
}
|