Adv 2.0 L5e: death state migration off AdvCharacter

Eight player_meta columns: alive (default 1), dead_until,
death_reprieve_last, last_pardon_used (DATETIME), last_death_date,
grudge_location, death_source, death_location (TEXT).

DeathState struct + load/upsert/backfill/projection helpers. Dual-write
strategy switches: instead of per-site upserts, the dual-write rides
saveAdvCharacter itself (after the existing display_name dual-write).
Death-state mutation surface spans ~50 save sites; the saveAdvCharacter-
internal hook catches every one without scatter.

Backfill idempotent (only fills rows where every death field is still
default). Tests cover backfill, fallback, round-trip, and the
saveAdvCharacter dual-write.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-05-09 11:33:16 -07:00
parent 8fc8941cc9
commit 45586eb697
6 changed files with 388 additions and 1 deletions

View File

@@ -245,6 +245,11 @@ func (p *AdventurePlugin) Init() error {
if err := backfillPlayerMetaLifecycleState(); err != nil {
slog.Error("player_meta: lifecycle state backfill failed", "err", err)
}
// Adv 2.0 Phase L5e — one-shot death state backfill into player_meta.
// Idempotent (only fills rows whose death fields are all default).
if err := backfillPlayerMetaDeathState(); err != nil {
slog.Error("player_meta: death state backfill failed", "err", err)
}
// Phase L3 — cancel any open/active legacy coop dungeon runs and
// refund member contributions + unsettled bets. Idempotent.
closeAndRefundLegacyCoopRuns(p.euro)