From 808294adad3f378ad8d66b698acf8df7f49c2302 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 12 Nov 2026 00:28:50 +0100 Subject: Phase 1: headless game engine on the server (M1) Complete mechanical port of the reference app's game engine to server/lib/core/ so later phases are UI-only: - models/ (7), state/ (GameState + 18 part files), methods/ (7), game_methods, 79 command files, enums, card_stack, stat_calculator, action_handler (index, 250-deep history, save-per-action, undo/redo), disk-based game_data, l10n, translation_service, service_locator - ValueNotifier/ChangeNotifier removed in favor of plain fields with a minimal GameState listener hook for the Phase 2 broadcast layer; shared_preferences replaced by the SaveStore abstraction (InMemory for tests, File-backed for bin/main.dart) - command registry: 82 entries mapping wire names to constructors with arg validation; live-object args (loot/ability cards, figure lists) travel as id/name/nr and resolve against live state, enums by name, injected singletons never serialize - line_builder ported to Phase 1 scope: stat_applier + minimal LineBuilder (isElement, tokens); widget rendering deferred to Phase 4 - ported test suite: 81 test files, 562 tests green (command tests 1:1 with the reference, resource tests, registry smoke tests) - new headless integration test drives a full round: scenario setup, characters + standee, secret-initiative gate, draw, every figure's turn (incl. undo/redo), next round, round 2, round 3 - PORTING.md: the conventions contract used for the port - bin/main.dart boots the engine (file save store, assets/data) before serving; pubspec gains built_collection, collection, get_it, intl - dart format drift on pre-existing net/test files from the current formatter (whitespace only) dart analyze warning-free; dart test 562/562. --- server/lib/core/enums.dart | 120 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 server/lib/core/enums.dart (limited to 'server/lib/core/enums.dart') diff --git a/server/lib/core/enums.dart b/server/lib/core/enums.dart new file mode 100644 index 0000000..590f825 --- /dev/null +++ b/server/lib/core/enums.dart @@ -0,0 +1,120 @@ +import 'package:collection/collection.dart'; +import 'package:x_haven_server/core/state/game_state.dart'; + +import 'game_methods.dart'; + +enum Style { + frosthaven, + gloomhaven, + original, +} // ignore: prefer-match-file-name, file contains multiple shared enums + +enum Condition { + stun, + immobilize, + disarm, + wound, + wound2, + muddle, + poison, + poison2, + poison3, + poison4, + bane, + brittle, + chill, + infect, + impair, + rupture, + plague, + strengthen, + invisible, + regenerate, + ward, + dodge, + safeguard, + + shield, + retaliate, + + character1, + character2, + character3, + character4; + + static const int _kChar1Index = 0; + static const int _kChar2Index = 1; + static const int _kChar3Index = 2; + static const int _kChar4Index = 3; + + String _getCharacterName(int index) { + List characters = GameMethods.getCurrentCharacters(); + characters.sortBy((element) => element.characterClass.name); + if (characters.length > index) { + return characters[index].characterClass.name; + } + + return "Escort"; //some basic + } + + String getName() { + //get current characters, sort by name and add to this + if (this == Condition.character1) { + return _getCharacterName(_kChar1Index); + } else if (this == Condition.character2) { + return _getCharacterName(_kChar2Index); + } else if (this == Condition.character3) { + return _getCharacterName(_kChar3Index); + } else if (this == Condition.character4) { + return _getCharacterName(_kChar4Index); + } + + return name; + } + + @override + String toString() { + return index.toString(); + } +} + +enum ElementState { full, half, inert } + +enum Elements { fire, ice, air, earth, light, dark } + +enum RoundState { chooseInitiative, playTurns } + +enum ListItemState { + chooseInitiative, //gray + waitingTurn, //hopeful + myTurn, //conditions reminder (above in list is gray) + doneTurn, //gray, expire conditions +} + +enum MonsterType { normal, elite, boss, summon } + +enum TurnsState { + notDone, //if got condition while in this state or from earlier round: remove at end of current + current, //mark conditions added here to not be removed yet + done, //mark conditions added here to not be removed yet +} + +enum NetworkMessage { init, action, undo, redo } + +/// Escalating tiers of display power saving. Each tier is a superset of the +/// previous one in how much battery it saves and how much it gets in the way. +enum PowerMode { + /// Screen held awake at full brightness for as long as the app is open. + normal, + + /// Screen still held awake — the app never locks and you never lose your + /// place — but after a period with no input the app dims itself. Sits + /// between [normal] and [reducePower]: saves real power on OLED without + /// handing the display over to the system Auto-Lock timer. + dimWhenIdle, + + /// Releases the wakelock so the system dims and sleeps the display on its + /// own schedule, and lowers the cost of shadows, image filtering and + /// looping text animations. + reducePower, +} -- cgit v1.3.1