Adv 2.0 L4e reader flip (read-only sites): house state via loadHouseState

dnd_rest long-rest eligibility, dnd_sheet housing display, and
petShouldArrive / mistyHousingHint now source house state from
player_meta via loadHouseState(userID) instead of *AdventureCharacter.
petShouldArrive, mistyHousingHint, and renderDnDSheet gained a
HouseState parameter; scheduler and Misty NPC callers load it.
Reader flip inside adventure_housing.go itself stays deferred — its
mutation paths bundle with cutting AdvCharacter writes post-soak.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-05-09 10:42:59 -07:00
parent c719b30fd7
commit 0004a2e35c
8 changed files with 42 additions and 32 deletions

View File

@@ -334,7 +334,8 @@ This is also the right shape because zone-boss plumbing (bestiary, mood events,
- Backfill: `backfillPlayerMetaHouseState()` runs on every Init; idempotent (only fills rows whose `house_tier` and `house_loan_balance` are both still the default zero, and the legacy AdvCharacter row has either tier > 0 or loan > 0).
- Tests: `TestPlayerMetaHouseStateBackfill_Idempotent`, `TestLoadHouseState_FallsBackToAdvCharacter`, `TestUpsertPlayerMetaHouseState_RoundTrip` in `player_meta_test.go` (skip without prod DB, matching the L4d pattern).
- `go vet ./...` + `go test ./...` clean.
- **Reader flip deferred.** Reads in `adventure_housing.go`, `dnd_rest.go`, `dnd_sheet.go`, `adventure_pets.go` still go through `*AdventureCharacter`. Flipping them to `loadHouseState(userID)` is a separate session; the DB-level migration (this step) is the prerequisite.
- **Reader flip (read-only sites) SHIPPED 2026-05-09.** `dnd_rest.go` long-rest housing eligibility, `dnd_sheet.go` housing-tier display, and `adventure_pets.go::petShouldArrive`/`mistyHousingHint` now read via `loadHouseState(userID)` (fallback to AdvCharacter inside the helper). `petShouldArrive` and `mistyHousingHint` gained a `HouseState` parameter; callers in `adventure_scheduler.go` and `adventure_npcs.go` load it. `renderDnDSheet` gained a `HouseState` parameter; test callers in `dnd_subclass_test.go` pass `HouseState{}`. Tests in `adventure_pets_test.go` updated to pass `HouseState`. `go vet ./... && go test ./...` clean.
- **Reader flip in `adventure_housing.go` itself still deferred.** Mutation paths (`handleThomBuy`, `handleThomPayoff`, `handleThomPay`, `handleThomAutopay`, `processMortgagePayments`, `sendMortgageRateChangeDMs`) read-then-write `char.House*` in place; flipping these is bundled with cutting the AdvCharacter writes (post-soak), not now.
### 6.6 L4f — TwinBee/render
- `adventure_render.go`: morning DM reads from DnDCharacter + `player_meta`. Coop teaser gating moves to DnDCharacter.Level.