diff options
Diffstat (limited to 'server')
| -rw-r--r-- | server/bin/main.dart | 2 | ||||
| -rw-r--r-- | server/lib/core/state/loot_deck_state.dart | 16 | ||||
| -rw-r--r-- | server/lib/core/state/modifier_deck.dart | 15 | ||||
| -rw-r--r-- | server/lib/net/app.dart | 11 |
4 files changed, 43 insertions, 1 deletions
diff --git a/server/bin/main.dart b/server/bin/main.dart index f864828..7be16e2 100644 --- a/server/bin/main.dart +++ b/server/bin/main.dart @@ -43,6 +43,8 @@ Future<void> main(List<String> args) async { // The client's menus and artwork read the same assets the engine loads. dataDir: 'assets/data/', imageDir: 'assets/images/', + // In-game ability-text translations for the client's card renderer. + i18nDir: 'assets/i18n/', ); stdout ..writeln('X-Haven server listening on http://localhost:${server.port}') diff --git a/server/lib/core/state/loot_deck_state.dart b/server/lib/core/state/loot_deck_state.dart index 31c6df7..ccd1003 100644 --- a/server/lib/core/state/loot_deck_state.dart +++ b/server/lib/core/state/loot_deck_state.dart @@ -566,6 +566,22 @@ class LootDeck { 'enhancements': _enhancements, '1418': _hasCard1418, '1419': _hasCard1419, + // Pool card ids only: pool cards are the same live instances that enter + // the draw/discard piles (and mutate with them), so their full JSON would + // leak those mutations into the static pool. The enhancement menu needs + // the ids plus the `enhancements` map (card id → level). + 'pools': { + 'coin': _coinPool.map((c) => c.id).toList(), + 'lumber': _lumberPool.map((c) => c.id).toList(), + 'hide': _hidePool.map((c) => c.id).toList(), + 'metal': _metalPool.map((c) => c.id).toList(), + 'corpsecap': _corpsecapPool.map((c) => c.id).toList(), + 'arrowvine': _arrowvinePool.map((c) => c.id).toList(), + 'flamefruit': _flamefruitPool.map((c) => c.id).toList(), + 'axenut': _axenutPool.map((c) => c.id).toList(), + 'rockroot': _rockrootPool.map((c) => c.id).toList(), + 'snowthistle': _snowthistlePool.map((c) => c.id).toList(), + }, }; @override diff --git a/server/lib/core/state/modifier_deck.dart b/server/lib/core/state/modifier_deck.dart index 6575e01..b7c00f1 100644 --- a/server/lib/core/state/modifier_deck.dart +++ b/server/lib/core/state/modifier_deck.dart @@ -68,6 +68,10 @@ class ModifierDeck { int get revealedCount => _revealedCount; bool get cassandraSpecial => _cassandraSpecial; + /// The removable-card counter totals (bless / curse / empower / enfeeble + /// variants) — the client's deck-header counters read these. + Map<String, int> get removables => Map.unmodifiable(_removables); + ModifierDeck(this.name) { //build deck _initDeck(); @@ -141,6 +145,16 @@ class ModifierDeck { _addedMinusOnes = modifierDeckData.containsKey('addedMinusOnes') ? modifierDeckData["addedMinusOnes"] as int : 0; + + // The counter totals are the source of truth; the physical-card rebuild + // above already re-derived them for saves written before `removables` + // existed on the wire. + if (modifierDeckData.containsKey('removables')) { + final saved = modifierDeckData['removables'] as Map<String, dynamic>; + for (final key in _removables.keys) { + _removables[key] = (saved[key] as int?) ?? _removables[key]!; + } + } } void setRemovableValue(_StateModifier _, String id, int value) { @@ -551,6 +565,7 @@ class ModifierDeck { 'corrosiveSpew': _corrosiveSpew, 'revealed': _revealedCount, 'cassandra': _cassandraSpecial, + 'removables': _removables, 'drawPile': _drawPile.getList().map((c) => c.toJson()).toList(), 'removedPile': _removedPile.getList().map((c) => c.toJson()).toList(), 'discardPile': _discardPile.getList().map((c) => c.toJson()).toList(), diff --git a/server/lib/net/app.dart b/server/lib/net/app.dart index a38d5c0..8936104 100644 --- a/server/lib/net/app.dart +++ b/server/lib/net/app.dart @@ -24,12 +24,16 @@ final _log = Logger('server'); /// non-null: the client's menus read the campaign/scenario/character/section /// JSON from it (the same files the engine loads). [imageDir] (e.g. /// `assets/images/`) is served at `/images/` when non-null — character and -/// monster artwork for the main list. +/// monster artwork for the main list. [i18nDir] (e.g. `assets/i18n/`) is +/// served at `/i18n/` when non-null — the in-game ability-text translations +/// the client's card renderer resolves (the reference app's +/// `TranslationService`, PLAN.md Phase 4). Handler createHandler({ required String staticDir, required GameServer gameServer, String? dataDir, String? imageDir, + String? i18nDir, }) { final router = Router(); router.get('/ws', createWebSocketUpgradeHandler(gameServer)); @@ -43,6 +47,9 @@ Handler createHandler({ if (imageDir != null) { router.mount('/images/', _createStaticHandler(imageDir, plain: true)); } + if (i18nDir != null) { + router.mount('/i18n/', _createStaticHandler(i18nDir, plain: true)); + } // Session endpoint (PLAN.md section 3.3): returns the caller's persistent // session id, setting the `x-haven-session` cookie when the caller has // none yet. Browsers then carry the cookie on every same-origin request, @@ -72,6 +79,7 @@ Future<HttpServer> startServer({ required GameServer gameServer, String? dataDir, String? imageDir, + String? i18nDir, }) { return shelf_io.serve( createHandler( @@ -79,6 +87,7 @@ Future<HttpServer> startServer({ gameServer: gameServer, dataDir: dataDir, imageDir: imageDir, + i18nDir: i18nDir, ), '0.0.0.0', port, |
