blob: 2e47bba2075af501349bf2ae3d6f15a6e271b6b8 (
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
|
import 'package:collection/collection.dart';
import '../state/game_state.dart';
import 'command_l10n.dart';
/// Attaches a note to a figure (character or monster) by [linkedId], optionally
/// pinned to [standeeNr] for a monster standee, or detaches it when [linkedId]
/// is empty. The list's reflow step repositions the note accordingly.
class SetNoteRowLinkCommand extends Command {
SetNoteRowLinkCommand(
this.noteId,
this.linkedId,
this.standeeNr, {
required GameState gameState,
}) : _gameState = gameState;
final String noteId;
final String linkedId;
final int standeeNr;
final GameState _gameState;
@override
void execute() {
final match = _gameState.currentList.firstWhereOrNull(
(element) => element.id == noteId,
);
if (match is NoteRow) {
match.setLink(stateAccess, linkedId, standeeNr);
}
}
@override
String describe() {
return commandL10n.cmdLinkNoteRow;
}
}
|