blob: 8510927f4f5429d45d3451519342849eaa1239ab (
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 '../game_methods.dart';
import '../state/game_state.dart';
import 'command_l10n.dart';
class AddCharacterCommand extends Command {
final String _id;
final String _edition;
final int _level;
final String? _display;
Character? character;
AddCharacterCommand(this._id, this._edition, this._display, this._level) {
final created = CharacterMethods.createCharacter(
stateAccess,
_id,
_edition,
_display,
_level,
);
if (created == null) {
throw StateError(
'AddCharacterCommand: character class not found: $_id (edition: $_edition)',
);
}
character = created;
}
@override
void execute() {
final char = character;
if (char == null) return;
//add new character on top of list
RoundMethods.addToMainList(stateAccess, 0, char);
if (!GameMethods.isObjectiveOrEscort(char.characterClass)) {
ScenarioMethods.applyDifficulty(stateAccess);
}
RoundMethods.updateForSpecialRules(stateAccess);
ScenarioMethods.unlockClass(stateAccess, char.characterClass.id);
}
@override
String describe() {
return commandL10n.cmdAddCharacter(_id);
}
}
|