package game // potions.c — the visibility-related helpers arrive first; quaff and the // potion effect dispatch come with the effects phase. // isMagic reports whether an object radiates magic (potions.c is_magic). func (o *Object) isMagic() bool { switch o.Type { case Armor: return o.Flags.Has(IsProt) || o.Arm != aClass[o.Which] case Weapon: return o.HPlus != 0 || o.DPlus != 0 case Potion, Scroll, Stick, Ring, Amulet: return true } return false } // invisOn turns on the ability to see invisible monsters (potions.c // invis_on). func (g *RogueGame) invisOn() { g.Player.Flags.Set(CanSee) for _, mp := range g.Level.Monsters { if mp.On(IsInvis) && g.seeMonst(mp) && !g.Player.On(IsHalu) { g.mvaddch(mp.Pos.Y, mp.Pos.X, mp.Disguise) } } } // turnSee puts on or off seeing monsters on this level (potions.c // turn_see). func (g *RogueGame) turnSee(turnOff bool) bool { addNew := false for _, mp := range g.Level.Monsters { g.move(mp.Pos.Y, mp.Pos.X) canSee := g.seeMonst(mp) if turnOff { if !canSee { g.addch(mp.OldCh) } } else { if !canSee { g.standout() } if !g.Player.On(IsHalu) { g.addch(mp.Type) } else { g.addch(byte(g.rnd(26) + 'A')) } if !canSee { g.standend() addNew = true } } } if turnOff { g.Player.Flags.Clear(SeeMonst) } else { g.Player.Flags.Set(SeeMonst) } return addNew } // seenStairs reports whether the player has seen the stairs (potions.c // seen_stairs). func (g *RogueGame) seenStairs() bool { st := g.Level.Stairs g.move(st.Y, st.X) if g.inch() == Stairs { // it's on the map return true } if g.Player.Pos == st { // it's under him return true } // 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: return true // it must have moved there } if g.Player.On(SeeMonst) && tp.OldCh == Stairs { return true } } return false }