adventure: count the treasures an adventurer has actually found

A treasure_found fact turns loot into a trophy: a story-grade find lands on the
who page as a stat tile, a named row in a Treasures found showcase, and a trail
entry linking back to the dispatch. A realm-first hoard rides the priority tier
the way zone_first does, and gets the same star and callout.

The item name travels in the fact's stakes field, which the events log now keeps
(a new nullable column, backfilled to NULL for older rows). Counting is only ever
from the fact, never the vault snapshot, so a bought sword is never a trophy and a
history that predates the fact is a clean zero.

This is a new event_type, so Pete's ingest must be deployed before gogobee emits
one, or the first finds park forever on the retry ladder.
This commit is contained in:
prosolis
2026-07-17 09:02:19 -07:00
parent 1589c36e96
commit 6219224ea9
10 changed files with 192 additions and 41 deletions

View File

@@ -88,8 +88,8 @@ func seedWho(t *testing.T, owner string) *Server {
Effect: "faster to act, +4 HP", Attunement: true, Attuned: false},
},
Vault: []storage.ItemView{{Name: "Jeweled Crown", Type: "treasure", Tier: 4, Value: 5000}},
House: storage.HouseView{Tier: 2, LoanBalance: 1500},
Pets: []storage.PetView{{Type: "cat", Name: "Mittens", Level: 3}},
House: storage.HouseView{Tier: 2, LoanBalance: 1500},
Pets: []storage.PetView{{Type: "cat", Name: "Mittens", Level: 3}},
}}}); w.Code != 200 {
t.Fatalf("seed detail = %d", w.Code)
}
@@ -110,6 +110,8 @@ func seedHistory(t *testing.T, s *Server) {
Subject: "Josie", Zone: "holymachina", Level: 14, OccurredAt: 300},
{GUID: "milestone:d:4", EventType: "milestone", Tier: "bulletin", Actors: []string{"Josie"},
Subject: "Josie", Milestone: "level 14", OccurredAt: 400},
{GUID: "treasure_found:e:5", EventType: "treasure_found", Tier: "priority", Actors: []string{"Josie"},
Subject: "Josie", Zone: "The Ossuary", Stakes: "Crown of the Drowned King", Outcome: "legendary", OccurredAt: 500},
}
for _, f := range facts {
body, _ := json.Marshal(f)
@@ -298,10 +300,14 @@ func TestWhoHistoryPanels(t *testing.T) {
"The record",
"The Rotmother", // the boss tally
"bosses down",
"realm-first", // the boss_first got flagged
"level 14", // the milestone chip
"realm-first", // the boss_first got flagged
"level 14", // the milestone chip
"treasure", // the treasure stat tile
"Treasures found", // the showcase panel
"Crown of the Drowned King", // the named hoard
"first hoard", // the realm-first callout picked it up
"The trail",
"/adventure/boss_first:a:1", // the trail links back to the dispatch
"/adventure/treasure_found:e:5", // the trail links back to the treasure dispatch
} {
if !strings.Contains(body, want) {
t.Errorf("history render missing %q", want)