Adv 2.0 D&D layer: Phases 1-8 + Phase 9 SP1+SP2

Combines all uncommitted D&D work into one checkpoint:

Phases 1-8 (per gogobee_dnd_session_summary.md):
- Race/class/stats system, !setup flow, !sheet, !respec
- d20-vs-AC combat with race/class passives, auto-migration
- XP/level-up, skill checks, NPC refund hooks
- Equipment slot mapping, rarity, !rest short/long
- Pre-arm active abilities, resource pools
- Bestiary, !roll/!stats/!level, onboarding DM
- Audit fixes A-I, flavor wiring under internal/flavor/
- Phase 8 weapon dice + armor AC tables (gogobee_equipment_appendix)

Phase 9 SP1 — spell system foundations:
- 79 SpellDefinitions (76 in-scope + 3 reaction-deferred)
- dnd_known_spells, dnd_spell_slots tables
- pending_cast / concentration_* columns on dnd_character
- Slot tables for Mage/Cleric/Ranger, DC + attack-bonus math
- Long-rest refreshes slots; respec wipes spell state
- Auto-grant default known list on !setup confirm and auto-migration

Phase 9 SP2 — !cast / !spells / !prepare commands:
- Out-of-combat HEAL and UTILITY resolve immediately
- Damage/control/buff queue as pending_cast for next combat
- Audit-style save-then-debit, slot refund on save failure
- !cast --drop, concentration supersession, prep-cap enforcement
- Reaction spells refused with Phase 11 note

SP3 (combat-time resolution of pending_cast) and SP4 (full prep/learn
tests) are next. Build clean, full test suite green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-05-08 08:21:44 -07:00
parent 8e0fe0230c
commit 9e1a1f606c
80 changed files with 19088 additions and 210 deletions

View File

@@ -841,7 +841,9 @@ func (p *HoldemPlugin) doShowdown(game *HoldemGame) {
// Post end announcement to room and DM each player.
endAnn := renderEndAnnouncement(results, game)
p.SendMessage(game.RoomID, endAnn)
if gameHasPublicRoom(game) {
p.SendMessage(game.RoomID, endAnn)
}
p.broadcastDM(game, endAnn)
// Settle balances.
@@ -874,7 +876,9 @@ func (p *HoldemPlugin) finishHand(game *HoldemGame) {
// Award pot to last remaining player.
ann, winnerID := awardPotToLastPlayer(game)
if ann != "" {
p.SendMessage(game.RoomID, ann)
if gameHasPublicRoom(game) {
p.SendMessage(game.RoomID, ann)
}
p.broadcastDM(game, ann)
}
@@ -980,18 +984,22 @@ func (p *HoldemPlugin) sendTurnNotifications(game *HoldemGame) {
}
}
// broadcastDM delivers msg to each player's channel — their DM room in
// multiplayer, or game.RoomID directly in solo-vs-bot (where the room IS
// the player's DM). Deduplicated by room so callers that also post to
// game.RoomID for spectators (see gameHasPublicRoom) don't cause the solo
// player to see the message twice.
func (p *HoldemPlugin) broadcastDM(game *HoldemGame, msg string) {
sent := map[id.RoomID]bool{}
first := true
for _, pl := range game.Players {
if pl.IsNPC || pl.State == PlayerSatOut {
continue
}
// Skip players whose DM room IS the game room — they already saw
// the message via the public-room post (solo-vs-bot case, where
// game.RoomID == player's DM).
if pl.DMRoomID == game.RoomID {
if sent[pl.DMRoomID] {
continue
}
sent[pl.DMRoomID] = true
if !first {
// Jitter 150400ms between sends to avoid bursts on the Matrix server.
time.Sleep(150*time.Millisecond + time.Duration(rand.IntN(250))*time.Millisecond)
@@ -1001,6 +1009,17 @@ func (p *HoldemPlugin) broadcastDM(game *HoldemGame, msg string) {
}
}
// gameHasPublicRoom reports whether game.RoomID is a separate public room
// (multiplayer) rather than a player's own DM (solo-vs-bot).
func gameHasPublicRoom(g *HoldemGame) bool {
for _, pl := range g.Players {
if !pl.IsNPC && pl.DMRoomID == g.RoomID {
return false
}
}
return true
}
// --- NPC ---
func (p *HoldemPlugin) npcAct(game *HoldemGame) {