Un-overload Object fields and pre-parse damage dice (refactor step 3)

Object.Arm carried four meanings in C (o_arm/o_charges/o_goldval plus
ring bonuses); it is now four fields: ArmorClass, Charges, GoldValue,
and Bonus. Stats.Arm becomes Stats.ArmorClass. The Charges()/GoldVal()
accessor pair is gone.

Damage dice strings ("1x4/1x2") are parsed once into DiceSpec — at
table definition for the bestiary and weapon tables, at creation for
items — instead of re-parsed with atoi on every swing as fight.c
roll_em did. ParseDice preserves the C parse semantics exactly,
including the junk-tolerant "%%%x0" bestiary placeholder and the
"000x0" flytrap reset (regression-tested in dice_test.go); the
flytrap's growing grip becomes DiceSpec{{VfHit, 1}}.

Save format bumps to 5.4.4-go3 (field renames and retypes would
silently zero under gob's match-by-name decoding).

No behavior change; full suite green.
This commit is contained in:
2026-07-06 23:07:57 +02:00
parent c75af2ec22
commit 2eff377a73
28 changed files with 268 additions and 186 deletions

View File

@@ -38,12 +38,12 @@ func (g *RogueGame) createObj() {
obj.HPlus += g.rnd(3) + 1
}
} else {
obj.Arm = aClass[obj.Which]
obj.ArmorClass = aClass[obj.Which]
if bless == '-' {
obj.Arm += g.rnd(3) + 1
obj.ArmorClass += g.rnd(3) + 1
}
if bless == '+' {
obj.Arm -= g.rnd(3) + 1
obj.ArmorClass -= g.rnd(3) + 1
}
}
case obj.Kind == KindRing:
@@ -54,9 +54,9 @@ func (g *RogueGame) createObj() {
g.Msgs.Mpos = 0
if bless == '-' {
obj.Flags.Set(Cursed)
obj.Arm = -1
obj.Bonus = -1
} else {
obj.Arm = g.rnd(2) + 1
obj.Bonus = g.rnd(2) + 1
}
case RingAggravateMonsters, RingTeleportation:
obj.Flags.Set(Cursed)
@@ -67,7 +67,7 @@ func (g *RogueGame) createObj() {
g.msg("how much?")
buf := ""
if g.getStr(&buf, g.scr.Std) == Norm {
obj.SetGoldVal(cAtoi(buf))
obj.GoldValue = cAtoi(buf)
}
}
g.addPack(obj, false)
@@ -169,7 +169,7 @@ func (g *RogueGame) teleport() {
if p.On(Held) {
p.Flags.Clear(Held)
p.VfHit = 0
g.Monsters['F'-'A'].Stats.Dmg = "000x0"
g.Monsters['F'-'A'].Stats.Dmg = dice("000x0")
}
g.NoMove = 0
g.Count = 0