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:
10
game/rip.go
10
game/rip.go
@@ -124,8 +124,8 @@ func (g *RogueGame) totalWinner() {
|
||||
obj.Flags.Set(Known)
|
||||
case KindArmor:
|
||||
worth = it.Armors[obj.Which].Worth
|
||||
worth += (9 - obj.Arm) * 100
|
||||
worth += 10 * (aClass[obj.Which] - obj.Arm)
|
||||
worth += (9 - obj.ArmorClass) * 100
|
||||
worth += 10 * (aClass[obj.Which] - obj.ArmorClass)
|
||||
obj.Flags.Set(Known)
|
||||
case KindScroll:
|
||||
op := &it.Scrolls[obj.Which]
|
||||
@@ -146,8 +146,8 @@ func (g *RogueGame) totalWinner() {
|
||||
worth = op.Worth
|
||||
if obj.RingKind() == RingAddStrength || obj.RingKind() == RingIncreaseDamage ||
|
||||
obj.RingKind() == RingProtection || obj.RingKind() == RingDexterity {
|
||||
if obj.Arm > 0 {
|
||||
worth += obj.Arm * 100
|
||||
if obj.Bonus > 0 {
|
||||
worth += obj.Bonus * 100
|
||||
} else {
|
||||
worth = 10
|
||||
}
|
||||
@@ -160,7 +160,7 @@ func (g *RogueGame) totalWinner() {
|
||||
case KindWand:
|
||||
op := &it.Sticks[obj.Which]
|
||||
worth = op.Worth
|
||||
worth += 20 * obj.Charges()
|
||||
worth += 20 * obj.Charges
|
||||
if !obj.Flags.Has(Known) {
|
||||
worth /= 2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user