From 0530c7aa9473f9878e3fba86ed745de7d1056cf9 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 23 Nov 2026 20:09:13 +0100 Subject: server: replace the scenario getter/setter with a direct field --- server/lib/core/methods/scenario_methods.dart | 2 +- server/lib/core/state/game_save_state.dart | 2 +- server/lib/core/state/game_state.dart | 15 ++++++--------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/server/lib/core/methods/scenario_methods.dart b/server/lib/core/methods/scenario_methods.dart index a75fc80..fb6368d 100644 --- a/server/lib/core/methods/scenario_methods.dart +++ b/server/lib/core/methods/scenario_methods.dart @@ -104,7 +104,7 @@ class ScenarioMethods { gs._sanctuaryDeck._initDeck(); RoundMethods.setRoundState(s, RoundState.chooseInitiative); - gs._scenario = scenario; + gs.scenario = scenario; gs._scenarioSectionsAdded = []; final List newList = []; diff --git a/server/lib/core/state/game_save_state.dart b/server/lib/core/state/game_save_state.dart index e5f25ff..87886fa 100644 --- a/server/lib/core/state/game_save_state.dart +++ b/server/lib/core/state/game_save_state.dart @@ -21,7 +21,7 @@ class GameSaveState { final data = json.decode(_savedState ?? '') as Map; gameState._level = data['level'] as int; - gameState._scenario = data['scenario']; // as String; + gameState.scenario = data['scenario']; // as String; if (data.containsKey('toastMessage')) { gameState._toastMessage = data['toastMessage']; // as String; } diff --git a/server/lib/core/state/game_state.dart b/server/lib/core/state/game_state.dart index 903cc51..c57f03c 100644 --- a/server/lib/core/state/game_state.dart +++ b/server/lib/core/state/game_state.dart @@ -65,7 +65,10 @@ class GameState { bool _autoScenarioLevel = false; bool _allyDeckInOGGloom = true; int _difficulty = 1; - String _scenario = ""; + /// Direct set for tests (mirrors the reference app's writable + /// `ValueNotifier` scenario, which its tests wrote to in order to + /// bypass `SetScenarioCommand`'s side effects). + String scenario = ""; String _toastMessage = ""; bool _showAllyDeck = false; List? pendingAutoAddDialog; @@ -95,12 +98,6 @@ class GameState { bool get allyDeckInOGGloom => _allyDeckInOGGloom; int get difficulty => _difficulty; String get toastMessage => _toastMessage; - String get scenario => _scenario; - - /// Direct set for tests (mirrors the reference app's writable - /// `ValueNotifier` scenario, which its tests wrote to in order to - /// bypass `SetScenarioCommand`'s side effects). - set scenario(String value) => _scenario = value; bool get showAllyDeck => _showAllyDeck; int get scenarioSectionsVersion => _scenarioSectionsVersion; @@ -212,7 +209,7 @@ class GameState { } void setScenario(_StateModifier _, String value) { - _scenario = value; + scenario = value; } void setToastMessage(_StateModifier _, String value) { @@ -235,7 +232,7 @@ class GameState { 'roundState': _roundState.index, 'round': _round, 'totalRounds': _totalRounds, - 'scenario': _scenario, + 'scenario': scenario, 'toastMessage': _toastMessage, 'scenarioSpecialRules': _scenarioSpecialRules .map((r) => r.toJson()) -- cgit v1.3.1