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:
102
game/potions.go
102
game/potions.go
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user