Rename constants to descriptive names (refactor step 1)
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.
This commit is contained in:
54
game/move.go
54
game/move.go
@@ -21,7 +21,7 @@ func (g *RogueGame) doMove(dy, dx int) {
|
||||
}
|
||||
// Do a confused move (maybe)
|
||||
var nh Coord
|
||||
if p.On(IsHuh) && g.rnd(5) != 0 {
|
||||
if p.On(Confused) && g.rnd(5) != 0 {
|
||||
nh = g.rndmove(&p.Creature)
|
||||
if nh == p.Pos {
|
||||
g.After = false
|
||||
@@ -52,12 +52,12 @@ over:
|
||||
fl = *g.Level.FlagsAt(nh.Y, nh.X)
|
||||
ch = g.Level.VisibleChar(nh.Y, nh.X)
|
||||
if !fl.Has(FReal) && ch == Floor {
|
||||
if !p.On(IsLevit) {
|
||||
if !p.On(Levitating) {
|
||||
ch = Trap
|
||||
g.Level.SetChar(nh.Y, nh.X, Trap)
|
||||
g.Level.FlagsAt(nh.Y, nh.X).Set(FReal)
|
||||
}
|
||||
} else if p.On(IsHeld) && ch != 'F' {
|
||||
} else if p.On(Held) && ch != 'F' {
|
||||
g.msg("you are being held")
|
||||
return
|
||||
}
|
||||
@@ -67,8 +67,8 @@ over:
|
||||
}
|
||||
switch ch {
|
||||
case ' ', '|', '-':
|
||||
if g.Options.PassGo && g.Running && p.Room.Flags.Has(IsGone) &&
|
||||
!p.On(IsBlind) {
|
||||
if g.Options.PassGo && g.Running && p.Room.Flags.Has(Gone) &&
|
||||
!p.On(Blind) {
|
||||
var b1, b2 bool
|
||||
switch g.RunCh {
|
||||
case 'h', 'l':
|
||||
@@ -109,13 +109,13 @@ over:
|
||||
g.After = false
|
||||
case Door:
|
||||
g.Running = false
|
||||
if g.Level.FlagsAt(p.Pos.Y, p.Pos.X).Has(FPass) {
|
||||
if g.Level.FlagsAt(p.Pos.Y, p.Pos.X).Has(FPassage) {
|
||||
g.enterRoom(nh)
|
||||
}
|
||||
g.moveStuff(nh, fl)
|
||||
case Trap:
|
||||
tr := g.beTrapped(nh)
|
||||
if tr == TDoor || tr == TTelep {
|
||||
if tr == TrapDoor || tr == TrapTeleport {
|
||||
return
|
||||
}
|
||||
g.moveStuff(nh, fl)
|
||||
@@ -151,7 +151,7 @@ over:
|
||||
func (g *RogueGame) moveStuff(nh Coord, fl PlaceFlags) {
|
||||
p := &g.Player
|
||||
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorAt())
|
||||
if fl.Has(FPass) && g.Level.Char(g.Oldpos.Y, g.Oldpos.X) == Door {
|
||||
if fl.Has(FPassage) && g.Level.Char(g.Oldpos.Y, g.Oldpos.X) == Door {
|
||||
g.leaveRoom(nh)
|
||||
}
|
||||
p.Pos = nh
|
||||
@@ -161,7 +161,7 @@ func (g *RogueGame) moveStuff(nh Coord, fl PlaceFlags) {
|
||||
// (move.c turn_ok).
|
||||
func (g *RogueGame) turnOk(y, x int) bool {
|
||||
pp := g.Level.At(y, x)
|
||||
return pp.Ch == Door || pp.Flags&(FReal|FPass) == (FReal|FPass)
|
||||
return pp.Ch == Door || pp.Flags&(FReal|FPassage) == (FReal|FPassage)
|
||||
}
|
||||
|
||||
// turnref decides whether to refresh at a passage turning (move.c turnref).
|
||||
@@ -179,7 +179,7 @@ func (g *RogueGame) turnref() {
|
||||
// doorOpen is called to wake up things in a room that might move when the
|
||||
// hero enters (move.c door_open).
|
||||
func (g *RogueGame) doorOpen(rp *Room) {
|
||||
if rp.Flags.Has(IsGone) {
|
||||
if rp.Flags.Has(Gone) {
|
||||
return
|
||||
}
|
||||
for y := rp.Pos.Y; y < rp.Pos.Y+rp.Max.Y; y++ {
|
||||
@@ -194,24 +194,24 @@ func (g *RogueGame) doorOpen(rp *Room) {
|
||||
// beTrapped makes him pay for stepping on a trap (move.c be_trapped).
|
||||
func (g *RogueGame) beTrapped(tc Coord) int {
|
||||
p := &g.Player
|
||||
if p.On(IsLevit) {
|
||||
return TRust // anything that's not a door or teleport
|
||||
if p.On(Levitating) {
|
||||
return TrapRust // anything that's not a door or teleport
|
||||
}
|
||||
g.Running = false
|
||||
g.Count = 0
|
||||
pp := g.Level.At(tc.Y, tc.X)
|
||||
pp.Ch = Trap
|
||||
tr := int(pp.Flags & FTMask)
|
||||
tr := int(pp.Flags & FTrapMask)
|
||||
pp.Flags.Set(FSeen)
|
||||
switch tr {
|
||||
case TDoor:
|
||||
case TrapDoor:
|
||||
g.Depth++
|
||||
g.NewLevel()
|
||||
g.msg("you fell into a trap!")
|
||||
case TBear:
|
||||
case TrapBear:
|
||||
g.NoMove += g.spread(3) // BEARTIME
|
||||
g.msg("you are caught in a bear trap")
|
||||
case TMyst:
|
||||
case TrapMystery:
|
||||
switch g.rnd(11) {
|
||||
case 0:
|
||||
g.msg("you are suddenly in a parallel dimension")
|
||||
@@ -236,11 +236,11 @@ func (g *RogueGame) beTrapped(tc Coord) int {
|
||||
case 10:
|
||||
g.msg("you pack turns %s!", rainbow[g.rnd(len(rainbow))])
|
||||
}
|
||||
case TSleep:
|
||||
case TrapSleep:
|
||||
g.NoCommand += g.spread(5) // SLEEPTIME
|
||||
p.Flags.Clear(IsRun)
|
||||
p.Flags.Clear(Awake)
|
||||
g.msg("a strange white mist envelops you and you fall asleep")
|
||||
case TArrow:
|
||||
case TrapArrow:
|
||||
if g.swing(p.Stats.Lvl-1, p.Stats.Arm, 1) {
|
||||
p.Stats.HP -= g.roll(1, 6)
|
||||
if p.Stats.HP <= 0 {
|
||||
@@ -251,18 +251,18 @@ func (g *RogueGame) beTrapped(tc Coord) int {
|
||||
}
|
||||
} else {
|
||||
arrow := newObject()
|
||||
g.initWeapon(arrow, Arrow)
|
||||
g.initWeapon(arrow, WeaponArrow)
|
||||
arrow.Count = 1
|
||||
arrow.Pos = p.Pos
|
||||
g.fall(arrow, false)
|
||||
g.msg("an arrow shoots past you")
|
||||
}
|
||||
case TTelep:
|
||||
case TrapTeleport:
|
||||
// since the hero's leaving, look() won't put a TRAP down for us,
|
||||
// so we have to do it ourself
|
||||
g.teleport()
|
||||
g.mvaddch(tc.Y, tc.X, Trap)
|
||||
case TDart:
|
||||
case TrapDart:
|
||||
if !g.swing(p.Stats.Lvl+1, p.Stats.Arm, 1) {
|
||||
g.msg("a small dart whizzes by your ear and vanishes")
|
||||
} else {
|
||||
@@ -271,12 +271,12 @@ func (g *RogueGame) beTrapped(tc Coord) int {
|
||||
g.msg("a poisoned dart killed you")
|
||||
g.death('d')
|
||||
}
|
||||
if !p.IsWearing(RSustStr) && !g.save(VsPoison) {
|
||||
if !p.IsWearing(RingSustainStrength) && !g.save(VsPoison) {
|
||||
g.chgStr(-1)
|
||||
}
|
||||
g.msg("a small dart just hit you in the shoulder")
|
||||
}
|
||||
case TRust:
|
||||
case TrapRust:
|
||||
g.msg("a gush of water hits you on the head")
|
||||
g.rustArmor(p.CurArmor)
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func (g *RogueGame) rndmove(who *Creature) Coord {
|
||||
break
|
||||
}
|
||||
}
|
||||
if found != nil && found.Which == SScare {
|
||||
if found != nil && found.Which == ScrollScareMonster {
|
||||
return who.Pos
|
||||
}
|
||||
}
|
||||
@@ -321,12 +321,12 @@ func (g *RogueGame) rndmove(who *Creature) Coord {
|
||||
// rustArmor rusts the given armor, if it is a legal kind to rust, and we
|
||||
// aren't wearing a magic ring (move.c rust_armor).
|
||||
func (g *RogueGame) rustArmor(arm *Object) {
|
||||
if arm == nil || arm.Type != Armor || arm.Which == Leather ||
|
||||
if arm == nil || arm.Type != Armor || arm.Which == ArmorLeather ||
|
||||
arm.Arm >= 9 {
|
||||
return
|
||||
}
|
||||
|
||||
if arm.Flags.Has(IsProt) || g.Player.IsWearing(RSustArm) {
|
||||
if arm.Flags.Has(Protected) || g.Player.IsWearing(RingMaintainArmor) {
|
||||
if !g.ToDeath {
|
||||
g.msg("the rust vanishes instantly")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user