summaryrefslogtreecommitdiff
path: root/server/lib/core/commands/set_note_row_text_command.dart
blob: 2b53cb9301024e4c2001f39329cd255dc2492b4a (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
import 'package:collection/collection.dart';

import '../state/game_state.dart';
import 'command_l10n.dart';

class SetNoteRowTextCommand extends Command {
  SetNoteRowTextCommand(this.text, this.noteId, {required GameState gameState})
    : _gameState = gameState;
  final String text;
  final String noteId;
  final GameState _gameState;

  @override
  void execute() {
    final match = _gameState.currentList.firstWhereOrNull(
      (element) => element.id == noteId,
    );
    if (match is NoteRow) {
      match.setText(stateAccess, text);
    }
  }

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