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

@@ -241,7 +241,7 @@ func (g *RogueGame) beTrapped(tc Coord) TrapKind {
p.Flags.Clear(Awake)
g.msg("a strange white mist envelops you and you fall asleep")
case TrapArrow:
if g.swing(p.Stats.Lvl-1, p.Stats.Arm, 1) {
if g.swing(p.Stats.Lvl-1, p.Stats.ArmorClass, 1) {
p.Stats.HP -= g.roll(1, 6)
if p.Stats.HP <= 0 {
g.msg("an arrow killed you")
@@ -263,7 +263,7 @@ func (g *RogueGame) beTrapped(tc Coord) TrapKind {
g.teleport()
g.mvaddch(tc.Y, tc.X, Trap)
case TrapDart:
if !g.swing(p.Stats.Lvl+1, p.Stats.Arm, 1) {
if !g.swing(p.Stats.Lvl+1, p.Stats.ArmorClass, 1) {
g.msg("a small dart whizzes by your ear and vanishes")
} else {
p.Stats.HP -= g.roll(1, 4)
@@ -322,7 +322,7 @@ func (g *RogueGame) rndmove(who *Creature) Coord {
// aren't wearing a magic ring (move.c rust_armor).
func (g *RogueGame) rustArmor(arm *Object) {
if arm == nil || arm.Kind != KindArmor || arm.ArmorKind() == ArmorLeather ||
arm.Arm >= 9 {
arm.ArmorClass >= 9 {
return
}
@@ -331,7 +331,7 @@ func (g *RogueGame) rustArmor(arm *Object) {
g.msg("the rust vanishes instantly")
}
} else {
arm.Arm++
arm.ArmorClass++
if !g.Options.Terse {
g.msg("your armor appears to be weaker now. Oh my!")
} else {