adventure: give every dispatch a card that looks like what it is
Every dispatch rendered the same image: one violet gradient, a swapped
emoji, a label. A death, a first-ever clear and a legendary hoard were
visually identical — and this image is not decoration. It is the
og:image on every link Pete puts in Matrix and the thumbnail on every
feed card. The most interesting thing that has ever happened in the
realm looked exactly like the most routine.
The card is now keyed on the dispatch GUID instead of the event type,
so the renderer can read the fact behind it and put the actual nouns on
it — the boss's name, the zone, the item, the level. Each family gets
its own palette, and treasure is tinted by the rarity gogobee already
computes and currently spends on an adjective in a sentence.
A realm-first gets visible ceremony. The priority/bulletin split is
already computed upstream and until now it only decided whether Matrix
got pinged; a thing nobody has ever done should also look different
from the ninth time somebody did it. It earns a ribbon on the card and
a badge and a heavier ring in the feed.
Siege cards carry the HP bar, which is the W1 deferral landing. The
siege fact has the boss and the defender count but never the HP, so the
bar comes from the war-room snapshot: the live row while that boss is
still camped, the history once it has closed. When neither has it yet —
the real two-minute window between a win being filed and the push that
explains it — the card renders barless rather than wrong, and caches
for five minutes instead of a day so the unfurl isn't pinned that way.
Nothing needs backfilling. A story with a type-keyed image_url still
serves, and a dispatch with no stored fact degrades to the old emblem.
Two things learned by looking at the rendered output rather than at the
tests, both of which unit tests would never have caught: the feed
thumbnail is a 16/10 crop of a 1200x630 card and was eating the chip
("EGENDARY"), hence advSafeX; and an empty bar under a victory headline
reads at a glance as a wipe, hence the event-aware caption.
Claude-Session: https://claude.ai/code/session_012bxpQQJDjC1mTtLN3VVtBQ
This commit is contained in:
@@ -131,6 +131,49 @@ func ReplaceSiege(s Siege, snapshotAt int64) error {
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
// SiegeBarForBoss finds the HP bar to draw on a siege dispatch's card: current
|
||||
// and max HP for the named boss around the time the dispatch was filed.
|
||||
//
|
||||
// A siege fact carries the boss and the defender count but not the HP, so the
|
||||
// bar has to come from the war-room snapshot. Two places to look, in order:
|
||||
//
|
||||
// - the live row, when that boss is still camped (a siege_start card should
|
||||
// show the bar as it stands right now, and it will keep sliding as the town
|
||||
// chips away);
|
||||
// - the history, for a Siege that has closed — matched on name and then on
|
||||
// the row that ended nearest the dispatch, since the same boss comes back
|
||||
// month after month and only the clock separates the two.
|
||||
//
|
||||
// ok is false when neither has it, which is a real and temporary state: the
|
||||
// win/loss dispatch is filed the moment the Siege resolves, and the history that
|
||||
// explains it doesn't reach Pete until the next 2-minute push. The card renders
|
||||
// without a bar in the meantime rather than drawing a wrong one.
|
||||
func SiegeBarForBoss(boss string, at int64) (current, max int, ok bool) {
|
||||
if boss == "" {
|
||||
return 0, 0, false
|
||||
}
|
||||
var active bool
|
||||
var name string
|
||||
var hpCur, hpMax int
|
||||
err := Get().QueryRow(`
|
||||
SELECT active, boss_name, hp_current, hp_max FROM adventure_siege WHERE id = 1`).
|
||||
Scan(&active, &name, &hpCur, &hpMax)
|
||||
if err == nil && active && name == boss && hpMax > 0 {
|
||||
return hpCur, hpMax, true
|
||||
}
|
||||
|
||||
// ORDER BY the distance from the dispatch, so a boss that has besieged the
|
||||
// town three times resolves to the siege this dispatch is actually about.
|
||||
err = Get().QueryRow(`
|
||||
SELECT hp_remaining, hp_max FROM adventure_siege_history
|
||||
WHERE boss_name = ? AND hp_max > 0
|
||||
ORDER BY ABS(ended_at - ?) ASC LIMIT 1`, boss, at).Scan(&hpCur, &hpMax)
|
||||
if err != nil {
|
||||
return 0, 0, false
|
||||
}
|
||||
return hpCur, hpMax, true
|
||||
}
|
||||
|
||||
// LoadSiege returns the war room as last pushed. ok is false when gogobee has
|
||||
// never pushed one at all — distinct from a pushed snapshot that says no Siege
|
||||
// is camped, which is a real answer the page can render.
|
||||
|
||||
Reference in New Issue
Block a user