mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 00:32:40 +00:00
B4: Slot classifier no longer treats "Springing" / "Snaring" / "Devouring"
as ring matches; tokenises by word boundary instead of raw substring.
Adds DnDSlotCloak so cloaks/capes/mantles/wings stop evicting body armor
from the chest slot. Regenerated magic_items_srd_data.go: boots_of_*,
gloves_of_missile_snaring, bag_of_devouring, talismans, and 6 cloaks all
land in the right slot.
R4: equipMagicItem swap-back returns the prior occupant at full Value
instead of half — swapping a curio shouldn't tax it.
R5: Attunement count is recomputed *after* the swap-back so freeing the
prior occupant's bond opens the slot for the incoming item.
R1: Inventory tags magic_item rows with 🔮 + rarity label and prints a
single equip-magic footer when any are present.
R6: Sheet's Magic Items block marks unbonded items as **(inactive)**
with the reason (cap full vs unbonded), so over-cap items aren't silent.
R7: New activeMagicItemsLine surfaces a one-shot "your curios stir: …"
at combat-start in both the dungeon path and !fight, mirroring the way
class passives are surfaced.
R8/R9: dropMagicItemLoot pretty-prints rarity, drops "wondrous", calls
attunement "needs bonding", appends "auto-uses in combat" for
potions/scrolls, and routes persistence errors to slog instead of
leaking %v into chat.
R2/R3: Curios shelf now shows "Very Rare" not "very_rare", drops the
bare "wondrous" word (the effect line carries it), renders the codified
magicItemEffectSummary above the SRD desc, and ends with a one-line
plain-language "what is bonding" footnote.
R10: Curios stock day flips at 06:00 UTC instead of midnight so EU
players don't see a fresh shelf at 1 a.m. mid-session.
R11: Curios buy resolver disambiguates fuzzy matches — typing "ring"
when several rings are on the shelf lists candidates instead of
silently selling the first.
P1: Greeting grid pairs Curios with an Exit chip so the 2-column
emoji layout doesn't dangle.
P2: Equip-magic empty state trimmed to one line.
P4 (back-from-curios reprompt) deferred — the existing back-flow is
correct, just verbose; not worth the surface-area expansion this
session.
Tests: word-boundary classifier, cloak/chest coexistence, full-value
swap-back. go test ./... + go vet clean.
91 lines
2.3 KiB
Go
91 lines
2.3 KiB
Go
package plugin
|
|
|
|
import "testing"
|
|
|
|
func TestMapLegacySlot(t *testing.T) {
|
|
cases := []struct {
|
|
legacy EquipmentSlot
|
|
want DnDSlot
|
|
}{
|
|
{SlotWeapon, DnDSlotMainHand},
|
|
{SlotArmor, DnDSlotChest},
|
|
{SlotHelmet, DnDSlotHead},
|
|
{SlotBoots, DnDSlotFeet},
|
|
{SlotTool, DnDSlotOffHand},
|
|
}
|
|
for _, c := range cases {
|
|
if got := mapLegacySlot(c.legacy); got != c.want {
|
|
t.Errorf("mapLegacySlot(%s) = %s, want %s", c.legacy, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestInferRarity(t *testing.T) {
|
|
cases := []struct {
|
|
tier int
|
|
masterwork bool
|
|
arenaTier int
|
|
want DnDRarity
|
|
}{
|
|
{1, false, 0, RarityCommon},
|
|
{2, false, 0, RarityCommon},
|
|
{3, false, 0, RarityUncommon},
|
|
{4, false, 0, RarityUncommon},
|
|
{5, false, 0, RarityRare},
|
|
{6, false, 0, RarityRare},
|
|
{7, false, 0, RarityEpic},
|
|
{9, false, 0, RarityLegendary},
|
|
// Masterwork bumps to Rare/Epic
|
|
{2, true, 0, RarityRare},
|
|
{6, true, 0, RarityEpic},
|
|
// Arena set
|
|
{3, false, 1, RarityUncommon},
|
|
{3, false, 3, RarityRare},
|
|
{3, false, 4, RarityEpic},
|
|
{3, false, 5, RarityLegendary},
|
|
}
|
|
for _, c := range cases {
|
|
got := inferRarity(c.tier, c.masterwork, c.arenaTier)
|
|
if got != c.want {
|
|
t.Errorf("inferRarity(t=%d mw=%v arena=%d) = %s, want %s",
|
|
c.tier, c.masterwork, c.arenaTier, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestRarityIcon(t *testing.T) {
|
|
for _, r := range []DnDRarity{RarityCommon, RarityUncommon, RarityRare, RarityEpic, RarityLegendary} {
|
|
if rarityIcon(r) == "" {
|
|
t.Errorf("rarityIcon(%s) returned empty string", r)
|
|
}
|
|
}
|
|
if rarityIcon("Bogus") != "" {
|
|
t.Error("rarityIcon for unknown rarity should be empty")
|
|
}
|
|
}
|
|
|
|
func TestEquipmentRarity_NilSafety(t *testing.T) {
|
|
if got := equipmentRarity(nil); got != RarityCommon {
|
|
t.Errorf("equipmentRarity(nil) = %s, want Common", got)
|
|
}
|
|
}
|
|
|
|
func TestDnDSlotOrderComplete(t *testing.T) {
|
|
// Every D&D slot is in the order list exactly once.
|
|
seen := map[DnDSlot]bool{}
|
|
for _, s := range dndSlotOrder {
|
|
if seen[s] {
|
|
t.Errorf("dndSlotOrder has duplicate %s", s)
|
|
}
|
|
seen[s] = true
|
|
}
|
|
expected := []DnDSlot{
|
|
DnDSlotHead, DnDSlotChest, DnDSlotCloak, DnDSlotLegs, DnDSlotHands, DnDSlotFeet,
|
|
DnDSlotMainHand, DnDSlotOffHand,
|
|
DnDSlotRing1, DnDSlotRing2, DnDSlotAmulet,
|
|
}
|
|
if len(seen) != len(expected) {
|
|
t.Errorf("dndSlotOrder size = %d, want %d", len(seen), len(expected))
|
|
}
|
|
}
|