Pure rename, no behavior change; the full suite (RNG goldens,
generation invariants, scripted sessions, save round trip) is
unchanged and green.
- Creature flags: IsHuh→Confused, IsHalu→Hallucinating,
CanHuh→CanConfuse, CanSee→CanSeeInvisible, IsRun→Awake,
SeeMonst→SenseMonsters, IsCanc→Cancelled, IsLevit→Levitating,
IsBlind/IsGreed/IsHaste/IsTarget/IsHeld/IsInvis/IsMean/IsRegen/
IsFly/IsSlow → Blind/Greedy/Hasted/Targeted/Held/Invisible/Mean/
Regenerates/Flying/Slowed, IsFound→Found
- Object flags: IsCursed→Cursed, IsKnow→Known, IsMissl→Missile,
IsMany→Stackable, ObjIsFound→WasFound, IsProt→Protected
- Room flags: IsDark/IsGone/IsMaze → Dark/Gone/Maze; place flags:
FPass→FPassage, FPNum→FPassNum, FTMask→FTrapMask
- Trap types: TDoor→TrapDoor ... TMyst→TrapMystery
- Item subtypes: P*→Potion* (PLSD→PotionLSD, PMFind→
PotionDetectMonsters, ...), S*→Scroll* (SIDRorS→
ScrollIdentifyRingOrStick, ...), R*→Ring* (RAddHit→RingDexterity,
RNop→RingAdornment, ...), Ws*→Wand* (WsElect→WandLightning, ...),
weapons (TwoSword→WeaponTwoHandedSword, Shiraken→WeaponShuriken,
...), armor (RingMail→ArmorRingMail, ...)
- Counts: Max{Potions,Scrolls,Rings,Sticks,Weapons,Armors} →
Num{Potion,Scroll,Ring,Wand,Weapon,Armor}Types; NTraps→NumTrapTypes
- Level.NTraps field → TrapCount (also in the save snapshot)
- Original C constant names preserved as comment breadcrumbs in
types.go so the lineage stays greppable
TODO.md: step 1 moved to Completed, step 2 (typed kinds) promoted to
Next Step.
175 lines
3.4 KiB
Go
175 lines
3.4 KiB
Go
package game
|
|
|
|
import "fmt"
|
|
|
|
// rings.c — routines dealing specifically with rings.
|
|
|
|
// ringOn puts a ring on a hand (rings.c ring_on).
|
|
func (g *RogueGame) ringOn() {
|
|
p := &g.Player
|
|
obj := g.getItem("put on", int(Ring))
|
|
// Make certain that it is something that we want to wear
|
|
if obj == nil {
|
|
return
|
|
}
|
|
if obj.Type != Ring {
|
|
if !g.Options.Terse {
|
|
g.msg("it would be difficult to wrap that around a finger")
|
|
} else {
|
|
g.msg("not a ring")
|
|
}
|
|
return
|
|
}
|
|
|
|
// find out which hand to put it on
|
|
if g.isCurrent(obj) {
|
|
return
|
|
}
|
|
|
|
var ring int
|
|
switch {
|
|
case p.CurRing[Left] == nil && p.CurRing[Right] == nil:
|
|
if ring = g.gethand(); ring < 0 {
|
|
return
|
|
}
|
|
case p.CurRing[Left] == nil:
|
|
ring = Left
|
|
case p.CurRing[Right] == nil:
|
|
ring = Right
|
|
default:
|
|
if !g.Options.Terse {
|
|
g.msg("you already have a ring on each hand")
|
|
} else {
|
|
g.msg("wearing two")
|
|
}
|
|
return
|
|
}
|
|
p.CurRing[ring] = obj
|
|
|
|
// Calculate the effect it has on the poor guy.
|
|
switch obj.Which {
|
|
case RingAddStrength:
|
|
g.chgStr(obj.Arm)
|
|
case RingSeeInvisible:
|
|
g.invisOn()
|
|
case RingAggravateMonsters:
|
|
g.aggravate()
|
|
}
|
|
|
|
if !g.Options.Terse {
|
|
g.addmsg("you are now wearing ")
|
|
}
|
|
g.msg("%s (%c)", g.invName(obj, true), obj.PackCh)
|
|
}
|
|
|
|
// ringOff takes off a ring (rings.c ring_off).
|
|
func (g *RogueGame) ringOff() {
|
|
p := &g.Player
|
|
var ring int
|
|
switch {
|
|
case p.CurRing[Left] == nil && p.CurRing[Right] == nil:
|
|
if g.Options.Terse {
|
|
g.msg("no rings")
|
|
} else {
|
|
g.msg("you aren't wearing any rings")
|
|
}
|
|
return
|
|
case p.CurRing[Left] == nil:
|
|
ring = Right
|
|
case p.CurRing[Right] == nil:
|
|
ring = Left
|
|
default:
|
|
if ring = g.gethand(); ring < 0 {
|
|
return
|
|
}
|
|
}
|
|
g.Msgs.Mpos = 0
|
|
obj := p.CurRing[ring]
|
|
if obj == nil {
|
|
g.msg("not wearing such a ring")
|
|
return
|
|
}
|
|
if g.dropCheck(obj) {
|
|
g.msg("was wearing %s(%c)", g.invName(obj, true), obj.PackCh)
|
|
}
|
|
}
|
|
|
|
// gethand asks which hand the hero is interested in (rings.c gethand).
|
|
func (g *RogueGame) gethand() int {
|
|
for {
|
|
if g.Options.Terse {
|
|
g.msg("left or right ring? ")
|
|
} else {
|
|
g.msg("left hand or right hand? ")
|
|
}
|
|
c := g.readchar()
|
|
if c == Escape {
|
|
return -1
|
|
}
|
|
g.Msgs.Mpos = 0
|
|
if c == 'l' || c == 'L' {
|
|
return Left
|
|
}
|
|
if c == 'r' || c == 'R' {
|
|
return Right
|
|
}
|
|
if g.Options.Terse {
|
|
g.msg("L or R")
|
|
} else {
|
|
g.msg("please type L or R")
|
|
}
|
|
}
|
|
}
|
|
|
|
// ringUses is the rings.c ring_eat static uses[] table: how much food each
|
|
// ring type uses up per turn (negative = a 1-in-n chance of 1).
|
|
var ringUses = [NumRingTypes]int{
|
|
1, // R_PROTECT
|
|
1, // R_ADDSTR
|
|
1, // R_SUSTSTR
|
|
-3, // R_SEARCH
|
|
-5, // R_SEEINVIS
|
|
0, // R_NOP
|
|
0, // R_AGGR
|
|
-3, // R_ADDHIT
|
|
-3, // R_ADDDAM
|
|
2, // R_REGEN
|
|
-2, // R_DIGEST
|
|
0, // R_TELEPORT
|
|
1, // R_STEALTH
|
|
1, // R_SUSTARM
|
|
}
|
|
|
|
// ringEat reports how much food the ring on the given hand uses up
|
|
// (rings.c ring_eat).
|
|
func (g *RogueGame) ringEat(hand int) int {
|
|
ring := g.Player.CurRing[hand]
|
|
if ring == nil {
|
|
return 0
|
|
}
|
|
eat := ringUses[ring.Which]
|
|
if eat < 0 {
|
|
if g.rnd(-eat) == 0 {
|
|
eat = 1
|
|
} else {
|
|
eat = 0
|
|
}
|
|
}
|
|
if ring.Which == RingSlowDigestion {
|
|
eat = -eat
|
|
}
|
|
return eat
|
|
}
|
|
|
|
// ringNum prints ring bonuses (rings.c ring_num).
|
|
func ringNum(g *RogueGame, obj *Object) string {
|
|
if !obj.Flags.Has(Known) {
|
|
return ""
|
|
}
|
|
switch obj.Which {
|
|
case RingProtection, RingAddStrength, RingIncreaseDamage, RingDexterity:
|
|
return fmt.Sprintf(" [%s]", num(obj.Arm, 0, Ring))
|
|
}
|
|
return ""
|
|
}
|