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:
2026-07-06 21:28:57 +02:00
parent 1133feb0ba
commit e71a2ef3fd
32 changed files with 646 additions and 650 deletions

View File

@@ -23,7 +23,7 @@ func (g *RogueGame) wear() {
return
}
g.wasteTime()
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
sp := g.invName(obj, true)
p.CurArmor = obj
if !g.Options.Terse {

View File

@@ -9,19 +9,19 @@ const dragonShot = 5
func (g *RogueGame) runners(int) {
list := append([]*Monster(nil), g.Level.Monsters...)
for _, tp := range list {
if !tp.On(IsHeld) && tp.On(IsRun) {
if !tp.On(Held) && tp.On(Awake) {
origPos := tp.Pos
wastarget := tp.On(IsTarget)
wastarget := tp.On(Targeted)
if g.moveMonst(tp) == -1 {
continue
}
if tp.On(IsFly) && distCp(g.Player.Pos, tp.Pos) >= 3 {
if tp.On(Flying) && distCp(g.Player.Pos, tp.Pos) >= 3 {
if g.moveMonst(tp) == -1 {
continue
}
}
if wastarget && origPos != tp.Pos {
tp.Flags.Clear(IsTarget)
tp.Flags.Clear(Targeted)
g.ToDeath = false
}
}
@@ -35,12 +35,12 @@ func (g *RogueGame) runners(int) {
// moveMonst executes a single turn of running for a monster (chase.c
// move_monst). Returns -1 if the monster died or left the level.
func (g *RogueGame) moveMonst(tp *Monster) int {
if !tp.On(IsSlow) || tp.Turn {
if !tp.On(Slowed) || tp.Turn {
if g.doChase(tp) == -1 {
return -1
}
}
if tp.On(IsHaste) {
if tp.On(Hasted) {
if g.doChase(tp) == -1 {
return -1
}
@@ -68,7 +68,7 @@ func (g *RogueGame) relocate(th *Monster, newLoc Coord) {
g.move(newLoc.Y, newLoc.X)
if g.seeMonst(th) {
g.addch(th.Disguise)
} else if g.Player.On(SeeMonst) {
} else if g.Player.On(SenseMonsters) {
g.standout()
g.addch(th.Type)
g.standend()
@@ -83,7 +83,7 @@ func (g *RogueGame) doChase(th *Monster) int {
mindist := 32767
rer := th.Room // find room of chaser
if th.On(IsGreed) && rer.GoldVal == 0 {
if th.On(Greedy) && rer.GoldVal == 0 {
th.Dest = &p.Pos // if gold has been taken, run after hero
}
var ree *Room // find room of chasee
@@ -108,7 +108,7 @@ over:
}
}
if door {
rer = &g.Level.Passages[*g.Level.FlagsAt(th.Pos.Y, th.Pos.X)&FPNum]
rer = &g.Level.Passages[*g.Level.FlagsAt(th.Pos.Y, th.Pos.X)&FPassNum]
door = false
goto over
}
@@ -120,7 +120,7 @@ over:
if th.Type == 'D' && (th.Pos.Y == p.Pos.Y || th.Pos.X == p.Pos.X ||
abs(th.Pos.Y-p.Pos.Y) == abs(th.Pos.X-p.Pos.X)) &&
distCp(th.Pos, p.Pos) <= BoltLength*BoltLength &&
!th.On(IsCanc) && g.rnd(dragonShot) == 0 {
!th.On(Cancelled) && g.rnd(dragonShot) == 0 {
g.Delta.Y = sign(p.Pos.Y - th.Pos.Y)
g.Delta.X = sign(p.Pos.X - th.Pos.X)
if g.HasHit {
@@ -130,7 +130,7 @@ over:
g.Running = false
g.Count = 0
g.Quiet = 0
if g.ToDeath && !th.On(IsTarget) {
if g.ToDeath && !th.On(Targeted) {
g.ToDeath = false
g.Kamikaze = false
}
@@ -147,7 +147,7 @@ over:
if th.Dest == &obj.Pos {
detachObj(&g.Level.Objects, obj)
attachObj(&th.Pack, obj)
if th.Room.Flags.Has(IsGone) {
if th.Room.Flags.Has(Gone) {
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, Passage)
} else {
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, Floor)
@@ -168,7 +168,7 @@ over:
g.relocate(th, g.chRet)
// And stop running if need be
if stoprun && th.Pos == *th.Dest {
th.Flags.Clear(IsRun)
th.Flags.Clear(Awake)
}
return 0
}
@@ -185,14 +185,14 @@ func (g *RogueGame) chase(tp *Monster, ee Coord) bool {
// If the thing is confused, let it move randomly. Invisible Stalkers
// are slightly confused all of the time, and bats are quite confused
// all the time
if (tp.On(IsHuh) && g.rnd(5) != 0) || (tp.Type == 'P' && g.rnd(5) == 0) ||
if (tp.On(Confused) && g.rnd(5) != 0) || (tp.Type == 'P' && g.rnd(5) == 0) ||
(tp.Type == 'B' && g.rnd(2) == 0) {
// get a valid random move
g.chRet = g.rndmove(&tp.Creature)
curdist = distCp(g.chRet, ee)
// Small chance that it will become un-confused
if g.rnd(20) == 0 {
tp.Flags.Clear(IsHuh)
tp.Flags.Clear(Confused)
}
} else {
// Otherwise, find the empty spot next to the chaser that is
@@ -233,7 +233,7 @@ func (g *RogueGame) chase(tp *Monster, ee Coord) bool {
break
}
}
if found != nil && found.Which == SScare {
if found != nil && found.Which == ScrollScareMonster {
continue
}
}
@@ -268,8 +268,8 @@ func (g *RogueGame) setOldch(tp *Monster, cp Coord) {
}
sch := tp.OldCh
tp.OldCh = g.mvinch(cp.Y, cp.X)
if !g.Player.On(IsBlind) {
if (sch == Floor || tp.OldCh == Floor) && tp.Room.Flags.Has(IsDark) {
if !g.Player.On(Blind) {
if (sch == Floor || tp.OldCh == Floor) && tp.Room.Flags.Has(Dark) {
tp.OldCh = ' '
} else if distCp(cp, g.Player.Pos) <= LampDist && g.Options.SeeFloor {
tp.OldCh = g.Level.Char(cp.Y, cp.X)
@@ -281,10 +281,10 @@ func (g *RogueGame) setOldch(tp *Monster, cp Coord) {
// see_monst).
func (g *RogueGame) seeMonst(mp *Monster) bool {
p := &g.Player
if p.On(IsBlind) {
if p.On(Blind) {
return false
}
if mp.On(IsInvis) && !p.On(CanSee) {
if mp.On(Invisible) && !p.On(CanSeeInvisible) {
return false
}
y, x := mp.Pos.Y, mp.Pos.X
@@ -298,7 +298,7 @@ func (g *RogueGame) seeMonst(mp *Monster) bool {
if mp.Room != p.Room {
return false
}
return !mp.Room.Flags.Has(IsDark)
return !mp.Room.Flags.Has(Dark)
}
// runto sets a monster running after the hero (chase.c runto).
@@ -308,8 +308,8 @@ func (g *RogueGame) runto(runner Coord) {
return
}
// Start the beastie running
tp.Flags.Set(IsRun)
tp.Flags.Clear(IsHeld)
tp.Flags.Set(Awake)
tp.Flags.Clear(Held)
tp.Dest = g.findDest(tp)
}
@@ -317,8 +317,8 @@ func (g *RogueGame) runto(runner Coord) {
// any room (chase.c roomin).
func (g *RogueGame) roomin(cp Coord) *Room {
fp := *g.Level.FlagsAt(cp.Y, cp.X)
if fp.Has(FPass) {
return &g.Level.Passages[fp&FPNum]
if fp.Has(FPassage) {
return &g.Level.Passages[fp&FPassNum]
}
for i := range g.Level.Rooms {
@@ -348,11 +348,11 @@ func (g *RogueGame) diagOk(sp, ep Coord) bool {
// cansee).
func (g *RogueGame) cansee(y, x int) bool {
p := &g.Player
if p.On(IsBlind) {
if p.On(Blind) {
return false
}
if distance(y, x, p.Pos.Y, p.Pos.X) < LampDist {
if g.Level.FlagsAt(y, x).Has(FPass) {
if g.Level.FlagsAt(y, x).Has(FPassage) {
if y != p.Pos.Y && x != p.Pos.X &&
!stepOk(g.Level.Char(y, p.Pos.X)) &&
!stepOk(g.Level.Char(p.Pos.Y, x)) {
@@ -364,7 +364,7 @@ func (g *RogueGame) cansee(y, x int) bool {
// We can only see if the hero is in the same room as the coordinate
// and the room is lit, or if it is close.
rer := g.roomin(Coord{X: x, Y: y})
return rer == p.Room && !rer.Flags.Has(IsDark)
return rer == p.Room && !rer.Flags.Has(Dark)
}
// findDest finds the proper destination for the monster (chase.c
@@ -375,7 +375,7 @@ func (g *RogueGame) findDest(tp *Monster) *Coord {
return &g.Player.Pos
}
for _, obj := range g.Level.Objects {
if obj.Type == Scroll && obj.Which == SScare {
if obj.Type == Scroll && obj.Which == ScrollScareMonster {
continue
}
if g.roomin(obj.Pos) == tp.Room && g.rnd(100) < prob {

View File

@@ -7,7 +7,7 @@ package game
func (g *RogueGame) command() {
p := &g.Player
ntimes := 1 // number of player moves
if p.On(IsHaste) {
if p.On(Hasted) {
ntimes++
}
// Let the daemons start up
@@ -21,7 +21,7 @@ func (g *RogueGame) command() {
}
// these are illegal things for the player to be, so if any are
// set, someone's been poking in memory
if p.On(IsSlow | IsGreed | IsInvis | IsRegen | IsTarget) {
if p.On(Slowed | Greedy | Invisible | Regenerates | Targeted) {
panic("player flags corrupted")
}
@@ -59,7 +59,7 @@ func (g *RogueGame) command() {
}
if g.NoCommand != 0 {
if g.NoCommand--; g.NoCommand == 0 {
p.Flags.Set(IsRun)
p.Flags.Set(Awake)
g.msg("you can move again")
}
} else {
@@ -121,14 +121,14 @@ func (g *RogueGame) command() {
}
g.DoDaemons(After)
g.DoFuses(After)
if p.IsRing(Left, RSearch) {
if p.IsRing(Left, RingSearching) {
g.search()
} else if p.IsRing(Left, RTeleport) && g.rnd(50) == 0 {
} else if p.IsRing(Left, RingTeleportation) && g.rnd(50) == 0 {
g.teleport()
}
if p.IsRing(Right, RSearch) {
if p.IsRing(Right, RingSearching) {
g.search()
} else if p.IsRing(Right, RTeleport) && g.rnd(50) == 0 {
} else if p.IsRing(Right, RingTeleportation) && g.rnd(50) == 0 {
g.teleport()
}
}
@@ -197,7 +197,7 @@ over:
g.doRun('n')
case CTRL('H'), CTRL('J'), CTRL('K'), CTRL('L'),
CTRL('Y'), CTRL('U'), CTRL('B'), CTRL('N'):
if !p.On(IsBlind) {
if !p.On(Blind) {
g.DoorStop = true
g.Firstmove = true
}
@@ -219,7 +219,7 @@ over:
g.Delta.Y += p.Pos.Y
g.Delta.X += p.Pos.X
mp := g.Level.MonsterAt(g.Delta.Y, g.Delta.X)
if mp == nil || (!g.seeMonst(mp) && !p.On(SeeMonst)) {
if mp == nil || (!g.seeMonst(mp) && !p.On(SenseMonsters)) {
if !g.Options.Terse {
g.addmsg("I see ")
}
@@ -228,7 +228,7 @@ over:
} else if g.diagOk(p.Pos, g.Delta) {
g.ToDeath = true
g.MaxHit = 0
mp.Flags.Set(IsTarget)
mp.Flags.Set(Targeted)
g.RunCh = g.DirCh
ch = g.DirCh
goto over
@@ -333,10 +333,10 @@ over:
}
if g.Level.Char(g.Delta.Y, g.Delta.X) != Trap {
g.msg("no trap there")
} else if p.On(IsHalu) {
g.msg("%s", trName[g.rnd(NTraps)])
} else if p.On(Hallucinating) {
g.msg("%s", trName[g.rnd(NumTrapTypes)])
} else {
g.msg("%s", trName[*fp&FTMask])
g.msg("%s", trName[*fp&FTrapMask])
fp.Set(FSeen)
}
}
@@ -407,7 +407,7 @@ func (g *RogueGame) wizardCommand(ch byte) {
case CTRL('C'):
g.addPass()
case CTRL('X'):
g.turnSee(p.On(SeeMonst))
g.turnSee(p.On(SenseMonsters))
case CTRL('~'):
if item := g.getItem("charge", int(Stick)); item != nil {
item.SetCharges(10000)
@@ -418,7 +418,7 @@ func (g *RogueGame) wizardCommand(ch byte) {
}
// Give him a sword (+1,+1)
obj := newObject()
g.initWeapon(obj, TwoSword)
g.initWeapon(obj, WeaponTwoHandedSword)
obj.HPlus = 1
obj.DPlus = 1
g.addPack(obj, true)
@@ -426,9 +426,9 @@ func (g *RogueGame) wizardCommand(ch byte) {
// And his suit of armor
obj = newObject()
obj.Type = Armor
obj.Which = PlateMail
obj.Which = ArmorPlateMail
obj.Arm = -5
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
obj.Count = 1
p.CurArmor = obj
g.addPack(obj, true)
@@ -453,10 +453,10 @@ func (g *RogueGame) search() {
ey := p.Pos.Y + 1
ex := p.Pos.X + 1
probinc := 0
if p.On(IsHalu) {
if p.On(Hallucinating) {
probinc = 3
}
if p.On(IsBlind) {
if p.On(Blind) {
probinc += 2
}
found := false
@@ -486,10 +486,10 @@ func (g *RogueGame) search() {
if !g.Options.Terse {
g.addmsg("you found ")
}
if p.On(IsHalu) {
g.msg("%s", trName[g.rnd(NTraps)])
if p.On(Hallucinating) {
g.msg("%s", trName[g.rnd(NumTrapTypes)])
} else {
g.msg("%s", trName[*fp&FTMask])
g.msg("%s", trName[*fp&FTrapMask])
fp.Set(FSeen)
}
foundone = true
@@ -661,7 +661,7 @@ func (g *RogueGame) uLevel() {
// levitCheck checks whether she's levitating, and if she is, prints an
// appropriate message (command.c levit_check).
func (g *RogueGame) levitCheck() bool {
if !g.Player.On(IsLevit) {
if !g.Player.On(Levitating) {
return false
}
g.msg("You can't. You're floating off the ground!")

View File

@@ -53,10 +53,10 @@ func (g *RogueGame) doctor(int) {
} else if g.Quiet >= 3 {
p.Stats.HP += g.rnd(lv-7) + 1
}
if p.IsRing(Left, RRegen) {
if p.IsRing(Left, RingRegeneration) {
p.Stats.HP++
}
if p.IsRing(Right, RRegen) {
if p.IsRing(Right, RingRegeneration) {
p.Stats.HP++
}
if ohp != p.Stats.HP {
@@ -92,27 +92,27 @@ func wanderTime(g *RogueGame) int { return g.spread(70) }
// unconfuse releases the poor player from his confusion (daemons.c
// unconfuse).
func (g *RogueGame) unconfuse(int) {
g.Player.Flags.Clear(IsHuh)
g.Player.Flags.Clear(Confused)
g.msg("you feel less %s now", g.chooseStr("trippy", "confused"))
}
// unsee turns off the ability to see invisible (daemons.c unsee).
func (g *RogueGame) unsee(int) {
for _, th := range g.Level.Monsters {
if th.On(IsInvis) && g.seeMonst(th) {
if th.On(Invisible) && g.seeMonst(th) {
g.mvaddch(th.Pos.Y, th.Pos.X, th.OldCh)
}
}
g.Player.Flags.Clear(CanSee)
g.Player.Flags.Clear(CanSeeInvisible)
}
// sight gives the hero his sight back (daemons.c sight).
func (g *RogueGame) sight(int) {
p := &g.Player
if p.On(IsBlind) {
if p.On(Blind) {
g.Extinguish(DSight)
p.Flags.Clear(IsBlind)
if !p.Room.Flags.Has(IsGone) {
p.Flags.Clear(Blind)
if !p.Room.Flags.Has(Gone) {
g.enterRoom(p.Pos)
}
g.msg("%s", g.chooseStr("far out! Everything is all cosmic again",
@@ -122,7 +122,7 @@ func (g *RogueGame) sight(int) {
// nohaste ends the hasting (daemons.c nohaste).
func (g *RogueGame) nohaste(int) {
g.Player.Flags.Clear(IsHaste)
g.Player.Flags.Clear(Hasted)
g.msg("you feel yourself slowing down")
}
@@ -170,7 +170,7 @@ func (g *RogueGame) stomach(int) {
}
}
if p.HungryState != origHungry {
p.Flags.Clear(IsRun)
p.Flags.Clear(Awake)
g.Running = false
g.ToDeath = false
g.Count = 0
@@ -180,14 +180,14 @@ func (g *RogueGame) stomach(int) {
// comeDown takes the hero down off her acid trip (daemons.c come_down).
func (g *RogueGame) comeDown(int) {
p := &g.Player
if !p.On(IsHalu) {
if !p.On(Hallucinating) {
return
}
g.KillDaemon(DVisuals)
p.Flags.Clear(IsHalu)
p.Flags.Clear(Hallucinating)
if p.On(IsBlind) {
if p.On(Blind) {
return
}
@@ -199,11 +199,11 @@ func (g *RogueGame) comeDown(int) {
}
// undo the monsters
seemonst := p.On(SeeMonst)
seemonst := p.On(SenseMonsters)
for _, tp := range g.Level.Monsters {
g.move(tp.Pos.Y, tp.Pos.X)
if g.cansee(tp.Pos.Y, tp.Pos.X) {
if !tp.On(IsInvis) || p.On(CanSee) {
if !tp.On(Invisible) || p.On(CanSeeInvisible) {
g.addch(tp.Disguise)
} else {
g.addch(g.Level.Char(tp.Pos.Y, tp.Pos.X))
@@ -237,7 +237,7 @@ func (g *RogueGame) visuals(int) {
}
// change the monsters
seemonst := p.On(SeeMonst)
seemonst := p.On(SenseMonsters)
for _, tp := range g.Level.Monsters {
g.move(tp.Pos.Y, tp.Pos.X)
if g.seeMonst(tp) {
@@ -256,7 +256,7 @@ func (g *RogueGame) visuals(int) {
// land lands the hero from a levitation potion (daemons.c land).
func (g *RogueGame) land(int) {
g.Player.Flags.Clear(IsLevit)
g.Player.Flags.Clear(Levitating)
g.msg("%s", g.chooseStr("bummer! You've hit the ground",
"you float gently to the ground"))
}

View File

@@ -23,7 +23,7 @@ func TestQuaffHealingPotion(t *testing.T) {
g := mkGameInput(t, 5, "")
pot := newObject()
pot.Type = Potion
pot.Which = PHealing
pot.Which = PotionHealing
ch := give(g, pot)
g.scr.term.(*testTerm).input = []byte{ch}
@@ -32,7 +32,7 @@ func TestQuaffHealingPotion(t *testing.T) {
if g.Player.Stats.HP <= 1 {
t.Error("healing potion did not heal")
}
if !g.Items.Potions[PHealing].Know {
if !g.Items.Potions[PotionHealing].Know {
t.Error("healing potion not identified after drinking")
}
if len(g.Player.Pack) != 5 {
@@ -44,12 +44,12 @@ func TestQuaffConfusionSetsFlagAndFuse(t *testing.T) {
g := mkGameInput(t, 5, "")
pot := newObject()
pot.Type = Potion
pot.Which = PConfuse
pot.Which = PotionConfusion
ch := give(g, pot)
g.scr.term.(*testTerm).input = []byte{ch}
g.quaff()
if !g.Player.On(IsHuh) {
if !g.Player.On(Confused) {
t.Error("confusion potion did not confuse")
}
if g.findSlot(DUnconfuse) == nil {
@@ -59,7 +59,7 @@ func TestQuaffConfusionSetsFlagAndFuse(t *testing.T) {
for range 30 {
g.DoFuses(After)
}
if g.Player.On(IsHuh) {
if g.Player.On(Confused) {
t.Error("confusion never wore off")
}
}
@@ -68,7 +68,7 @@ func TestReadEnchantArmor(t *testing.T) {
g := mkGameInput(t, 5, "")
scr := newObject()
scr.Type = Scroll
scr.Which = SArmor
scr.Which = ScrollEnchantArmor
ch := give(g, scr)
g.scr.term.(*testTerm).input = []byte{ch}
@@ -88,16 +88,16 @@ func TestReadHoldMonsterFreezesAdjacent(t *testing.T) {
// TestHoldScrollGreedyMonsterQuirk.
g := mkGameInput(t, 5, "")
tp := spawnAdjacent(g, 'Z')
tp.Flags.Set(IsRun)
tp.Flags.Set(Awake)
scr := newObject()
scr.Type = Scroll
scr.Which = SHold
scr.Which = ScrollHoldMonster
ch := give(g, scr)
g.scr.term.(*testTerm).input = []byte{ch}
g.readScroll()
t.Logf("after scroll: flags=%o huh=%q", tp.Flags, g.Msgs.Huh)
if tp.On(IsRun) || !tp.On(IsHeld) {
if tp.On(Awake) || !tp.On(Held) {
t.Error("hold monster scroll did not hold the adjacent monster")
}
}
@@ -109,20 +109,20 @@ func TestReadHoldMonsterFreezesAdjacent(t *testing.T) {
func TestHoldScrollGreedyMonsterQuirk(t *testing.T) {
g := mkGameInput(t, 5, "")
tp := spawnAdjacent(g, 'O')
tp.Flags.Set(IsRun)
tp.Flags.Set(Awake)
scr := newObject()
scr.Type = Scroll
scr.Which = SHold
scr.Which = ScrollHoldMonster
ch := give(g, scr)
g.scr.term.(*testTerm).input = []byte{ch}
g.readScroll()
t.Logf("orc after scroll: flags=%o (IsRun=%v IsHeld=%v)",
tp.Flags, tp.On(IsRun), tp.On(IsHeld))
if !tp.On(IsHeld) {
t.Error("orc lost IsHeld entirely")
t.Logf("orc after scroll: flags=%o (Awake=%v Held=%v)",
tp.Flags, tp.On(Awake), tp.On(Held))
if !tp.On(Held) {
t.Error("orc lost Held entirely")
}
if !tp.On(IsRun) {
if !tp.On(Awake) {
t.Error("quirk changed: greedy monster stayed held; if this is a " +
"deliberate fix, update this test and ARCHITECTURE.md")
}
@@ -133,7 +133,7 @@ func TestZapSlowMonster(t *testing.T) {
tp := spawnAdjacent(g, 'Z')
stick := newObject()
stick.Type = Stick
stick.Which = WsSlowM
stick.Which = WandSlowMonster
g.fixStick(stick)
ch := give(g, stick)
g.scr.term.(*testTerm).input = []byte{ch}
@@ -141,7 +141,7 @@ func TestZapSlowMonster(t *testing.T) {
charges := stick.Charges()
g.doZap()
if !tp.On(IsSlow) {
if !tp.On(Slowed) {
t.Error("slow monster wand did not slow")
}
if stick.Charges() != charges-1 {

View File

@@ -48,14 +48,14 @@ var addDam = [32]int{
// setMname returns the monster name for the given monster (fight.c
// set_mname).
func (g *RogueGame) setMname(tp *Monster) string {
if !g.seeMonst(tp) && !g.Player.On(SeeMonst) {
if !g.seeMonst(tp) && !g.Player.On(SenseMonsters) {
if g.Options.Terse {
return "it"
}
return "something"
}
var mname string
if g.Player.On(IsHalu) {
if g.Player.On(Hallucinating) {
ch := int(g.mvinch(tp.Pos.Y, tp.Pos.X))
if !isUpper(byte(ch)) {
ch = g.rnd(26)
@@ -83,9 +83,9 @@ func (g *RogueGame) fight(mp Coord, weap *Object, thrown bool) bool {
g.Quiet = 0
g.runto(mp)
// Let him know it was really a xeroc (if it was one).
if tp.Type == 'X' && tp.Disguise != 'X' && !p.On(IsBlind) {
if tp.Type == 'X' && tp.Disguise != 'X' && !p.On(Blind) {
tp.Disguise = 'X'
if p.On(IsHalu) {
if p.On(Hallucinating) {
g.mvaddch(tp.Pos.Y, tp.Pos.X, byte(g.rnd(26)+'A'))
}
g.msg("%s", g.chooseStr("heavy! That's a nasty critter!",
@@ -104,17 +104,17 @@ func (g *RogueGame) fight(mp Coord, weap *Object, thrown bool) bool {
} else {
g.hit("", mname, g.Options.Terse)
}
if p.On(CanHuh) {
if p.On(CanConfuse) {
didHit = true
tp.Flags.Set(IsHuh)
p.Flags.Clear(CanHuh)
tp.Flags.Set(Confused)
p.Flags.Clear(CanConfuse)
g.endmsg()
g.HasHit = false
g.msg("your hands stop glowing %s", g.pickColor("red"))
}
if tp.Stats.HP <= 0 {
g.killed(tp, true)
} else if didHit && !p.On(IsBlind) {
} else if didHit && !p.On(Blind) {
g.msg("%s appears confused", mname)
}
didHit = true
@@ -137,13 +137,13 @@ func (g *RogueGame) attack(mp *Monster) int {
g.Running = false
g.Count = 0
g.Quiet = 0
if g.ToDeath && !mp.On(IsTarget) {
if g.ToDeath && !mp.On(Targeted) {
g.ToDeath = false
g.Kamikaze = false
}
if mp.Type == 'X' && mp.Disguise != 'X' && !p.On(IsBlind) {
if mp.Type == 'X' && mp.Disguise != 'X' && !p.On(Blind) {
mp.Disguise = 'X'
if p.On(IsHalu) {
if p.On(Hallucinating) {
g.mvaddch(mp.Pos.Y, mp.Pos.X, byte(g.rnd(26)+'A'))
}
}
@@ -171,14 +171,14 @@ func (g *RogueGame) attack(mp *Monster) int {
g.ToDeath = false
}
}
if !mp.On(IsCanc) {
if !mp.On(Cancelled) {
switch mp.Type {
case 'A':
// If an aquator hits, you can lose armor class.
g.rustArmor(p.CurArmor)
case 'I':
// The ice monster freezes you
p.Flags.Clear(IsRun)
p.Flags.Clear(Awake)
if g.NoCommand == 0 {
g.addmsg("you are frozen")
if !g.Options.Terse {
@@ -193,7 +193,7 @@ func (g *RogueGame) attack(mp *Monster) int {
case 'R':
// Rattlesnakes have poisonous bites
if !g.save(VsPoison) {
if !p.IsWearing(RSustStr) {
if !p.IsWearing(RingSustainStrength) {
g.chgStr(-1)
if !g.Options.Terse {
g.msg("you feel a bite in your leg and now feel weaker")
@@ -243,7 +243,7 @@ func (g *RogueGame) attack(mp *Monster) int {
}
case 'F':
// Venus Flytrap stops the poor guy from moving
p.Flags.Set(IsHeld)
p.Flags.Set(Held)
p.VfHit++
g.Monsters['F'-'A'].Stats.Dmg = fmt.Sprintf("%dx1", p.VfHit)
if p.Stats.HP--; p.Stats.HP <= 0 {
@@ -330,20 +330,20 @@ func (g *RogueGame) rollEm(thatt, thdef *Creature, weap *Object, hurl bool) bool
hplus = weap.HPlus
dplus = weap.DPlus
if weap == p.CurWeapon {
if p.IsRing(Left, RAddDam) {
if p.IsRing(Left, RingIncreaseDamage) {
dplus += p.CurRing[Left].Arm
} else if p.IsRing(Left, RAddHit) {
} else if p.IsRing(Left, RingDexterity) {
hplus += p.CurRing[Left].Arm
}
if p.IsRing(Right, RAddDam) {
if p.IsRing(Right, RingIncreaseDamage) {
dplus += p.CurRing[Right].Arm
} else if p.IsRing(Right, RAddHit) {
} else if p.IsRing(Right, RingDexterity) {
hplus += p.CurRing[Right].Arm
}
}
cp = weap.Damage
if hurl {
if weap.Flags.Has(IsMissl) && p.CurWeapon != nil &&
if weap.Flags.Has(Missile) && p.CurWeapon != nil &&
p.CurWeapon.Which == weap.Launch {
cp = weap.HurlDmg
hplus += p.CurWeapon.HPlus
@@ -355,7 +355,7 @@ func (g *RogueGame) rollEm(thatt, thdef *Creature, weap *Object, hurl bool) bool
}
// If the creature being attacked is not running (asleep or held) then
// the attacker gets a plus four bonus to hit.
if !thdef.Flags.Has(IsRun) {
if !thdef.Flags.Has(Awake) {
hplus += 4
}
defArm := def.Arm
@@ -363,10 +363,10 @@ func (g *RogueGame) rollEm(thatt, thdef *Creature, weap *Object, hurl bool) bool
if p.CurArmor != nil {
defArm = p.CurArmor.Arm
}
if p.IsRing(Left, RProtect) {
if p.IsRing(Left, RingProtection) {
defArm -= p.CurRing[Left].Arm
}
if p.IsRing(Right, RProtect) {
if p.IsRing(Right, RingProtection) {
defArm -= p.CurRing[Right].Arm
}
}
@@ -512,7 +512,7 @@ func (g *RogueGame) removeMon(mp Coord, tp *Monster, waskill bool) {
g.Level.SetMonsterAt(mp.Y, mp.X, nil)
g.mvaddch(mp.Y, mp.X, tp.OldCh)
detachMon(&g.Level.Monsters, tp)
if tp.On(IsTarget) {
if tp.On(Targeted) {
g.Kamikaze = false
g.ToDeath = false
if g.Options.FightFlush {
@@ -529,7 +529,7 @@ func (g *RogueGame) killed(tp *Monster, pr bool) {
// If the monster was a venus flytrap, un-hold him
switch tp.Type {
case 'F':
p.Flags.Clear(IsHeld)
p.Flags.Clear(Held)
p.VfHit = 0
g.Monsters['F'-'A'].Stats.Dmg = "000x0"
case 'L':

View File

@@ -25,7 +25,7 @@ func TestRollEmParsesMultiAttackDice(t *testing.T) {
g := mkGame(t, 42)
att := &Creature{Stats: Stats{Str: 16, Lvl: 20, Dmg: "1x4/1x4/1x4"}}
def := &Creature{Stats: Stats{Arm: 10, HP: 1000}}
def.Flags.Set(IsRun)
def.Flags.Set(Awake)
// With attacker level 20 vs armor 10, swing always hits
// (rnd(20)+wplus >= (20-20)-10 is always true), so three attacks of
// 1x4 + str bonus 1 each must deal between 6 and 15 damage.
@@ -60,7 +60,7 @@ func TestAttackHurtsPlayer(t *testing.T) {
g := mkGame(t, 9)
tp := spawnAdjacent(g, 'T') // troll: 1x8/1x8/2x6
tp.Stats.Lvl = 20 // always hits
tp.Flags.Clear(IsCanc)
tp.Flags.Clear(Cancelled)
hpBefore := g.Player.Stats.HP
g.Player.Stats.HP = 500
g.Player.Stats.MaxHP = 500
@@ -96,7 +96,7 @@ func TestRunnersChaseHero(t *testing.T) {
}
tp := &Monster{}
g.newMonster(tp, 'H', pos)
tp.Flags.Set(IsRun)
tp.Flags.Set(Awake)
tp.Dest = &p.Pos
d0 := distCp(tp.Pos, p.Pos)
g.runners(0)

View File

@@ -3,19 +3,19 @@ package game
// ItemLore is the per-game item identity state: the randomized appearance
// names and the seven mutable ObjInfo tables (extern.c/init.c).
type ItemLore struct {
PotColors [MaxPotions]string // p_colors: colors of the potions
ScrNames [MaxScrolls]string // s_names: names of the scrolls
RingStones [MaxRings]string // r_stones: stone settings of the rings
WandMade [MaxSticks]string // ws_made: what sticks are made of
WandType [MaxSticks]string // ws_type: "wand" or "staff"
PotColors [NumPotionTypes]string // p_colors: colors of the potions
ScrNames [NumScrollTypes]string // s_names: names of the scrolls
RingStones [NumRingTypes]string // r_stones: stone settings of the rings
WandMade [NumWandTypes]string // ws_made: what sticks are made of
WandType [NumWandTypes]string // ws_type: "wand" or "staff"
Things [NumThings]ObjInfo
Potions [MaxPotions]ObjInfo
Scrolls [MaxScrolls]ObjInfo
Rings [MaxRings]ObjInfo
Sticks [MaxSticks]ObjInfo
Weapons [MaxWeapons + 1]ObjInfo
Armors [MaxArmors]ObjInfo
Potions [NumPotionTypes]ObjInfo
Scrolls [NumScrollTypes]ObjInfo
Rings [NumRingTypes]ObjInfo
Sticks [NumWandTypes]ObjInfo
Weapons [NumWeaponTypes + 1]ObjInfo
Armors [NumArmorTypes]ObjInfo
Group int // group number for the next stack of missiles (weapons.c `group`)
}
@@ -168,7 +168,7 @@ func NewGame(cfg Config) *RogueGame {
g.FileName = cfg.Home + "/rogue.save"
g.rogueOpts = cfg.RogueOpts
if cfg.Wizard {
g.Player.Flags.Set(SeeMonst)
g.Player.Flags.Set(SenseMonsters)
}
if cfg.RogueOpts != "" {
g.ParseOpts(cfg.RogueOpts)
@@ -177,7 +177,7 @@ func NewGame(cfg Config) *RogueGame {
g.Monsters = monsterTable
g.Items.Group = 2 // weapons.c: int group = 2
for i := range g.Level.Passages {
g.Level.Passages[i].Flags = IsGone | IsDark
g.Level.Passages[i].Flags = Gone | Dark
}
g.initProbs() // set up prob tables for objects

View File

@@ -19,31 +19,31 @@ func (g *RogueGame) initPlayer() {
// And his suit of armor
obj = newObject()
obj.Type = Armor
obj.Which = RingMail
obj.Arm = aClass[RingMail] - 1
obj.Flags.Set(IsKnow)
obj.Which = ArmorRingMail
obj.Arm = aClass[ArmorRingMail] - 1
obj.Flags.Set(Known)
obj.Count = 1
p.CurArmor = obj
g.addPack(obj, true)
// Give him his weaponry. First a mace.
obj = newObject()
g.initWeapon(obj, Mace)
g.initWeapon(obj, WeaponMace)
obj.HPlus = 1
obj.DPlus = 1
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
g.addPack(obj, true)
p.CurWeapon = obj
// Now a +1 bow
obj = newObject()
g.initWeapon(obj, Bow)
g.initWeapon(obj, WeaponBow)
obj.HPlus = 1
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
g.addPack(obj, true)
// Now some arrows
obj = newObject()
g.initWeapon(obj, Arrow)
g.initWeapon(obj, WeaponArrow)
obj.Count = g.rnd(15) + 25
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
g.addPack(obj, true)
}
@@ -51,7 +51,7 @@ func (g *RogueGame) initPlayer() {
// (init.c init_colors).
func (g *RogueGame) initColors() {
used := make([]bool, len(rainbow))
for i := 0; i < MaxPotions; i++ {
for i := 0; i < NumPotionTypes; i++ {
var j int
for {
j = g.rnd(len(rainbow))
@@ -66,7 +66,7 @@ func (g *RogueGame) initColors() {
// initNames generates the names of the various scrolls (init.c init_names).
func (g *RogueGame) initNames() {
for i := 0; i < MaxScrolls; i++ {
for i := 0; i < NumScrollTypes; i++ {
var cp strings.Builder
nwords := g.rnd(3) + 2
for ; nwords > 0; nwords-- {
@@ -88,7 +88,7 @@ func (g *RogueGame) initNames() {
// (init.c init_stones).
func (g *RogueGame) initStones() {
used := make([]bool, len(stoneTable))
for i := 0; i < MaxRings; i++ {
for i := 0; i < NumRingTypes; i++ {
var j int
for {
j = g.rnd(len(stoneTable))
@@ -107,7 +107,7 @@ func (g *RogueGame) initStones() {
func (g *RogueGame) initMaterials() {
used := make([]bool, len(woods))
metused := make([]bool, len(metals))
for i := 0; i < MaxSticks; i++ {
for i := 0; i < NumWandTypes; i++ {
var str string
for {
if g.rnd(2) == 0 {
@@ -156,14 +156,14 @@ func (g *RogueGame) initProbs() {
sumProbs(g.Items.Scrolls[:])
sumProbs(g.Items.Rings[:])
sumProbs(g.Items.Sticks[:])
sumProbs(g.Items.Weapons[:MaxWeapons]) // C sums MAXWEAPONS, excluding the flame entry
sumProbs(g.Items.Weapons[:NumWeaponTypes]) // C sums MAXWEAPONS, excluding the flame entry
sumProbs(g.Items.Armors[:])
}
// pickColor returns the given color, or a random one if the hero is
// hallucinating (init.c pick_color).
func (g *RogueGame) pickColor(col string) string {
if g.Player.On(IsHalu) {
if g.Player.On(Hallucinating) {
return rainbow[g.rnd(len(rainbow))]
}
return col

View File

@@ -10,13 +10,13 @@ type Place struct {
// Level is the current dungeon level: the map and everything on it. It is
// reset in place by NewLevel, matching the C reuse of the global arrays.
type Level struct {
Places [MaxLines * MaxCols]Place
Rooms [MaxRooms]Room
Passages [MaxPass]Room // one pseudo-room per passage network
Objects []*Object // lvl_obj: objects on this level
Monsters []*Monster // mlist: monsters on the level
Stairs Coord // location of the staircase
NTraps int // number of traps on this level
Places [MaxLines * MaxCols]Place
Rooms [MaxRooms]Room
Passages [MaxPass]Room // one pseudo-room per passage network
Objects []*Object // lvl_obj: objects on this level
Monsters []*Monster // mlist: monsters on the level
Stairs Coord // location of the staircase
TrapCount int // number of traps on this level
}
// At returns the map cell at (y, x); the C INDEX(y,x) macro, including its

View File

@@ -36,7 +36,7 @@ func (g *RogueGame) look(wakeup bool) {
if x < 0 || x >= NumCols {
continue
}
if !p.On(IsBlind) {
if !p.On(Blind) {
if y == hero.Y && x == hero.X {
continue
}
@@ -49,11 +49,11 @@ func (g *RogueGame) look(wakeup bool) {
}
fp := &pp.Flags
if pch != Door && ch != Door {
if (pfl & FPass) != (*fp & FPass) {
if (pfl & FPassage) != (*fp & FPassage) {
continue
}
}
if (fp.Has(FPass) || ch == Door) && (pfl.Has(FPass) || pch == Door) {
if (fp.Has(FPassage) || ch == Door) && (pfl.Has(FPassage) || pch == Door) {
if hero.X != x && hero.Y != y &&
!stepOk(g.Level.Char(y, hero.X)) && !stepOk(g.Level.Char(hero.Y, x)) {
continue
@@ -63,7 +63,7 @@ func (g *RogueGame) look(wakeup bool) {
tp := pp.Monst
if tp == nil {
ch = g.tripCh(y, x, ch)
} else if p.On(SeeMonst) && tp.On(IsInvis) {
} else if p.On(SenseMonsters) && tp.On(Invisible) {
if g.DoorStop && !g.Firstmove {
g.Running = false
}
@@ -73,20 +73,20 @@ func (g *RogueGame) look(wakeup bool) {
g.wakeMonster(y, x)
}
if g.seeMonst(tp) {
if p.On(IsHalu) {
if p.On(Hallucinating) {
ch = byte(g.rnd(26) + 'A')
} else {
ch = tp.Disguise
}
}
}
if p.On(IsBlind) && (y != hero.Y || x != hero.X) {
if p.On(Blind) && (y != hero.Y || x != hero.X) {
continue
}
g.move(y, x)
if p.Room.Flags.Has(IsDark) && !g.Options.SeeFloor && ch == Floor {
if p.Room.Flags.Has(Dark) && !g.Options.SeeFloor && ch == Floor {
ch = ' '
}
@@ -156,7 +156,7 @@ func (g *RogueGame) look(wakeup bool) {
// tripCh returns the character for this space, taking into account whether
// or not the player is tripping (misc.c trip_ch).
func (g *RogueGame) tripCh(y, x int, ch byte) byte {
if g.Player.On(IsHalu) && g.After {
if g.Player.On(Hallucinating) && g.After {
switch ch {
case Floor, ' ', Passage, '-', '|', Door, Trap:
default:
@@ -171,8 +171,8 @@ func (g *RogueGame) tripCh(y, x int, ch byte) byte {
// eraseLamp erases the area shown by a lamp in a dark room
// (misc.c erase_lamp).
func (g *RogueGame) eraseLamp(pos Coord, rp *Room) {
if !(g.Options.SeeFloor && rp.Flags&(IsGone|IsDark) == IsDark &&
!g.Player.On(IsBlind)) {
if !(g.Options.SeeFloor && rp.Flags&(Gone|Dark) == Dark &&
!g.Player.On(Blind)) {
return
}
@@ -195,7 +195,7 @@ func (g *RogueGame) eraseLamp(pos Coord, rp *Room) {
// showFloor reports whether we show the floor in her room at this time
// (misc.c show_floor).
func (g *RogueGame) showFloor() bool {
if g.Player.Room.Flags&(IsGone|IsDark) == IsDark && !g.Player.On(IsBlind) {
if g.Player.Room.Flags&(Gone|Dark) == Dark && !g.Player.On(Blind) {
return g.Options.SeeFloor
}
return true
@@ -278,10 +278,10 @@ func (g *RogueGame) chgStr(amt int) {
p := &g.Player
addStr(&p.Stats.Str, amt)
comp := p.Stats.Str
if p.IsRing(Left, RAddStr) {
if p.IsRing(Left, RingAddStrength) {
addStr(&comp, -p.CurRing[Left].Arm)
}
if p.IsRing(Right, RAddStr) {
if p.IsRing(Right, RingAddStrength) {
addStr(&comp, -p.CurRing[Right].Arm)
}
if comp > p.MaxStats.Str {
@@ -301,14 +301,14 @@ func addStr(sp *int, amt int) {
// addHaste adds a haste to the player (misc.c add_haste).
func (g *RogueGame) addHaste(potion bool) bool {
p := &g.Player
if p.On(IsHaste) {
if p.On(Hasted) {
g.NoCommand += g.rnd(8)
p.Flags.Clear(IsRun | IsHaste)
p.Flags.Clear(Awake | Hasted)
g.Extinguish(DNohaste)
g.msg("you faint from exhaustion")
return false
}
p.Flags.Set(IsHaste)
p.Flags.Set(Hasted)
if potion {
g.Fuse(DNohaste, 0, g.rnd(4)+4, After)
}
@@ -403,7 +403,7 @@ func (g *RogueGame) getDir() bool {
g.LastDir = g.DirCh
g.lastDelt = g.Delta
}
if g.Player.On(IsHuh) && g.rnd(5) == 0 {
if g.Player.On(Confused) && g.rnd(5) == 0 {
for {
g.Delta.Y = g.rnd(3) - 1
g.Delta.X = g.rnd(3) - 1
@@ -451,7 +451,7 @@ func (g *RogueGame) rndThing() byte {
// chooseStr picks the first or second string depending on whether the
// player is tripping (misc.c choose_str).
func (g *RogueGame) chooseStr(ts, ns string) string {
if g.Player.On(IsHalu) {
if g.Player.On(Hallucinating) {
return ts
}
return ns

View File

@@ -60,11 +60,11 @@ func (g *RogueGame) newMonster(tp *Monster, typ byte, cp Coord) {
tp.Stats.Exp = mp.Stats.Exp + levAdd*10 + expAdd(tp)
tp.Flags = mp.Flags
if g.Depth > 29 {
tp.Flags.Set(IsHaste)
tp.Flags.Set(Hasted)
}
tp.Turn = true
tp.Pack = nil
if g.Player.IsWearing(RAggr) {
if g.Player.IsWearing(RingAggravateMonsters) {
g.runto(cp)
}
if typ == 'X' {
@@ -101,9 +101,9 @@ func (g *RogueGame) wanderer() {
}
}
g.newMonster(tp, g.randMonster(true), cp)
if g.Player.On(SeeMonst) {
if g.Player.On(SenseMonsters) {
g.standout()
if !g.Player.On(IsHalu) {
if !g.Player.On(Hallucinating) {
g.addch(tp.Type)
} else {
g.addch(byte(g.rnd(26) + 'A'))
@@ -123,24 +123,24 @@ func (g *RogueGame) wakeMonster(y, x int) *Monster {
}
ch := tp.Type
// Every time he sees a mean monster, it might start chasing him
if !tp.On(IsRun) && g.rnd(3) != 0 && tp.On(IsMean) && !tp.On(IsHeld) &&
!p.IsWearing(RStealth) && !p.On(IsLevit) {
if !tp.On(Awake) && g.rnd(3) != 0 && tp.On(Mean) && !tp.On(Held) &&
!p.IsWearing(RingStealth) && !p.On(Levitating) {
tp.Dest = &p.Pos
tp.Flags.Set(IsRun)
tp.Flags.Set(Awake)
}
if ch == 'M' && !p.On(IsBlind) && !p.On(IsHalu) &&
!tp.On(IsFound) && !tp.On(IsCanc) && tp.On(IsRun) {
if ch == 'M' && !p.On(Blind) && !p.On(Hallucinating) &&
!tp.On(Found) && !tp.On(Cancelled) && tp.On(Awake) {
rp := p.Room
if (rp != nil && !rp.Flags.Has(IsDark)) ||
if (rp != nil && !rp.Flags.Has(Dark)) ||
distance(y, x, p.Pos.Y, p.Pos.X) < LampDist {
tp.Flags.Set(IsFound)
tp.Flags.Set(Found)
if !g.save(VsMagic) {
if p.On(IsHuh) {
if p.On(Confused) {
g.Lengthen(DUnconfuse, g.spread(HuhDuration))
} else {
g.Fuse(DUnconfuse, 0, g.spread(HuhDuration), After)
}
p.Flags.Set(IsHuh)
p.Flags.Set(Confused)
mname := g.setMname(tp)
g.addmsg("%s", mname)
if mname != "it" {
@@ -151,8 +151,8 @@ func (g *RogueGame) wakeMonster(y, x int) *Monster {
}
}
// Let greedy ones guard gold
if tp.On(IsGreed) && !tp.On(IsRun) {
tp.Flags.Set(IsRun)
if tp.On(Greedy) && !tp.On(Awake) {
tp.Flags.Set(Awake)
if p.Room.GoldVal != 0 {
tp.Dest = &p.Room.Gold
} else {
@@ -182,10 +182,10 @@ func (g *RogueGame) saveThrow(which int, st *Stats) bool {
func (g *RogueGame) save(which int) bool {
p := &g.Player
if which == VsMagic {
if p.IsRing(Left, RProtect) {
if p.IsRing(Left, RingProtection) {
which -= p.CurRing[Left].Arm
}
if p.IsRing(Right, RProtect) {
if p.IsRing(Right, RingProtection) {
which -= p.CurRing[Right].Arm
}
}

View File

@@ -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")
}

View File

@@ -12,7 +12,7 @@ const (
// NewLevel digs and draws a new level (new_level.c new_level).
func (g *RogueGame) NewLevel() {
p := &g.Player
p.Flags.Clear(IsHeld) // unhold when you go down just in case
p.Flags.Clear(Held) // unhold when you go down just in case
if g.Depth > g.MaxDepth {
g.MaxDepth = g.Depth
}
@@ -31,11 +31,11 @@ func (g *RogueGame) NewLevel() {
g.putThings() // Place objects (if any)
// Place the traps
if g.rnd(10) < g.Depth {
g.Level.NTraps = g.rnd(g.Depth/4) + 1
if g.Level.NTraps > MaxTraps {
g.Level.NTraps = MaxTraps
g.Level.TrapCount = g.rnd(g.Depth/4) + 1
if g.Level.TrapCount > MaxTraps {
g.Level.TrapCount = MaxTraps
}
for i := g.Level.NTraps; i > 0; i-- {
for i := g.Level.TrapCount; i > 0; i-- {
// not only wouldn't it be NICE to have traps in mazes (not
// that we care about being nice), since the trap number is
// stored where the passage number is, we can't actually do it.
@@ -48,7 +48,7 @@ func (g *RogueGame) NewLevel() {
}
sp := g.Level.FlagsAt(stairs.Y, stairs.X)
sp.Clear(FReal)
*sp |= PlaceFlags(g.rnd(NTraps))
*sp |= PlaceFlags(g.rnd(NumTrapTypes))
}
}
// Place the staircase down.
@@ -65,10 +65,10 @@ func (g *RogueGame) NewLevel() {
p.Pos = hero
g.enterRoom(hero)
g.mvaddch(hero.Y, hero.X, PlayerCh)
if p.On(SeeMonst) {
if p.On(SenseMonsters) {
g.turnSee(false)
}
if p.On(IsHalu) {
if p.On(Hallucinating) {
g.visuals(0)
}
}
@@ -77,7 +77,7 @@ func (g *RogueGame) NewLevel() {
func (g *RogueGame) rndRoom() int {
for {
rm := g.rnd(MaxRooms)
if !g.Level.Rooms[rm].Flags.Has(IsGone) {
if !g.Level.Rooms[rm].Flags.Has(Gone) {
return rm
}
}
@@ -151,7 +151,7 @@ func (g *RogueGame) treasRoom() {
if mp, ok := g.findFloorIn(rp, maxTries, true); ok {
tp := &Monster{}
g.newMonster(tp, g.randMonster(false), mp)
tp.Flags.Set(IsMean) // no sloughers in THIS room
tp.Flags.Set(Mean) // no sloughers in THIS room
g.givePack(tp)
}
}

View File

@@ -86,10 +86,10 @@ func TestNewLevelInvariants(t *testing.T) {
t.Errorf("seed %d: starting pack has %d items, want 5",
seed, len(g.Player.Pack))
}
if g.Player.CurWeapon == nil || g.Player.CurWeapon.Which != Mace {
if g.Player.CurWeapon == nil || g.Player.CurWeapon.Which != WeaponMace {
t.Errorf("seed %d: not wielding the starting mace", seed)
}
if g.Player.CurArmor == nil || g.Player.CurArmor.Which != RingMail {
if g.Player.CurArmor == nil || g.Player.CurArmor.Which != ArmorRingMail {
t.Errorf("seed %d: not wearing the starting ring mail", seed)
}
}

View File

@@ -15,10 +15,10 @@ func (g *RogueGame) addPack(obj *Object, silent bool) {
}
// Check for and deal with scare monster scrolls
if obj.Type == Scroll && obj.Which == SScare && obj.Flags.Has(ObjIsFound) {
if obj.Type == Scroll && obj.Which == ScrollScareMonster && obj.Flags.Has(WasFound) {
detachObj(&g.Level.Objects, obj)
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorCh())
if p.Room.Flags.Has(IsGone) {
if p.Room.Flags.Has(Gone) {
g.Level.SetChar(p.Pos.Y, p.Pos.X, Passage)
} else {
g.Level.SetChar(p.Pos.Y, p.Pos.X, Floor)
@@ -101,7 +101,7 @@ func (g *RogueGame) addPack(obj *Object, silent bool) {
}
}
obj.Flags.Set(ObjIsFound)
obj.Flags.Set(WasFound)
// If this was the object of something's desire, that monster will get
// mad and run at the hero.
@@ -146,7 +146,7 @@ func (g *RogueGame) packRoom(fromFloor bool, obj *Object) bool {
if fromFloor {
detachObj(&g.Level.Objects, obj)
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorCh())
if p.Room.Flags.Has(IsGone) {
if p.Room.Flags.Has(Gone) {
g.Level.SetChar(p.Pos.Y, p.Pos.X, Passage)
} else {
g.Level.SetChar(p.Pos.Y, p.Pos.X, Floor)
@@ -234,7 +234,7 @@ func (g *RogueGame) inventory(list []*Object, typ int) bool {
// pickUp adds something to the character's pack (pack.c pick_up).
func (g *RogueGame) pickUp(ch byte) {
p := &g.Player
if p.On(IsLevit) {
if p.On(Levitating) {
return
}
@@ -348,7 +348,7 @@ func (g *RogueGame) money(value int) {
p := &g.Player
p.Purse += value
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorCh())
if p.Room.Flags.Has(IsGone) {
if p.Room.Flags.Has(Gone) {
g.Level.SetChar(p.Pos.Y, p.Pos.X, Passage)
} else {
g.Level.SetChar(p.Pos.Y, p.Pos.X, Floor)
@@ -364,7 +364,7 @@ func (g *RogueGame) money(value int) {
// floorCh returns the appropriate floor character for her room
// (pack.c floor_ch).
func (g *RogueGame) floorCh() byte {
if g.Player.Room.Flags.Has(IsGone) {
if g.Player.Room.Flags.Has(Gone) {
return Passage
}
if g.showFloor() {

View File

@@ -110,24 +110,24 @@ func (g *RogueGame) conn(r1, r2 int) {
var del, turnDelta, spos, epos Coord
var distance, turnDistance int
if direc == 'd' {
rmt := rm + 3 // room # of dest
rpt = &g.Level.Rooms[rmt] // room pointer of dest
del = Coord{X: 0, Y: 1} // direction of move
spos = rpf.Pos // start of move
epos = rpt.Pos // end of move
if !rpf.Flags.Has(IsGone) { // if not gone pick door pos
rmt := rm + 3 // room # of dest
rpt = &g.Level.Rooms[rmt] // room pointer of dest
del = Coord{X: 0, Y: 1} // direction of move
spos = rpf.Pos // start of move
epos = rpt.Pos // end of move
if !rpf.Flags.Has(Gone) { // if not gone pick door pos
for {
spos.X = rpf.Pos.X + g.rnd(rpf.Max.X-2) + 1
spos.Y = rpf.Pos.Y + rpf.Max.Y - 1
if !(rpf.Flags.Has(IsMaze) && !g.Level.FlagsAt(spos.Y, spos.X).Has(FPass)) {
if !(rpf.Flags.Has(Maze) && !g.Level.FlagsAt(spos.Y, spos.X).Has(FPassage)) {
break
}
}
}
if !rpt.Flags.Has(IsGone) {
if !rpt.Flags.Has(Gone) {
for {
epos.X = rpt.Pos.X + g.rnd(rpt.Max.X-2) + 1
if !(rpt.Flags.Has(IsMaze) && !g.Level.FlagsAt(epos.Y, epos.X).Has(FPass)) {
if !(rpt.Flags.Has(Maze) && !g.Level.FlagsAt(epos.Y, epos.X).Has(FPassage)) {
break
}
}
@@ -146,19 +146,19 @@ func (g *RogueGame) conn(r1, r2 int) {
del = Coord{X: 1, Y: 0}
spos = rpf.Pos
epos = rpt.Pos
if !rpf.Flags.Has(IsGone) {
if !rpf.Flags.Has(Gone) {
for {
spos.X = rpf.Pos.X + rpf.Max.X - 1
spos.Y = rpf.Pos.Y + g.rnd(rpf.Max.Y-2) + 1
if !(rpf.Flags.Has(IsMaze) && !g.Level.FlagsAt(spos.Y, spos.X).Has(FPass)) {
if !(rpf.Flags.Has(Maze) && !g.Level.FlagsAt(spos.Y, spos.X).Has(FPassage)) {
break
}
}
}
if !rpt.Flags.Has(IsGone) {
if !rpt.Flags.Has(Gone) {
for {
epos.Y = rpt.Pos.Y + g.rnd(rpt.Max.Y-2) + 1
if !(rpt.Flags.Has(IsMaze) && !g.Level.FlagsAt(epos.Y, epos.X).Has(FPass)) {
if !(rpt.Flags.Has(Maze) && !g.Level.FlagsAt(epos.Y, epos.X).Has(FPassage)) {
break
}
}
@@ -177,12 +177,12 @@ func (g *RogueGame) conn(r1, r2 int) {
// Draw in the doors on either side of the passage or just put #'s if
// the rooms are gone.
if !rpf.Flags.Has(IsGone) {
if !rpf.Flags.Has(Gone) {
g.door(rpf, spos)
} else {
g.putpass(spos)
}
if !rpt.Flags.Has(IsGone) {
if !rpt.Flags.Has(Gone) {
g.door(rpt, epos)
} else {
g.putpass(epos)
@@ -216,7 +216,7 @@ func (g *RogueGame) conn(r1, r2 int) {
// putpass).
func (g *RogueGame) putpass(cp Coord) {
pp := g.Level.At(cp.Y, cp.X)
pp.Flags.Set(FPass)
pp.Flags.Set(FPassage)
if g.rnd(10)+1 < g.Depth && g.rnd(40) == 0 {
pp.Flags.Clear(FReal)
} else {
@@ -229,7 +229,7 @@ func (g *RogueGame) putpass(cp Coord) {
func (g *RogueGame) door(rm *Room, cp Coord) {
rm.Exits = append(rm.Exits, cp)
if rm.Flags.Has(IsMaze) {
if rm.Flags.Has(Maze) {
return
}
@@ -252,10 +252,10 @@ func (g *RogueGame) addPass() {
for y := 1; y < NumLines-1; y++ {
for x := 0; x < NumCols; x++ {
pp := g.Level.At(y, x)
if pp.Flags.Has(FPass) || pp.Ch == Door ||
if pp.Flags.Has(FPassage) || pp.Ch == Door ||
(!pp.Flags.Has(FReal) && (pp.Ch == '|' || pp.Ch == '-')) {
ch := pp.Ch
if pp.Flags.Has(FPass) {
if pp.Flags.Has(FPassage) {
ch = Passage
}
pp.Flags.Set(FSeen)
@@ -266,7 +266,7 @@ func (g *RogueGame) addPass() {
g.addch(ch)
} else {
g.standout()
if pp.Flags.Has(FPass) {
if pp.Flags.Has(FPassage) {
g.addch(Passage)
} else {
g.addch(Door)
@@ -301,7 +301,7 @@ func (g *RogueGame) numpass(y, x int) {
return
}
fp := g.Level.FlagsAt(y, x)
if fp.Has(FPNum) {
if fp.Has(FPassNum) {
return
}
if g.newpnum {
@@ -314,7 +314,7 @@ func (g *RogueGame) numpass(y, x int) {
(!fp.Has(FReal) && (ch == '|' || ch == '-')) {
rp := &g.Level.Passages[g.pnum]
rp.Exits = append(rp.Exits, Coord{Y: y, X: x})
} else if !fp.Has(FPass) {
} else if !fp.Has(FPassage) {
return
}
*fp |= PlaceFlags(g.pnum)

View File

@@ -15,18 +15,18 @@ type pact struct {
// pActions is potions.c p_actions[]. The P_SEEINVIS message is dynamic
// (it names the fruit) and is computed in doPot.
var pActions = [MaxPotions]pact{
PConfuse: {IsHuh, DUnconfuse, HuhDuration,
var pActions = [NumPotionTypes]pact{
PotionConfusion: {Confused, DUnconfuse, HuhDuration,
"what a tripy feeling!",
"wait, what's going on here. Huh? What? Who?"},
PLSD: {IsHalu, DComeDown, SeeDuration,
PotionLSD: {Hallucinating, DComeDown, SeeDuration,
"Oh, wow! Everything seems so cosmic!",
"Oh, wow! Everything seems so cosmic!"},
PSeeInvis: {CanSee, DUnsee, SeeDuration, "", ""},
PBlind: {IsBlind, DSight, SeeDuration,
PotionSeeInvisible: {CanSeeInvisible, DUnsee, SeeDuration, "", ""},
PotionBlindness: {Blind, DSight, SeeDuration,
"oh, bummer! Everything is dark! Help!",
"a cloak of darkness falls around you"},
PLevit: {IsLevit, DLand, HealTime,
PotionLevitation: {Levitating, DLand, HealTime,
"oh, wow! You're floating in the air!",
"you start to float in the air"},
}
@@ -52,40 +52,40 @@ func (g *RogueGame) quaff() {
}
// Calculate the effect it has on the poor guy.
trip := p.On(IsHalu)
trip := p.On(Hallucinating)
g.leavePack(obj, false, false)
switch obj.Which {
case PConfuse:
g.doPot(PConfuse, !trip)
case PPoison:
g.Items.Potions[PPoison].Know = true
if p.IsWearing(RSustStr) {
case PotionConfusion:
g.doPot(PotionConfusion, !trip)
case PotionPoison:
g.Items.Potions[PotionPoison].Know = true
if p.IsWearing(RingSustainStrength) {
g.msg("you feel momentarily sick")
} else {
g.chgStr(-(g.rnd(3) + 1))
g.msg("you feel very sick now")
g.comeDown(0)
}
case PHealing:
g.Items.Potions[PHealing].Know = true
case PotionHealing:
g.Items.Potions[PotionHealing].Know = true
if p.Stats.HP += g.roll(p.Stats.Lvl, 4); p.Stats.HP > p.Stats.MaxHP {
p.Stats.MaxHP++
p.Stats.HP = p.Stats.MaxHP
}
g.sight(0)
g.msg("you begin to feel better")
case PStrength:
g.Items.Potions[PStrength].Know = true
case PotionGainStrength:
g.Items.Potions[PotionGainStrength].Know = true
g.chgStr(1)
g.msg("you feel stronger, now. What bulging muscles!")
case PMFind:
p.Flags.Set(SeeMonst)
case PotionDetectMonsters:
p.Flags.Set(SenseMonsters)
g.Fuse(DTurnSee, 1, HuhDuration, After)
if !g.turnSee(false) {
g.msg("you have a %s feeling for a moment, then it passes",
g.chooseStr("normal", "strange"))
}
case PTFind:
case PotionDetectMagic:
// Potion of magic detection. Show the potions and scrolls
show := false
if len(g.Level.Objects) > 0 {
@@ -94,7 +94,7 @@ func (g *RogueGame) quaff() {
if tp.isMagic() {
show = true
g.scr.Hw.MvAddCh(tp.Pos.Y, tp.Pos.X, Magic)
g.Items.Potions[PTFind].Know = true
g.Items.Potions[PotionDetectMagic].Know = true
}
}
for _, mp := range g.Level.Monsters {
@@ -107,34 +107,34 @@ func (g *RogueGame) quaff() {
}
}
if show {
g.Items.Potions[PTFind].Know = true
g.Items.Potions[PotionDetectMagic].Know = true
g.showWin("You sense the presence of magic on this level.--More--")
} else {
g.msg("you have a %s feeling for a moment, then it passes",
g.chooseStr("normal", "strange"))
}
case PLSD:
case PotionLSD:
if !trip {
if p.On(SeeMonst) {
if p.On(SenseMonsters) {
g.turnSee(false)
}
g.StartDaemon(DVisuals, 0, Before)
g.SeenStairs = g.seenStairs()
}
g.doPot(PLSD, true)
case PSeeInvis:
show := p.On(CanSee)
g.doPot(PSeeInvis, false)
g.doPot(PotionLSD, true)
case PotionSeeInvisible:
show := p.On(CanSeeInvisible)
g.doPot(PotionSeeInvisible, false)
if !show {
g.invisOn()
}
g.sight(0)
case PRaise:
g.Items.Potions[PRaise].Know = true
case PotionRaiseLevel:
g.Items.Potions[PotionRaiseLevel].Know = true
g.msg("you suddenly feel much more skillful")
g.raiseLevel()
case PXHeal:
g.Items.Potions[PXHeal].Know = true
case PotionExtraHealing:
g.Items.Potions[PotionExtraHealing].Know = true
if p.Stats.HP += g.roll(p.Stats.Lvl, 8); p.Stats.HP > p.Stats.MaxHP {
if p.Stats.HP > p.Stats.MaxHP+p.Stats.Lvl+1 {
p.Stats.MaxHP++
@@ -145,33 +145,33 @@ func (g *RogueGame) quaff() {
g.sight(0)
g.comeDown(0)
g.msg("you begin to feel much better")
case PHaste:
g.Items.Potions[PHaste].Know = true
case PotionHaste:
g.Items.Potions[PotionHaste].Know = true
g.After = false
if g.addHaste(true) {
g.msg("you feel yourself moving much faster")
}
case PRestore:
if p.IsRing(Left, RAddStr) {
case PotionRestoreStrength:
if p.IsRing(Left, RingAddStrength) {
addStr(&p.Stats.Str, -p.CurRing[Left].Arm)
}
if p.IsRing(Right, RAddStr) {
if p.IsRing(Right, RingAddStrength) {
addStr(&p.Stats.Str, -p.CurRing[Right].Arm)
}
if p.Stats.Str < p.MaxStats.Str {
p.Stats.Str = p.MaxStats.Str
}
if p.IsRing(Left, RAddStr) {
if p.IsRing(Left, RingAddStrength) {
addStr(&p.Stats.Str, p.CurRing[Left].Arm)
}
if p.IsRing(Right, RAddStr) {
if p.IsRing(Right, RingAddStrength) {
addStr(&p.Stats.Str, p.CurRing[Right].Arm)
}
g.msg("hey, this tastes great. It make you feel warm all over")
case PBlind:
g.doPot(PBlind, true)
case PLevit:
g.doPot(PLevit, true)
case PotionBlindness:
g.doPot(PotionBlindness, true)
case PotionLevitation:
g.doPot(PotionLevitation, true)
}
g.status()
// Throw the item away
@@ -201,7 +201,7 @@ func (g *RogueGame) doPot(typ int, knowit bool) {
g.Lengthen(pp.daemon, t)
}
high, straight := pp.high, pp.straight
if typ == PSeeInvis {
if typ == PotionSeeInvisible {
s := fmt.Sprintf("this potion tastes like %s juice", g.Fruit)
high, straight = s, s
}
@@ -212,7 +212,7 @@ func (g *RogueGame) doPot(typ int, knowit bool) {
func (o *Object) isMagic() bool {
switch o.Type {
case Armor:
return o.Flags.Has(IsProt) || o.Arm != aClass[o.Which]
return o.Flags.Has(Protected) || o.Arm != aClass[o.Which]
case Weapon:
return o.HPlus != 0 || o.DPlus != 0
case Potion, Scroll, Stick, Ring, Amulet:
@@ -224,9 +224,9 @@ func (o *Object) isMagic() bool {
// invisOn turns on the ability to see invisible monsters (potions.c
// invis_on).
func (g *RogueGame) invisOn() {
g.Player.Flags.Set(CanSee)
g.Player.Flags.Set(CanSeeInvisible)
for _, mp := range g.Level.Monsters {
if mp.On(IsInvis) && g.seeMonst(mp) && !g.Player.On(IsHalu) {
if mp.On(Invisible) && g.seeMonst(mp) && !g.Player.On(Hallucinating) {
g.mvaddch(mp.Pos.Y, mp.Pos.X, mp.Disguise)
}
}
@@ -247,7 +247,7 @@ func (g *RogueGame) turnSee(turnOff bool) bool {
if !canSee {
g.standout()
}
if !g.Player.On(IsHalu) {
if !g.Player.On(Hallucinating) {
g.addch(mp.Type)
} else {
g.addch(byte(g.rnd(26) + 'A'))
@@ -259,9 +259,9 @@ func (g *RogueGame) turnSee(turnOff bool) bool {
}
}
if turnOff {
g.Player.Flags.Clear(SeeMonst)
g.Player.Flags.Clear(SenseMonsters)
} else {
g.Player.Flags.Set(SeeMonst)
g.Player.Flags.Set(SenseMonsters)
}
return addNew
}
@@ -279,10 +279,10 @@ func (g *RogueGame) seenStairs() bool {
}
// if a monster is on the stairs, this gets hairy
if tp := g.Level.MonsterAt(st.Y, st.X); tp != nil {
if g.seeMonst(tp) && tp.On(IsRun) { // visible and awake:
if g.seeMonst(tp) && tp.On(Awake) { // visible and awake:
return true // it must have moved there
}
if g.Player.On(SeeMonst) && tp.OldCh == Stairs {
if g.Player.On(SenseMonsters) && tp.OldCh == Stairs {
return true
}
}

View File

@@ -48,11 +48,11 @@ func (g *RogueGame) ringOn() {
// Calculate the effect it has on the poor guy.
switch obj.Which {
case RAddStr:
case RingAddStrength:
g.chgStr(obj.Arm)
case RSeeInvis:
case RingSeeInvisible:
g.invisOn()
case RAggr:
case RingAggravateMonsters:
g.aggravate()
}
@@ -123,7 +123,7 @@ func (g *RogueGame) gethand() int {
// 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 = [MaxRings]int{
var ringUses = [NumRingTypes]int{
1, // R_PROTECT
1, // R_ADDSTR
1, // R_SUSTSTR
@@ -155,7 +155,7 @@ func (g *RogueGame) ringEat(hand int) int {
eat = 0
}
}
if ring.Which == RDigest {
if ring.Which == RingSlowDigestion {
eat = -eat
}
return eat
@@ -163,11 +163,11 @@ func (g *RogueGame) ringEat(hand int) int {
// ringNum prints ring bonuses (rings.c ring_num).
func ringNum(g *RogueGame, obj *Object) string {
if !obj.Flags.Has(IsKnow) {
if !obj.Flags.Has(Known) {
return ""
}
switch obj.Which {
case RProtect, RAddStr, RAddDam, RAddHit:
case RingProtection, RingAddStrength, RingIncreaseDamage, RingDexterity:
return fmt.Sprintf(" [%s]", num(obj.Arm, 0, Ring))
}
return ""

View File

@@ -121,12 +121,12 @@ func (g *RogueGame) totalWinner() {
case Weapon:
worth = it.Weapons[obj.Which].Worth
worth *= 3*(obj.HPlus+obj.DPlus) + obj.Count
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
case Armor:
worth = it.Armors[obj.Which].Worth
worth += (9 - obj.Arm) * 100
worth += 10 * (aClass[obj.Which] - obj.Arm)
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
case Scroll:
op := &it.Scrolls[obj.Which]
worth = op.Worth * obj.Count
@@ -144,27 +144,27 @@ func (g *RogueGame) totalWinner() {
case Ring:
op := &it.Rings[obj.Which]
worth = op.Worth
if obj.Which == RAddStr || obj.Which == RAddDam ||
obj.Which == RProtect || obj.Which == RAddHit {
if obj.Which == RingAddStrength || obj.Which == RingIncreaseDamage ||
obj.Which == RingProtection || obj.Which == RingDexterity {
if obj.Arm > 0 {
worth += obj.Arm * 100
} else {
worth = 10
}
}
if !obj.Flags.Has(IsKnow) {
if !obj.Flags.Has(Known) {
worth /= 2
}
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
op.Know = true
case Stick:
op := &it.Sticks[obj.Which]
worth = op.Worth
worth += 20 * obj.Charges()
if !obj.Flags.Has(IsKnow) {
if !obj.Flags.Has(Known) {
worth /= 2
}
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
op.Know = true
case Amulet:
worth = 1000

View File

@@ -33,14 +33,14 @@ func (g *RogueGame) doRooms() {
// Put the gone rooms, if any, on the level
leftOut := g.rnd(4)
for i := 0; i < leftOut; i++ {
g.Level.Rooms[g.rndRoom()].Flags.Set(IsGone)
g.Level.Rooms[g.rndRoom()].Flags.Set(Gone)
}
// dig and populate all the rooms on the level
for i := range g.Level.Rooms {
rp := &g.Level.Rooms[i]
// Find upper left corner of box that this room goes in
top := Coord{X: (i%3)*bsze.X + 1, Y: (i / 3) * bsze.Y}
if rp.Flags.Has(IsGone) {
if rp.Flags.Has(Gone) {
// Place a gone room. Make certain that there is a blank line
// for passage drawing.
for {
@@ -56,13 +56,13 @@ func (g *RogueGame) doRooms() {
}
// set room type
if g.rnd(10) < g.Depth-1 {
rp.Flags.Set(IsDark) // dark room
rp.Flags.Set(Dark) // dark room
if g.rnd(15) == 0 {
rp.Flags = IsMaze // maze room
rp.Flags = Maze // maze room
}
}
// Find a place and size for a random room
if rp.Flags.Has(IsMaze) {
if rp.Flags.Has(Maze) {
rp.Max.X = bsze.X - 1
rp.Max.Y = bsze.Y - 1
if rp.Pos.X = top.X; rp.Pos.X == 1 {
@@ -92,7 +92,7 @@ func (g *RogueGame) doRooms() {
rp.Gold, _ = g.findFloorIn(rp, 0, false)
gold.Pos = rp.Gold
g.Level.SetChar(rp.Gold.Y, rp.Gold.X, Gold)
gold.Flags = IsMany
gold.Flags = Stackable
gold.Group = goldGrp
gold.Type = Gold
attachObj(&g.Level.Objects, gold)
@@ -114,7 +114,7 @@ func (g *RogueGame) doRooms() {
// drawRoom draws a box around a room and lays down the floor for normal
// rooms; for maze rooms, draws the maze (rooms.c draw_room).
func (g *RogueGame) drawRoom(rp *Room) {
if rp.Flags.Has(IsMaze) {
if rp.Flags.Has(Maze) {
g.doMaze(rp)
return
}
@@ -180,7 +180,7 @@ func (g *RogueGame) dig(y, x int) {
if newy < 0 || newy > m.maxy || newx < 0 || newx > m.maxx {
continue
}
if g.Level.FlagsAt(newy+m.starty, newx+m.startx).Has(FPass) {
if g.Level.FlagsAt(newy+m.starty, newx+m.startx).Has(FPassage) {
continue
}
if cnt++; g.rnd(cnt) == 0 {
@@ -257,7 +257,7 @@ func (g *RogueGame) findFloorImpl(rp *Room, limit int, monst, pickroom bool) (Co
var compchar byte
if !pickroom {
compchar = Floor
if rp.Flags.Has(IsMaze) {
if rp.Flags.Has(Maze) {
compchar = Passage
}
}
@@ -271,7 +271,7 @@ func (g *RogueGame) findFloorImpl(rp *Room, limit int, monst, pickroom bool) (Co
if pickroom {
rp = &g.Level.Rooms[g.rndRoom()]
compchar = Floor
if rp.Flags.Has(IsMaze) {
if rp.Flags.Has(Maze) {
compchar = Passage
}
}
@@ -294,7 +294,7 @@ func (g *RogueGame) enterRoom(cp Coord) {
rp := g.roomin(cp)
p.Room = rp
g.doorOpen(rp)
if !rp.Flags.Has(IsDark) && !p.On(IsBlind) {
if !rp.Flags.Has(Dark) && !p.On(Blind) {
for y := rp.Pos.Y; y < rp.Max.Y+rp.Pos.Y; y++ {
g.move(y, rp.Pos.X)
for x := rp.Pos.X; x < rp.Max.X+rp.Pos.X; x++ {
@@ -309,7 +309,7 @@ func (g *RogueGame) enterRoom(cp Coord) {
} else {
tp.OldCh = ch
if !g.seeMonst(tp) {
if p.On(SeeMonst) {
if p.On(SenseMonsters) {
g.standout()
g.addch(tp.Disguise)
g.standend()
@@ -330,21 +330,21 @@ func (g *RogueGame) leaveRoom(cp Coord) {
p := &g.Player
rp := p.Room
if rp.Flags.Has(IsMaze) {
if rp.Flags.Has(Maze) {
return
}
var floor byte
switch {
case rp.Flags.Has(IsGone):
case rp.Flags.Has(Gone):
floor = Passage
case !rp.Flags.Has(IsDark) || p.On(IsBlind):
case !rp.Flags.Has(Dark) || p.On(Blind):
floor = Floor
default:
floor = ' '
}
p.Room = &g.Level.Passages[*g.Level.FlagsAt(cp.Y, cp.X)&FPNum]
p.Room = &g.Level.Passages[*g.Level.FlagsAt(cp.Y, cp.X)&FPassNum]
for y := rp.Pos.Y; y < rp.Max.Y+rp.Pos.Y; y++ {
for x := rp.Pos.X; x < rp.Max.X+rp.Pos.X; x++ {
g.move(y, x)
@@ -357,7 +357,7 @@ func (g *RogueGame) leaveRoom(cp Coord) {
// to check for monster, we have to strip out the standout
// bit (our Window returns the bare character already)
if isUpper(ch) {
if p.On(SeeMonst) {
if p.On(SenseMonsters) {
g.standout()
g.addch(ch)
g.standend()

View File

@@ -74,14 +74,14 @@ type SaveState struct {
HasAmulet bool
SeenStairs bool
Places []savedPlace
Rooms [MaxRooms]Room
Passages [MaxPass]Room
Objects []Object
Monsters []savedCreature
Dests []destRef // parallel to Monsters
Stairs Coord
NTraps int
Places []savedPlace
Rooms [MaxRooms]Room
Passages [MaxPass]Room
Objects []Object
Monsters []savedCreature
Dests []destRef // parallel to Monsters
Stairs Coord
TrapCount int
After bool
Again bool
@@ -179,7 +179,7 @@ func (g *RogueGame) snapshot() *SaveState {
Rooms: g.Level.Rooms,
Passages: g.Level.Passages,
Stairs: g.Level.Stairs,
NTraps: g.Level.NTraps,
TrapCount: g.Level.TrapCount,
After: g.After,
Again: g.Again,
NoScoreF: g.NoScore,
@@ -308,7 +308,7 @@ func (g *RogueGame) applySnapshot(st *SaveState) {
g.Level.Rooms = st.Rooms
g.Level.Passages = st.Passages
g.Level.Stairs = st.Stairs
g.Level.NTraps = st.NTraps
g.Level.TrapCount = st.TrapCount
g.After = st.After
g.Again = st.Again
g.NoScore = st.NoScoreF

View File

@@ -13,11 +13,11 @@ func TestSaveRestoreRoundTrip(t *testing.T) {
g.Player.Purse = 123
g.Player.FoodLeft = 777
g.HasAmulet = true
g.Items.Potions[PHealing].Know = true
g.Items.Scrolls[SMap].Guess = "map???"
g.Items.Potions[PotionHealing].Know = true
g.Items.Scrolls[ScrollMagicMapping].Guess = "map???"
g.Monsters['F'-'A'].Stats.Dmg = "3x1" // mutated bestiary must survive
if len(g.Level.Monsters) > 0 {
g.Level.Monsters[0].Flags.Set(IsRun)
g.Level.Monsters[0].Flags.Set(Awake)
g.Level.Monsters[0].Dest = &g.Player.Pos
}
@@ -42,10 +42,10 @@ func TestSaveRestoreRoundTrip(t *testing.T) {
if !h.HasAmulet {
t.Error("amulet flag lost")
}
if !h.Items.Potions[PHealing].Know {
if !h.Items.Potions[PotionHealing].Know {
t.Error("potion identification lost")
}
if h.Items.Scrolls[SMap].Guess != "map???" {
if h.Items.Scrolls[ScrollMagicMapping].Guess != "map???" {
t.Error("scroll guess lost")
}
if h.Monsters['F'-'A'].Stats.Dmg != "3x1" {

View File

@@ -4,12 +4,12 @@ package game
// idType maps identify scrolls to the type they identify (scrolls.c
// static id_type).
var idType = [SIDRorS + 1]int{
SIDPotion: int(Potion),
SIDScroll: int(Scroll),
SIDWeapon: int(Weapon),
SIDArmor: int(Armor),
SIDRorS: RorS,
var idType = [ScrollIdentifyRingOrStick + 1]int{
ScrollIdentifyPotion: int(Potion),
ScrollIdentifyScroll: int(Scroll),
ScrollIdentifyWeapon: int(Weapon),
ScrollIdentifyArmor: int(Armor),
ScrollIdentifyRingOrStick: RorS,
}
// readScroll reads a scroll from the pack and does the appropriate thing
@@ -36,17 +36,17 @@ func (g *RogueGame) readScroll() {
g.leavePack(obj, false, false)
switch obj.Which {
case SConfuse:
case ScrollMonsterConfusion:
// Scroll of monster confusion. Give him that power.
p.Flags.Set(CanHuh)
p.Flags.Set(CanConfuse)
g.msg("your hands begin to glow %s", g.pickColor("red"))
case SArmor:
case ScrollEnchantArmor:
if p.CurArmor != nil {
p.CurArmor.Arm--
p.CurArmor.Flags.Clear(IsCursed)
p.CurArmor.Flags.Clear(Cursed)
g.msg("your armor glows %s for a moment", g.pickColor("silver"))
}
case SHold:
case ScrollHoldMonster:
// Hold monster scroll. Stop all monsters within two spaces from
// chasing after the hero.
held := 0
@@ -58,9 +58,9 @@ func (g *RogueGame) readScroll() {
if y < 0 || y > NumLines-1 {
continue
}
if mp := g.Level.MonsterAt(y, x); mp != nil && mp.On(IsRun) {
mp.Flags.Clear(IsRun)
mp.Flags.Set(IsHeld)
if mp := g.Level.MonsterAt(y, x); mp != nil && mp.On(Awake) {
mp.Flags.Clear(Awake)
mp.Flags.Set(Held)
held++
}
}
@@ -75,17 +75,17 @@ func (g *RogueGame) readScroll() {
g.addmsg("s")
}
g.endmsg()
g.Items.Scrolls[SHold].Know = true
g.Items.Scrolls[ScrollHoldMonster].Know = true
} else {
g.msg("you feel a strange sense of loss")
}
case SSleep:
case ScrollSleep:
// Scroll which makes you fall asleep
g.Items.Scrolls[SSleep].Know = true
g.Items.Scrolls[ScrollSleep].Know = true
g.NoCommand += g.rnd(g.spread(5)) + 4 // SLEEPTIME
p.Flags.Clear(IsRun)
p.Flags.Clear(Awake)
g.msg("you fall asleep")
case SCreate:
case ScrollCreateMonster:
// Create a monster: first look in a circle around him, next try
// his room, otherwise give up
i := 0
@@ -99,7 +99,7 @@ func (g *RogueGame) readScroll() {
// Or anything else nasty
if ch := g.Level.VisibleChar(y, x); stepOk(ch) {
if ch == Scroll {
if fo := g.findObj(y, x); fo != nil && fo.Which == SScare {
if fo := g.findObj(y, x); fo != nil && fo.Which == ScrollScareMonster {
continue
}
}
@@ -115,14 +115,14 @@ func (g *RogueGame) readScroll() {
tp := &Monster{}
g.newMonster(tp, g.randMonster(false), mp)
}
case SIDPotion, SIDScroll, SIDWeapon, SIDArmor, SIDRorS:
case ScrollIdentifyPotion, ScrollIdentifyScroll, ScrollIdentifyWeapon, ScrollIdentifyArmor, ScrollIdentifyRingOrStick:
// Identify, let him figure something out
g.Items.Scrolls[obj.Which].Know = true
g.msg("this scroll is an %s scroll", g.Items.Scrolls[obj.Which].Name)
g.whatis(true, idType[obj.Which])
case SMap:
case ScrollMagicMapping:
// Scroll of magic mapping.
g.Items.Scrolls[SMap].Know = true
g.Items.Scrolls[ScrollMagicMapping].Know = true
g.msg("oh, now this scroll has a map on it")
// take all the things we want to keep hidden out of the window
for y := 1; y < NumLines-1; y++ {
@@ -141,7 +141,7 @@ func (g *RogueGame) readScroll() {
case ' ':
if pp.Flags.Has(FReal) {
// def: hidden things in walls stay hidden
if pp.Flags.Has(FPass) {
if pp.Flags.Has(FPassage) {
pass = true
} else {
ch = ' '
@@ -162,7 +162,7 @@ func (g *RogueGame) readScroll() {
pp.Flags.Set(FSeen | FReal)
}
default:
if pp.Flags.Has(FPass) {
if pp.Flags.Has(FPassage) {
pass = true
} else {
ch = ' '
@@ -178,7 +178,7 @@ func (g *RogueGame) readScroll() {
if ch != ' ' {
if tp := pp.Monst; tp != nil {
tp.OldCh = ch
if !p.On(SeeMonst) {
if !p.On(SenseMonsters) {
g.mvaddch(y, x, ch)
}
} else {
@@ -187,7 +187,7 @@ func (g *RogueGame) readScroll() {
}
}
}
case SFDet:
case ScrollFoodDetection:
// Food detection
found := false
g.scr.Hw.Clear()
@@ -198,23 +198,23 @@ func (g *RogueGame) readScroll() {
}
}
if found {
g.Items.Scrolls[SFDet].Know = true
g.Items.Scrolls[ScrollFoodDetection].Know = true
g.showWin("Your nose tingles and you smell food.--More--")
} else {
g.msg("your nose tingles")
}
case STelep:
case ScrollTeleportation:
// Scroll of teleportation: make him disappear and reappear
curRoom := p.Room
g.teleport()
if curRoom != p.Room {
g.Items.Scrolls[STelep].Know = true
g.Items.Scrolls[ScrollTeleportation].Know = true
}
case SEnch:
case ScrollEnchantWeapon:
if p.CurWeapon == nil || p.CurWeapon.Type != Weapon {
g.msg("you feel a strange sense of loss")
} else {
p.CurWeapon.Flags.Clear(IsCursed)
p.CurWeapon.Flags.Clear(Cursed)
if g.rnd(2) == 0 {
p.CurWeapon.HPlus++
} else {
@@ -223,25 +223,25 @@ func (g *RogueGame) readScroll() {
g.msg("your %s glows %s for a moment",
g.Items.Weapons[p.CurWeapon.Which].Name, g.pickColor("blue"))
}
case SScare:
case ScrollScareMonster:
// Reading it is a mistake and produces laughter at her poor boo
// boo.
g.msg("you hear maniacal laughter in the distance")
case SRemove:
case ScrollRemoveCurse:
uncurse(p.CurArmor)
uncurse(p.CurWeapon)
uncurse(p.CurRing[Left])
uncurse(p.CurRing[Right])
g.msg("%s", g.chooseStr("you feel in touch with the Universal Onenes",
"you feel as if somebody is watching over you"))
case SAggr:
case ScrollAggravateMonsters:
// This scroll aggravates all the monsters on the current level
// and sets them running towards the hero
g.aggravate()
g.msg("you hear a high pitched humming noise")
case SProtect:
case ScrollProtectArmor:
if p.CurArmor != nil {
p.CurArmor.Flags.Set(IsProt)
p.CurArmor.Flags.Set(Protected)
g.msg("your armor is covered by a shimmering %s shield",
g.pickColor("gold"))
} else {
@@ -257,6 +257,6 @@ func (g *RogueGame) readScroll() {
// uncurse uncurses an item (scrolls.c uncurse).
func uncurse(obj *Object) {
if obj != nil {
obj.Flags.Clear(IsCursed)
obj.Flags.Clear(Cursed)
}
}

View File

@@ -21,13 +21,13 @@ func (g *RogueGame) doZap() {
return
}
switch obj.Which {
case WsLight:
case WandLight:
// Reddy Kilowatt wand. Light up the room
g.Items.Sticks[WsLight].Know = true
if p.Room.Flags.Has(IsGone) {
g.Items.Sticks[WandLight].Know = true
if p.Room.Flags.Has(Gone) {
g.msg("the corridor glows and then fades")
} else {
p.Room.Flags.Clear(IsDark)
p.Room.Flags.Clear(Dark)
// Light the room and put the player back up
g.enterRoom(p.Pos)
g.addmsg("the room is lit")
@@ -36,7 +36,7 @@ func (g *RogueGame) doZap() {
}
g.endmsg()
}
case WsDrain:
case WandDrainLife:
// take away 1/2 of hero's hit points, then take it away evenly
// from the monsters in the room (or next to hero if he is in a
// passage)
@@ -45,7 +45,7 @@ func (g *RogueGame) doZap() {
return
}
g.drain()
case WsInvis, WsPolymorph, WsTelAway, WsTelTo, WsCancel:
case WandInvisibility, WandPolymorph, WandTeleportAway, WandTeleportTo, WandCancellation:
y := p.Pos.Y
x := p.Pos.X
for stepOk(g.Level.VisibleChar(y, x)) {
@@ -55,15 +55,15 @@ func (g *RogueGame) doZap() {
if tp := g.Level.MonsterAt(y, x); tp != nil {
monster := tp.Type
if monster == 'F' {
p.Flags.Clear(IsHeld)
p.Flags.Clear(Held)
}
switch obj.Which {
case WsInvis:
tp.Flags.Set(IsInvis)
case WandInvisibility:
tp.Flags.Set(Invisible)
if g.cansee(y, x) {
g.mvaddch(y, x, tp.OldCh)
}
case WsPolymorph:
case WandPolymorph:
pp := tp.Pack
detachMon(&g.Level.Monsters, tp)
if g.seeMonst(tp) {
@@ -80,18 +80,18 @@ func (g *RogueGame) doZap() {
tp.OldCh = oldch
tp.Pack = pp
if g.seeMonst(tp) {
g.Items.Sticks[WsPolymorph].Know = true
g.Items.Sticks[WandPolymorph].Know = true
}
case WsCancel:
tp.Flags.Set(IsCanc)
tp.Flags.Clear(IsInvis | CanHuh)
case WandCancellation:
tp.Flags.Set(Cancelled)
tp.Flags.Clear(Invisible | CanConfuse)
tp.Disguise = tp.Type
if g.seeMonst(tp) {
g.mvaddch(y, x, tp.Disguise)
}
case WsTelAway, WsTelTo:
case WandTeleportAway, WandTeleportTo:
var newPos Coord
if obj.Which == WsTelAway {
if obj.Which == WandTeleportAway {
for {
newPos, _ = g.findFloor(nil, 0, true)
if newPos != p.Pos {
@@ -103,18 +103,18 @@ func (g *RogueGame) doZap() {
newPos.X = p.Pos.X + g.Delta.X
}
tp.Dest = &p.Pos
tp.Flags.Set(IsRun)
tp.Flags.Set(Awake)
g.relocate(tp, newPos)
}
}
case WsMissile:
g.Items.Sticks[WsMissile].Know = true
case WandMagicMissile:
g.Items.Sticks[WandMagicMissile].Know = true
bolt := newObject()
bolt.Type = '*'
bolt.HurlDmg = "1x4"
bolt.HPlus = 100
bolt.DPlus = 1
bolt.Flags = IsMissl
bolt.Flags = Missile
if p.CurWeapon != nil {
bolt.Launch = p.CurWeapon.Which
}
@@ -127,7 +127,7 @@ func (g *RogueGame) doZap() {
} else {
g.msg("the missle vanishes with a puff of smoke")
}
case WsHasteM, WsSlowM:
case WandHasteMonster, WandSlowMonster:
y := p.Pos.Y
x := p.Pos.X
for stepOk(g.Level.VisibleChar(y, x)) {
@@ -135,17 +135,17 @@ func (g *RogueGame) doZap() {
x += g.Delta.X
}
if tp := g.Level.MonsterAt(y, x); tp != nil {
if obj.Which == WsHasteM {
if tp.On(IsSlow) {
tp.Flags.Clear(IsSlow)
if obj.Which == WandHasteMonster {
if tp.On(Slowed) {
tp.Flags.Clear(Slowed)
} else {
tp.Flags.Set(IsHaste)
tp.Flags.Set(Hasted)
}
} else {
if tp.On(IsHaste) {
tp.Flags.Clear(IsHaste)
if tp.On(Hasted) {
tp.Flags.Clear(Hasted)
} else {
tp.Flags.Set(IsSlow)
tp.Flags.Set(Slowed)
}
tp.Turn = true
}
@@ -153,19 +153,19 @@ func (g *RogueGame) doZap() {
g.Delta.X = x
g.runto(g.Delta)
}
case WsElect, WsFire, WsCold:
case WandLightning, WandFire, WandCold:
var name string
switch obj.Which {
case WsElect:
case WandLightning:
name = "bolt"
case WsFire:
case WandFire:
name = "flame"
default:
name = "ice"
}
g.fireBolt(p.Pos, &g.Delta, name)
g.Items.Sticks[obj.Which].Know = true
case WsNop:
case WandNothing:
}
obj.SetCharges(obj.Charges() - 1)
}
@@ -176,14 +176,14 @@ func (g *RogueGame) drain() {
// First count how many things we need to spread the hit points among
var corp *Room
if g.Level.Char(p.Pos.Y, p.Pos.X) == Door {
corp = &g.Level.Passages[*g.Level.FlagsAt(p.Pos.Y, p.Pos.X)&FPNum]
corp = &g.Level.Passages[*g.Level.FlagsAt(p.Pos.Y, p.Pos.X)&FPassNum]
}
inpass := p.Room.Flags.Has(IsGone)
inpass := p.Room.Flags.Has(Gone)
var drainee []*Monster
for _, mp := range g.Level.Monsters {
if mp.Room == p.Room || mp.Room == corp ||
(inpass && g.Level.Char(mp.Pos.Y, mp.Pos.X) == Door &&
&g.Level.Passages[*g.Level.FlagsAt(mp.Pos.Y, mp.Pos.X)&FPNum] == p.Room) {
&g.Level.Passages[*g.Level.FlagsAt(mp.Pos.Y, mp.Pos.X)&FPassNum] == p.Room) {
drainee = append(drainee, mp)
}
}
@@ -212,11 +212,11 @@ func (g *RogueGame) fireBolt(start Coord, dir *Coord, name string) {
bolt := newObject()
bolt.Type = Weapon
bolt.Which = Flame
bolt.Which = WeaponFlame
bolt.HurlDmg = "6x6"
bolt.HPlus = 100
bolt.DPlus = 0
g.Items.Weapons[Flame].Name = name
g.Items.Weapons[WeaponFlame].Name = name
var dirch byte
switch dir.Y + dir.X {
case 0:
@@ -329,7 +329,7 @@ func (g *RogueGame) fixStick(cur *Object) {
cur.HurlDmg = "1x1"
switch cur.Which {
case WsLight:
case WandLight:
cur.SetCharges(g.rnd(10) + 10)
default:
cur.SetCharges(g.rnd(5) + 3)
@@ -339,7 +339,7 @@ func (g *RogueGame) fixStick(cur *Object) {
// chargeStr returns the charge-count suffix for an identified stick
// (sticks.c charge_str).
func chargeStr(g *RogueGame, obj *Object) string {
if !obj.Flags.Has(IsKnow) {
if !obj.Flags.Has(Known) {
return ""
}
if g.Options.Terse {

View File

@@ -9,7 +9,7 @@ package game
var initStats = Stats{Str: 16, Exp: 0, Lvl: 1, Arm: 10, HP: 12, Dmg: "1x4", MaxHP: 12}
// aClass is extern.c a_class[]: armor class for each armor type.
var aClass = [MaxArmors]int{
var aClass = [NumArmorTypes]int{
8, // LEATHER
7, // RING_MAIL
7, // STUDDED_LEATHER
@@ -28,7 +28,7 @@ var eLevels = []int{
}
// trName is extern.c tr_name[]: names of the traps.
var trName = [NTraps]string{
var trName = [NumTrapTypes]string{
"a trapdoor",
"an arrow trap",
"a sleeping gas trap",
@@ -47,32 +47,32 @@ var invTName = []string{"Overwrite", "Slow", "Clear"}
// rolled from the level at creation time.
var monsterTable = [26]MonsterKind{
/* Name CARRY FLAGS str exp lvl arm hp dmg */
{"aquator", 0, IsMean, Stats{10, 20, 5, 2, 1, "0x0/0x0", 0}},
{"bat", 0, IsFly, Stats{10, 1, 1, 3, 1, "1x2", 0}},
{"aquator", 0, Mean, Stats{10, 20, 5, 2, 1, "0x0/0x0", 0}},
{"bat", 0, Flying, Stats{10, 1, 1, 3, 1, "1x2", 0}},
{"centaur", 15, 0, Stats{10, 17, 4, 4, 1, "1x2/1x5/1x5", 0}},
{"dragon", 100, IsMean, Stats{10, 5000, 10, -1, 1, "1x8/1x8/3x10", 0}},
{"emu", 0, IsMean, Stats{10, 2, 1, 7, 1, "1x2", 0}},
{"venus flytrap", 0, IsMean, Stats{10, 80, 8, 3, 1, "%%%x0", 0}},
{"griffin", 20, IsMean | IsFly | IsRegen, Stats{10, 2000, 13, 2, 1, "4x3/3x5", 0}},
{"hobgoblin", 0, IsMean, Stats{10, 3, 1, 5, 1, "1x8", 0}},
{"dragon", 100, Mean, Stats{10, 5000, 10, -1, 1, "1x8/1x8/3x10", 0}},
{"emu", 0, Mean, Stats{10, 2, 1, 7, 1, "1x2", 0}},
{"venus flytrap", 0, Mean, Stats{10, 80, 8, 3, 1, "%%%x0", 0}},
{"griffin", 20, Mean | Flying | Regenerates, Stats{10, 2000, 13, 2, 1, "4x3/3x5", 0}},
{"hobgoblin", 0, Mean, Stats{10, 3, 1, 5, 1, "1x8", 0}},
{"ice monster", 0, 0, Stats{10, 5, 1, 9, 1, "0x0", 0}},
{"jabberwock", 70, 0, Stats{10, 3000, 15, 6, 1, "2x12/2x4", 0}},
{"kestrel", 0, IsMean | IsFly, Stats{10, 1, 1, 7, 1, "1x4", 0}},
{"kestrel", 0, Mean | Flying, Stats{10, 1, 1, 7, 1, "1x4", 0}},
{"leprechaun", 0, 0, Stats{10, 10, 3, 8, 1, "1x1", 0}},
{"medusa", 40, IsMean, Stats{10, 200, 8, 2, 1, "3x4/3x4/2x5", 0}},
{"medusa", 40, Mean, Stats{10, 200, 8, 2, 1, "3x4/3x4/2x5", 0}},
{"nymph", 100, 0, Stats{10, 37, 3, 9, 1, "0x0", 0}},
{"orc", 15, IsGreed, Stats{10, 5, 1, 6, 1, "1x8", 0}},
{"phantom", 0, IsInvis, Stats{10, 120, 8, 3, 1, "4x4", 0}},
{"quagga", 0, IsMean, Stats{10, 15, 3, 3, 1, "1x5/1x5", 0}},
{"rattlesnake", 0, IsMean, Stats{10, 9, 2, 3, 1, "1x6", 0}},
{"snake", 0, IsMean, Stats{10, 2, 1, 5, 1, "1x3", 0}},
{"troll", 50, IsRegen | IsMean, Stats{10, 120, 6, 4, 1, "1x8/1x8/2x6", 0}},
{"black unicorn", 0, IsMean, Stats{10, 190, 7, -2, 1, "1x9/1x9/2x9", 0}},
{"vampire", 20, IsRegen | IsMean, Stats{10, 350, 8, 1, 1, "1x10", 0}},
{"orc", 15, Greedy, Stats{10, 5, 1, 6, 1, "1x8", 0}},
{"phantom", 0, Invisible, Stats{10, 120, 8, 3, 1, "4x4", 0}},
{"quagga", 0, Mean, Stats{10, 15, 3, 3, 1, "1x5/1x5", 0}},
{"rattlesnake", 0, Mean, Stats{10, 9, 2, 3, 1, "1x6", 0}},
{"snake", 0, Mean, Stats{10, 2, 1, 5, 1, "1x3", 0}},
{"troll", 50, Regenerates | Mean, Stats{10, 120, 6, 4, 1, "1x8/1x8/2x6", 0}},
{"black unicorn", 0, Mean, Stats{10, 190, 7, -2, 1, "1x9/1x9/2x9", 0}},
{"vampire", 20, Regenerates | Mean, Stats{10, 350, 8, 1, 1, "1x10", 0}},
{"wraith", 0, 0, Stats{10, 55, 5, 4, 1, "1x6", 0}},
{"xeroc", 30, 0, Stats{10, 100, 7, 7, 1, "4x4", 0}},
{"yeti", 30, 0, Stats{10, 50, 4, 6, 1, "1x6/1x6", 0}},
{"zombie", 0, IsMean, Stats{10, 6, 2, 8, 1, "1x8", 0}},
{"zombie", 0, Mean, Stats{10, 6, 2, 8, 1, "1x8", 0}},
}
// Base ObjInfo tables (extern.c). These are templates: NewGame copies them
@@ -88,7 +88,7 @@ var baseThings = [NumThings]ObjInfo{
{Prob: 4}, // stick
}
var baseArmInfo = [MaxArmors]ObjInfo{
var baseArmInfo = [NumArmorTypes]ObjInfo{
{Name: "leather armor", Prob: 20, Worth: 20},
{Name: "ring mail", Prob: 15, Worth: 25},
{Name: "studded leather armor", Prob: 15, Worth: 20},
@@ -99,7 +99,7 @@ var baseArmInfo = [MaxArmors]ObjInfo{
{Name: "plate mail", Prob: 5, Worth: 150},
}
var basePotInfo = [MaxPotions]ObjInfo{
var basePotInfo = [NumPotionTypes]ObjInfo{
{Name: "confusion", Prob: 7, Worth: 5},
{Name: "hallucination", Prob: 8, Worth: 5},
{Name: "poison", Prob: 8, Worth: 5},
@@ -116,7 +116,7 @@ var basePotInfo = [MaxPotions]ObjInfo{
{Name: "levitation", Prob: 6, Worth: 75},
}
var baseRingInfo = [MaxRings]ObjInfo{
var baseRingInfo = [NumRingTypes]ObjInfo{
{Name: "protection", Prob: 9, Worth: 400},
{Name: "add strength", Prob: 9, Worth: 400},
{Name: "sustain strength", Prob: 5, Worth: 280},
@@ -133,7 +133,7 @@ var baseRingInfo = [MaxRings]ObjInfo{
{Name: "maintain armor", Prob: 5, Worth: 380},
}
var baseScrInfo = [MaxScrolls]ObjInfo{
var baseScrInfo = [NumScrollTypes]ObjInfo{
{Name: "monster confusion", Prob: 7, Worth: 140},
{Name: "magic mapping", Prob: 4, Worth: 150},
{Name: "hold monster", Prob: 2, Worth: 180},
@@ -154,7 +154,7 @@ var baseScrInfo = [MaxScrolls]ObjInfo{
{Name: "protect armor", Prob: 2, Worth: 250},
}
var baseWeapInfo = [MaxWeapons + 1]ObjInfo{
var baseWeapInfo = [NumWeaponTypes + 1]ObjInfo{
{Name: "mace", Prob: 11, Worth: 8},
{Name: "long sword", Prob: 11, Worth: 15},
{Name: "short bow", Prob: 12, Worth: 15},
@@ -167,7 +167,7 @@ var baseWeapInfo = [MaxWeapons + 1]ObjInfo{
{}, // DO NOT REMOVE: fake entry for dragon's breath
}
var baseWsInfo = [MaxSticks]ObjInfo{
var baseWsInfo = [NumWandTypes]ObjInfo{
{Name: "light", Prob: 12, Worth: 250},
{Name: "invisibility", Prob: 6, Worth: 5},
{Name: "lightning", Prob: 3, Worth: 330},

View File

@@ -17,7 +17,7 @@ func TestProbabilitiesSumTo100(t *testing.T) {
"scrolls": baseScrInfo[:],
"rings": baseRingInfo[:],
"sticks": baseWsInfo[:],
"weapons": baseWeapInfo[:MaxWeapons], // excludes the flame entry
"weapons": baseWeapInfo[:NumWeaponTypes], // excludes the flame entry
"armor": baseArmInfo[:],
}
for name, tab := range tables {
@@ -29,11 +29,11 @@ func TestProbabilitiesSumTo100(t *testing.T) {
func TestInitProbsCumulative(t *testing.T) {
g := NewGame(Config{Seed: 1})
last := g.Items.Potions[MaxPotions-1].Prob
last := g.Items.Potions[NumPotionTypes-1].Prob
if last != 100 {
t.Errorf("cumulative potion probability ends at %d, want 100", last)
}
for i := 1; i < MaxPotions; i++ {
for i := 1; i < NumPotionTypes; i++ {
if g.Items.Potions[i].Prob < g.Items.Potions[i-1].Prob {
t.Errorf("potion probs not nondecreasing at %d", i)
}

View File

@@ -55,7 +55,7 @@ func (g *RogueGame) invName(obj *Object, drop bool) string {
} else {
fmt.Fprintf(&pb, "A%s ", vowelstr(sp))
}
if obj.Flags.Has(IsKnow) {
if obj.Flags.Has(Known) {
fmt.Fprintf(&pb, "%s %s", num(obj.HPlus, obj.DPlus, Weapon), sp)
} else {
pb.WriteString(sp)
@@ -68,7 +68,7 @@ func (g *RogueGame) invName(obj *Object, drop bool) string {
}
case Armor:
sp := it.Armors[which].Name
if obj.Flags.Has(IsKnow) {
if obj.Flags.Has(Known) {
fmt.Fprintf(&pb, "%s %s [", num(aClass[which]-obj.Arm, 0, Armor), sp)
if !g.Options.Terse {
pb.WriteString("protection ")
@@ -151,7 +151,7 @@ func (g *RogueGame) dropCheck(obj *Object) bool {
obj != p.CurRing[Left] && obj != p.CurRing[Right] {
return true
}
if obj.Flags.Has(IsCursed) {
if obj.Flags.Has(Cursed) {
g.msg("you can't. It appears to be cursed")
return false
}
@@ -167,9 +167,9 @@ func (g *RogueGame) dropCheck(obj *Object) bool {
}
p.CurRing[hand] = nil
switch obj.Which {
case RAddStr:
case RingAddStrength:
g.chgStr(-obj.Arm)
case RSeeInvis:
case RingSeeInvisible:
g.unsee(0)
g.Extinguish(DUnsee)
}
@@ -209,9 +209,9 @@ func (g *RogueGame) newThing() *Object {
cur.Which = 1
}
case 3:
g.initWeapon(cur, pickOne(g, g.Items.Weapons[:MaxWeapons]))
g.initWeapon(cur, pickOne(g, g.Items.Weapons[:NumWeaponTypes]))
if r := g.rnd(100); r < 10 {
cur.Flags.Set(IsCursed)
cur.Flags.Set(Cursed)
cur.HPlus -= g.rnd(3) + 1
} else if r < 15 {
cur.HPlus += g.rnd(3) + 1
@@ -221,7 +221,7 @@ func (g *RogueGame) newThing() *Object {
cur.Which = pickOne(g, g.Items.Armors[:])
cur.Arm = aClass[cur.Which]
if r := g.rnd(100); r < 20 {
cur.Flags.Set(IsCursed)
cur.Flags.Set(Cursed)
cur.Arm += g.rnd(3) + 1
} else if r < 28 {
cur.Arm -= g.rnd(3) + 1
@@ -230,13 +230,13 @@ func (g *RogueGame) newThing() *Object {
cur.Type = Ring
cur.Which = pickOne(g, g.Items.Rings[:])
switch cur.Which {
case RAddStr, RProtect, RAddHit, RAddDam:
case RingAddStrength, RingProtection, RingDexterity, RingIncreaseDamage:
if cur.Arm = g.rnd(3); cur.Arm == 0 {
cur.Arm = -1
cur.Flags.Set(IsCursed)
cur.Flags.Set(Cursed)
}
case RAggr, RTeleport:
cur.Flags.Set(IsCursed)
case RingAggravateMonsters, RingTeleportation:
cur.Flags.Set(Cursed)
}
case 6:
cur.Type = Stick
@@ -525,7 +525,7 @@ func (g *RogueGame) prList() {
case Armor:
g.prSpec(g.Items.Armors[:])
case Weapon:
g.prSpec(g.Items.Weapons[:MaxWeapons])
g.prSpec(g.Items.Weapons[:NumWeaponTypes])
}
}

View File

@@ -100,9 +100,9 @@ const (
type RoomFlags int16
const (
IsDark RoomFlags = 1 << iota // room is dark
IsGone // room is gone (a corridor)
IsMaze // room is a maze
Dark RoomFlags = 1 << iota // room is dark
Gone // room is gone (a corridor)
Maze // room is a maze
)
func (f RoomFlags) Has(b RoomFlags) bool { return f&b != 0 }
@@ -113,12 +113,12 @@ func (f *RoomFlags) Clear(b RoomFlags) { *f &^= b }
type ObjFlags int32
const (
IsCursed ObjFlags = 1 << iota // object is cursed
IsKnow // player knows details about the object
IsMissl // object is a missile type
IsMany // object comes in groups
ObjIsFound // object has been seen (ISFOUND shares the bit with creatures)
IsProt // armor is permanently protected
Cursed ObjFlags = 1 << iota // ISCURSED: object is cursed
Known // ISKNOW: player knows details about the object
Missile // ISMISL: object is a missile type
Stackable // ISMANY: object comes in groups
WasFound // ISFOUND (objects): object has been seen (ISFOUND shares the bit with creatures)
Protected // ISPROT: armor is permanently protected
)
func (f ObjFlags) Has(b ObjFlags) bool { return f&b != 0 }
@@ -131,25 +131,25 @@ func (f *ObjFlags) Clear(b ObjFlags) { *f &^= b }
type CreatureFlags int32
const (
CanHuh CreatureFlags = 0o000001 // creature can confuse
CanSee CreatureFlags = 0o000002 // creature can see invisible creatures
IsBlind CreatureFlags = 0o000004 // creature is blind
IsCanc CreatureFlags = 0o000010 // creature has special qualities cancelled
IsLevit CreatureFlags = 0o000010 // hero is levitating
IsFound CreatureFlags = 0o000020 // creature has been seen
IsGreed CreatureFlags = 0o000040 // creature runs to protect gold
IsHaste CreatureFlags = 0o000100 // creature has been hastened
IsTarget CreatureFlags = 0o000200 // creature is the target of an 'f' command
IsHeld CreatureFlags = 0o000400 // creature has been held
IsHuh CreatureFlags = 0o001000 // creature is confused
IsInvis CreatureFlags = 0o002000 // creature is invisible
IsMean CreatureFlags = 0o004000 // creature can wake when player enters room
IsHalu CreatureFlags = 0o004000 // hero is on acid trip
IsRegen CreatureFlags = 0o010000 // creature can regenerate
IsRun CreatureFlags = 0o020000 // creature is running at the player
SeeMonst CreatureFlags = 0o040000 // hero can detect unseen monsters
IsFly CreatureFlags = 0o040000 // creature can fly
IsSlow CreatureFlags = 0o100000 // creature has been slowed
CanConfuse CreatureFlags = 0o000001 // CANHUH: creature can confuse
CanSeeInvisible CreatureFlags = 0o000002 // CANSEE: creature can see invisible creatures
Blind CreatureFlags = 0o000004 // ISBLIND: creature is blind
Cancelled CreatureFlags = 0o000010 // ISCANC: creature has special qualities cancelled
Levitating CreatureFlags = 0o000010 // ISLEVIT: hero is levitating
Found CreatureFlags = 0o000020 // ISFOUND: creature has been seen
Greedy CreatureFlags = 0o000040 // ISGREED: creature runs to protect gold
Hasted CreatureFlags = 0o000100 // ISHASTE: creature has been hastened
Targeted CreatureFlags = 0o000200 // ISTARGET: creature is the target of an 'f' command
Held CreatureFlags = 0o000400 // ISHELD: creature has been held
Confused CreatureFlags = 0o001000 // ISHUH: creature is confused
Invisible CreatureFlags = 0o002000 // ISINVIS: creature is invisible
Mean CreatureFlags = 0o004000 // ISMEAN: creature can wake when player enters room
Hallucinating CreatureFlags = 0o004000 // ISHALU: hero is on acid trip
Regenerates CreatureFlags = 0o010000 // ISREGEN: creature can regenerate
Awake CreatureFlags = 0o020000 // ISRUN: creature is running at the player
SenseMonsters CreatureFlags = 0o040000 // SEEMONST: hero can detect unseen monsters
Flying CreatureFlags = 0o040000 // ISFLY: creature can fly
Slowed CreatureFlags = 0o100000 // ISSLOW: creature has been slowed
)
func (f CreatureFlags) Has(b CreatureFlags) bool { return f&b != 0 }
@@ -160,13 +160,13 @@ func (f *CreatureFlags) Clear(b CreatureFlags) { *f &^= b }
type PlaceFlags uint8
const (
FPass PlaceFlags = 0x80 // is a passageway
FSeen PlaceFlags = 0x40 // have seen this spot before
FDropped PlaceFlags = 0x20 // object was dropped here
FLocked PlaceFlags = 0x20 // door is locked
FReal PlaceFlags = 0x10 // what you see is what you get
FPNum PlaceFlags = 0x0f // passage number mask
FTMask PlaceFlags = 0x07 // trap number mask
FPassage PlaceFlags = 0x80 // F_PASS: is a passageway
FSeen PlaceFlags = 0x40 // have seen this spot before
FDropped PlaceFlags = 0x20 // object was dropped here
FLocked PlaceFlags = 0x20 // door is locked
FReal PlaceFlags = 0x10 // what you see is what you get
FPassNum PlaceFlags = 0x0f // F_PNUM: passage number mask
FTrapMask PlaceFlags = 0x07 // F_TMASK: trap number mask
)
func (f PlaceFlags) Has(b PlaceFlags) bool { return f&b != 0 }
@@ -175,123 +175,123 @@ func (f *PlaceFlags) Clear(b PlaceFlags) { *f &^= b }
// Trap types (rogue.h)
const (
TDoor = 0
TArrow = 1
TSleep = 2
TBear = 3
TTelep = 4
TDart = 5
TRust = 6
TMyst = 7
NTraps = 8
TrapDoor = 0
TrapArrow = 1
TrapSleep = 2
TrapBear = 3
TrapTeleport = 4
TrapDart = 5
TrapRust = 6
TrapMystery = 7
NumTrapTypes = 8
)
// Potion types (rogue.h)
const (
PConfuse = iota
PLSD
PPoison
PStrength
PSeeInvis
PHealing
PMFind
PTFind
PRaise
PXHeal
PHaste
PRestore
PBlind
PLevit
MaxPotions
PotionConfusion = iota
PotionLSD
PotionPoison
PotionGainStrength
PotionSeeInvisible
PotionHealing
PotionDetectMonsters
PotionDetectMagic
PotionRaiseLevel
PotionExtraHealing
PotionHaste
PotionRestoreStrength
PotionBlindness
PotionLevitation
NumPotionTypes
)
// Scroll types (rogue.h)
const (
SConfuse = iota
SMap
SHold
SSleep
SArmor
SIDPotion
SIDScroll
SIDWeapon
SIDArmor
SIDRorS
SScare
SFDet
STelep
SEnch
SCreate
SRemove
SAggr
SProtect
MaxScrolls
ScrollMonsterConfusion = iota
ScrollMagicMapping
ScrollHoldMonster
ScrollSleep
ScrollEnchantArmor
ScrollIdentifyPotion
ScrollIdentifyScroll
ScrollIdentifyWeapon
ScrollIdentifyArmor
ScrollIdentifyRingOrStick
ScrollScareMonster
ScrollFoodDetection
ScrollTeleportation
ScrollEnchantWeapon
ScrollCreateMonster
ScrollRemoveCurse
ScrollAggravateMonsters
ScrollProtectArmor
NumScrollTypes
)
// Weapon types (rogue.h)
const (
Mace = iota
Sword
Bow
Arrow
Dagger
TwoSword
Dart
Shiraken
Spear
Flame // fake entry for dragon breath (ick)
MaxWeapons = Flame
WeaponMace = iota
WeaponLongSword
WeaponBow
WeaponArrow
WeaponDagger
WeaponTwoHandedSword
WeaponDart
WeaponShuriken
WeaponSpear
WeaponFlame // fake entry for dragon breath (ick)
NumWeaponTypes = WeaponFlame
)
// Armor types (rogue.h)
const (
Leather = iota
RingMail
StuddedLeather
ScaleMail
ChainMail
SplintMail
BandedMail
PlateMail
MaxArmors
ArmorLeather = iota
ArmorRingMail
ArmorStuddedLeather
ArmorScaleMail
ArmorChainMail
ArmorSplintMail
ArmorBandedMail
ArmorPlateMail
NumArmorTypes
)
// Ring types (rogue.h)
const (
RProtect = iota
RAddStr
RSustStr
RSearch
RSeeInvis
RNop
RAggr
RAddHit
RAddDam
RRegen
RDigest
RTeleport
RStealth
RSustArm
MaxRings
RingProtection = iota
RingAddStrength
RingSustainStrength
RingSearching
RingSeeInvisible
RingAdornment
RingAggravateMonsters
RingDexterity
RingIncreaseDamage
RingRegeneration
RingSlowDigestion
RingTeleportation
RingStealth
RingMaintainArmor
NumRingTypes
)
// Rod/Wand/Staff types (rogue.h)
const (
WsLight = iota
WsInvis
WsElect
WsFire
WsCold
WsPolymorph
WsMissile
WsHasteM
WsSlowM
WsDrain
WsNop
WsTelAway
WsTelTo
WsCancel
MaxSticks
WandLight = iota
WandInvisibility
WandLightning
WandFire
WandCold
WandPolymorph
WandMagicMissile
WandHasteMonster
WandSlowMonster
WandDrainLife
WandNothing
WandTeleportAway
WandTeleportTo
WandCancellation
NumWandTypes
)
// Coord is a position on the level (rogue.h coord). A value type: the C

View File

@@ -122,21 +122,21 @@ func (g *RogueGame) wield() {
}
// initWeaps is the weapons.c init_dam[] table.
var initWeaps = [MaxWeapons]struct {
var initWeaps = [NumWeaponTypes]struct {
dam string // damage when wielded
hrl string // damage when thrown
launch int // launching weapon
flags ObjFlags
}{
{"2x4", "1x3", noWeapon, 0}, // Mace
{"3x4", "1x2", noWeapon, 0}, // Long sword
{"1x1", "1x1", noWeapon, 0}, // Bow
{"1x1", "2x3", Bow, IsMany | IsMissl}, // Arrow
{"1x6", "1x4", noWeapon, IsMissl}, // Dagger
{"4x4", "1x2", noWeapon, 0}, // 2h sword
{"1x1", "1x3", noWeapon, IsMany | IsMissl}, // Dart
{"1x2", "2x4", noWeapon, IsMany | IsMissl}, // Shuriken
{"2x3", "1x6", noWeapon, IsMissl}, // Spear
{"2x4", "1x3", noWeapon, 0}, // WeaponMace
{"3x4", "1x2", noWeapon, 0}, // Long sword
{"1x1", "1x1", noWeapon, 0}, // WeaponBow
{"1x1", "2x3", WeaponBow, Stackable | Missile}, // WeaponArrow
{"1x6", "1x4", noWeapon, Missile}, // WeaponDagger
{"4x4", "1x2", noWeapon, 0}, // 2h sword
{"1x1", "1x3", noWeapon, Stackable | Missile}, // WeaponDart
{"1x2", "2x4", noWeapon, Stackable | Missile}, // Shuriken
{"2x3", "1x6", noWeapon, Missile}, // WeaponSpear
}
// initWeapon sets up a new weapon (weapons.c init_weapon).
@@ -150,11 +150,11 @@ func (g *RogueGame) initWeapon(weap *Object, which int) {
weap.Flags = iwp.flags
weap.HPlus = 0
weap.DPlus = 0
if which == Dagger {
if which == WeaponDagger {
weap.Count = g.rnd(4) + 2
weap.Group = g.Items.Group
g.Items.Group++
} else if weap.Flags.Has(IsMany) {
} else if weap.Flags.Has(Stackable) {
weap.Count = g.rnd(8) + 8
weap.Group = g.Items.Group
g.Items.Group++

View File

@@ -27,7 +27,7 @@ func (g *RogueGame) createObj() {
bless := g.readchar()
g.Msgs.Mpos = 0
if bless == '-' {
obj.Flags.Set(IsCursed)
obj.Flags.Set(Cursed)
}
if obj.Type == Weapon {
g.initWeapon(obj, obj.Which)
@@ -48,18 +48,18 @@ func (g *RogueGame) createObj() {
}
case obj.Type == Ring:
switch obj.Which {
case RProtect, RAddStr, RAddHit, RAddDam:
case RingProtection, RingAddStrength, RingDexterity, RingIncreaseDamage:
g.msg("blessing? (+,-,n)")
bless := g.readchar()
g.Msgs.Mpos = 0
if bless == '-' {
obj.Flags.Set(IsCursed)
obj.Flags.Set(Cursed)
obj.Arm = -1
} else {
obj.Arm = g.rnd(2) + 1
}
case RAggr, RTeleport:
obj.Flags.Set(IsCursed)
case RingAggravateMonsters, RingTeleportation:
obj.Flags.Set(Cursed)
}
case obj.Type == Stick:
g.fixStick(obj)
@@ -131,7 +131,7 @@ func (g *RogueGame) whatis(insist bool, typ int) {
case Stick:
setKnow(obj, g.Items.Sticks[:])
case Weapon, Armor:
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
case Ring:
setKnow(obj, g.Items.Rings[:])
}
@@ -142,7 +142,7 @@ func (g *RogueGame) whatis(insist bool, typ int) {
// set_know).
func setKnow(obj *Object, info []ObjInfo) {
info[obj.Which].Know = true
obj.Flags.Set(IsKnow)
obj.Flags.Set(Known)
info[obj.Which].Guess = ""
}
@@ -187,8 +187,8 @@ func (g *RogueGame) teleport() {
g.mvaddch(p.Pos.Y, p.Pos.X, PlayerCh)
// turn off ISHELD in case teleportation was done while fighting a
// Flytrap
if p.On(IsHeld) {
p.Flags.Clear(IsHeld)
if p.On(Held) {
p.Flags.Clear(Held)
p.VfHit = 0
g.Monsters['F'-'A'].Stats.Dmg = "000x0"
}