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.
200 lines
4.3 KiB
Go
200 lines
4.3 KiB
Go
package game
|
|
|
|
// wizard.c — special wizard commands, some of which are also non-wizard
|
|
// commands under strange circumstances. The DES password check is not
|
|
// ported: wizard mode is enabled by configuration instead.
|
|
|
|
// createObj is the wizard command for getting anything he wants (wizard.c
|
|
// create_obj).
|
|
func (g *RogueGame) createObj() {
|
|
obj := newObject()
|
|
g.msg("type of item: ")
|
|
obj.Type = g.readchar()
|
|
g.Msgs.Mpos = 0
|
|
g.msg("which %c do you want? (0-f)", obj.Type)
|
|
ch := g.readchar()
|
|
if isDigit(ch) {
|
|
obj.Which = int(ch - '0')
|
|
} else {
|
|
obj.Which = int(ch-'a') + 10
|
|
}
|
|
obj.Group = 0
|
|
obj.Count = 1
|
|
g.Msgs.Mpos = 0
|
|
switch {
|
|
case obj.Type == Weapon || obj.Type == Armor:
|
|
g.msg("blessing? (+,-,n)")
|
|
bless := g.readchar()
|
|
g.Msgs.Mpos = 0
|
|
if bless == '-' {
|
|
obj.Flags.Set(Cursed)
|
|
}
|
|
if obj.Type == Weapon {
|
|
g.initWeapon(obj, obj.Which)
|
|
if bless == '-' {
|
|
obj.HPlus -= g.rnd(3) + 1
|
|
}
|
|
if bless == '+' {
|
|
obj.HPlus += g.rnd(3) + 1
|
|
}
|
|
} else {
|
|
obj.Arm = aClass[obj.Which]
|
|
if bless == '-' {
|
|
obj.Arm += g.rnd(3) + 1
|
|
}
|
|
if bless == '+' {
|
|
obj.Arm -= g.rnd(3) + 1
|
|
}
|
|
}
|
|
case obj.Type == Ring:
|
|
switch obj.Which {
|
|
case RingProtection, RingAddStrength, RingDexterity, RingIncreaseDamage:
|
|
g.msg("blessing? (+,-,n)")
|
|
bless := g.readchar()
|
|
g.Msgs.Mpos = 0
|
|
if bless == '-' {
|
|
obj.Flags.Set(Cursed)
|
|
obj.Arm = -1
|
|
} else {
|
|
obj.Arm = g.rnd(2) + 1
|
|
}
|
|
case RingAggravateMonsters, RingTeleportation:
|
|
obj.Flags.Set(Cursed)
|
|
}
|
|
case obj.Type == Stick:
|
|
g.fixStick(obj)
|
|
case obj.Type == Gold:
|
|
g.msg("how much?")
|
|
buf := ""
|
|
if g.getStr(&buf, g.scr.Std) == Norm {
|
|
obj.SetGoldVal(cAtoi(buf))
|
|
}
|
|
}
|
|
g.addPack(obj, false)
|
|
}
|
|
|
|
// showMap prints out the whole map for the wizard (wizard.c show_map).
|
|
func (g *RogueGame) showMap() {
|
|
hw := g.scr.Hw
|
|
hw.Clear()
|
|
for y := 1; y < NumLines-1; y++ {
|
|
for x := 0; x < NumCols; x++ {
|
|
real := g.Level.FlagsAt(y, x).Has(FReal)
|
|
if !real {
|
|
hw.Standout(true)
|
|
}
|
|
hw.MvAddCh(y, x, g.Level.Char(y, x))
|
|
if !real {
|
|
hw.Standout(false)
|
|
}
|
|
}
|
|
}
|
|
g.showWin("---More (level map)---")
|
|
}
|
|
|
|
// whatis identifies what a certain object is (wizard.c whatis).
|
|
func (g *RogueGame) whatis(insist bool, typ int) {
|
|
p := &g.Player
|
|
if len(p.Pack) == 0 {
|
|
g.msg("you don't have anything in your pack to identify")
|
|
return
|
|
}
|
|
|
|
var obj *Object
|
|
for {
|
|
obj = g.getItem("identify", typ)
|
|
if !insist {
|
|
break
|
|
}
|
|
if g.NObjs == 0 {
|
|
return
|
|
}
|
|
if obj == nil {
|
|
g.msg("you must identify something")
|
|
} else if typ != 0 && int(obj.Type) != typ &&
|
|
!(typ == RorS && (obj.Type == Ring || obj.Type == Stick)) {
|
|
g.msg("you must identify a %s", typeName(typ))
|
|
} else {
|
|
break
|
|
}
|
|
}
|
|
|
|
if obj == nil {
|
|
return
|
|
}
|
|
|
|
switch obj.Type {
|
|
case Scroll:
|
|
setKnow(obj, g.Items.Scrolls[:])
|
|
case Potion:
|
|
setKnow(obj, g.Items.Potions[:])
|
|
case Stick:
|
|
setKnow(obj, g.Items.Sticks[:])
|
|
case Weapon, Armor:
|
|
obj.Flags.Set(Known)
|
|
case Ring:
|
|
setKnow(obj, g.Items.Rings[:])
|
|
}
|
|
g.msg("%s", g.invName(obj, false))
|
|
}
|
|
|
|
// setKnow sets things up when we really know what a thing is (wizard.c
|
|
// set_know).
|
|
func setKnow(obj *Object, info []ObjInfo) {
|
|
info[obj.Which].Know = true
|
|
obj.Flags.Set(Known)
|
|
info[obj.Which].Guess = ""
|
|
}
|
|
|
|
// typeNameTable is the wizard.c type_name static tlist.
|
|
var typeNameTable = []struct {
|
|
ch int
|
|
desc string
|
|
}{
|
|
{int(Potion), "potion"},
|
|
{int(Scroll), "scroll"},
|
|
{int(Food), "food"},
|
|
{RorS, "ring, wand or staff"},
|
|
{int(Ring), "ring"},
|
|
{int(Stick), "wand or staff"},
|
|
{int(Weapon), "weapon"},
|
|
{int(Armor), "suit of armor"},
|
|
}
|
|
|
|
// typeName returns the name of an object type (wizard.c type_name).
|
|
func typeName(typ int) string {
|
|
for _, hp := range typeNameTable {
|
|
if typ == hp.ch {
|
|
return hp.desc
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// teleport bamfs the hero someplace else (wizard.c teleport).
|
|
func (g *RogueGame) teleport() {
|
|
p := &g.Player
|
|
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorAt())
|
|
c, _ := g.findFloor(nil, 0, true)
|
|
if g.roomin(c) != p.Room {
|
|
g.leaveRoom(p.Pos)
|
|
p.Pos = c
|
|
g.enterRoom(p.Pos)
|
|
} else {
|
|
p.Pos = c
|
|
g.look(true)
|
|
}
|
|
g.mvaddch(p.Pos.Y, p.Pos.X, PlayerCh)
|
|
// turn off ISHELD in case teleportation was done while fighting a
|
|
// Flytrap
|
|
if p.On(Held) {
|
|
p.Flags.Clear(Held)
|
|
p.VfHit = 0
|
|
g.Monsters['F'-'A'].Stats.Dmg = "000x0"
|
|
}
|
|
g.NoMove = 0
|
|
g.Count = 0
|
|
g.Running = false
|
|
g.flushType()
|
|
}
|