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:
@@ -72,11 +72,11 @@ func TestReadEnchantArmor(t *testing.T) {
|
||||
ch := give(g, scr)
|
||||
g.scr.term.(*testTerm).input = []byte{ch}
|
||||
|
||||
before := g.Player.CurArmor.Arm
|
||||
before := g.Player.CurArmor.ArmorClass
|
||||
g.readScroll()
|
||||
if g.Player.CurArmor.Arm != before-1 {
|
||||
if g.Player.CurArmor.ArmorClass != before-1 {
|
||||
t.Errorf("enchant armor: AC %d -> %d, want %d",
|
||||
before, g.Player.CurArmor.Arm, before-1)
|
||||
before, g.Player.CurArmor.ArmorClass, before-1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,12 +139,12 @@ func TestZapSlowMonster(t *testing.T) {
|
||||
g.scr.term.(*testTerm).input = []byte{ch}
|
||||
g.Delta = Coord{X: 1, Y: 0} // aim at the monster
|
||||
|
||||
charges := stick.Charges()
|
||||
charges := stick.Charges
|
||||
g.doZap()
|
||||
if !tp.On(Slowed) {
|
||||
t.Error("slow monster wand did not slow")
|
||||
}
|
||||
if stick.Charges() != charges-1 {
|
||||
if stick.Charges != charges-1 {
|
||||
t.Error("zap did not use a charge")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user