Merge refactor/descriptive-constants (refactor step 1)
This commit is contained in:
56
TODO.md
56
TODO.md
@@ -29,19 +29,21 @@ Refactor ground rules:
|
|||||||
|
|
||||||
# Next Step
|
# Next Step
|
||||||
|
|
||||||
Refactor step 1 (branch refactor/descriptive-constants): rename
|
Refactor step 2 (branch refactor/typed-kinds): typed kind enums —
|
||||||
constants to descriptive, less C-like names. Creature/object/room/place
|
PotionKind, ScrollKind, RingKind, WandKind, WeaponKind, ArmorKind,
|
||||||
flag bits (IsHuh→Confused, IsHalu→Hallucinating, CanHuh→CanConfuse,
|
TrapKind as iota enums with fmt.Stringer; Object.Which and the ObjInfo
|
||||||
SeeMonst→SenseMonsters, ObjIsFound→WasFound, IsCanc→Cancelled, ...),
|
tables move to the typed kinds; the object category glyph bytes ('!',
|
||||||
trap types (TMyst→TrapMystery), item subtype constants
|
'?', ...) become an ObjectKind with a Glyph() method so item category
|
||||||
(PLSD→PotionLSD, SIDRorS→ScrollIdentifyRingOrStick,
|
and map character stop sharing one byte namespace.
|
||||||
RAddHit→RingDexterity, WsHasteM→WandHasteMonster,
|
|
||||||
TwoSword→WeaponTwoHandedSword, ...), Max* count constants →
|
|
||||||
Num*Types, and the Level.NTraps field → TrapCount. Pure rename; no
|
|
||||||
behavior change; tests unchanged.
|
|
||||||
|
|
||||||
# Completed Steps
|
# Completed Steps
|
||||||
|
|
||||||
|
- 2026-07-06 Refactor step 1 (refactor/descriptive-constants): renamed
|
||||||
|
all flag bits, trap types, item subtype constants, and Max* counts to
|
||||||
|
descriptive names (IsHuh→Confused, SeeMonst→SenseMonsters,
|
||||||
|
WsHasteM→WandHasteMonster, MaxSticks→NumWandTypes, ...);
|
||||||
|
Level.NTraps→TrapCount; C names kept as comment breadcrumbs. Pure
|
||||||
|
rename, suite green.
|
||||||
- 2026-07-06 Made the rgoue branch Go-only: removed C sources and the
|
- 2026-07-06 Made the rgoue branch Go-only: removed C sources and the
|
||||||
autoconf/VS build system (they remain on master and modern-rogue),
|
autoconf/VS build system (they remain on master and modern-rogue),
|
||||||
ported the last wizard command (item-probability listing), rewrote
|
ported the last wizard command (item-probability listing), rewrote
|
||||||
@@ -63,58 +65,52 @@ behavior change; tests unchanged.
|
|||||||
|
|
||||||
# Future Steps
|
# Future Steps
|
||||||
|
|
||||||
1. Refactor step 2: typed kind enums — PotionKind, ScrollKind,
|
1. Refactor step 3: un-overload Object fields — split Object.Arm into
|
||||||
RingKind, WandKind, WeaponKind, ArmorKind, TrapKind as iota enums
|
|
||||||
with fmt.Stringer; Object.Which and the ObjInfo tables move to the
|
|
||||||
typed kinds; the object category glyph bytes ('!', '?', ...) become
|
|
||||||
an ObjectKind with a Glyph() method so item category and map
|
|
||||||
character stop sharing one byte namespace.
|
|
||||||
2. Refactor step 3: un-overload Object fields — split Object.Arm into
|
|
||||||
ArmorClass/Charges/GoldValue; parse damage dice ("1x4/1x2") once
|
ArmorClass/Charges/GoldValue; parse damage dice ("1x4/1x2") once
|
||||||
into a DiceSpec type at table definition instead of per swing;
|
into a DiceSpec type at table definition instead of per swing;
|
||||||
save-format update with round-trip test migration.
|
save-format update with round-trip test migration.
|
||||||
3. Adopt the house Go linting standards: copy .golangci.yml from the
|
2. Adopt the house Go linting standards: copy .golangci.yml from the
|
||||||
prompts repo and bring game/, term/, and cmd/ lint-clean (the port
|
prompts repo and bring game/, term/, and cmd/ lint-clean (the port
|
||||||
is greenfield code, so no exemptions apply).
|
is greenfield code, so no exemptions apply).
|
||||||
4. Refactor step 4: method renames, movement/world subsystem
|
3. Refactor step 4: method renames, movement/world subsystem
|
||||||
(doMove→moveHero, beTrapped→springTrap, rndmove→randomStep,
|
(doMove→moveHero, beTrapped→springTrap, rndmove→randomStep,
|
||||||
doRooms/doPassages/doMaze→digRooms/digPassages/digMaze,
|
doRooms/doPassages/doMaze→digRooms/digPassages/digMaze,
|
||||||
chgStr→changeStrength, ...); remove the goto/label flows in doMove,
|
chgStr→changeStrength, ...); remove the goto/label flows in doMove,
|
||||||
dispatch, and saveGame in favor of loops and helpers.
|
dispatch, and saveGame in favor of loops and helpers.
|
||||||
5. Refactor step 5: method renames, items/combat/UI subsystems
|
4. Refactor step 5: method renames, items/combat/UI subsystems
|
||||||
(invName→inventoryName, rollEm→rollAttacks, doPot→applyPotionFuse,
|
(invName→inventoryName, rollEm→rollAttacks, doPot→applyPotionFuse,
|
||||||
getItem→promptPackItem returning (obj, ok), getDir→promptDirection);
|
getItem→promptPackItem returning (obj, ok), getDir→promptDirection);
|
||||||
int status codes (attack returning -1) become named results. Two or
|
int status codes (attack returning -1) become named results. Two or
|
||||||
three commits, one subsystem each.
|
three commits, one subsystem each.
|
||||||
6. Refactor step 6: extract types from the god object — MessageLine
|
5. Refactor step 6: extract types from the god object — MessageLine
|
||||||
owns the msg/addmsg/endmsg machinery; pack/inventory operations move
|
owns the msg/addmsg/endmsg machinery; pack/inventory operations move
|
||||||
onto *Player; monster/object list management and map queries
|
onto *Player; monster/object list management and map queries
|
||||||
consolidate onto *Level; RogueGame keeps turn orchestration and
|
consolidate onto *Level; RogueGame keeps turn orchestration and
|
||||||
cross-system effects only.
|
cross-system effects only.
|
||||||
7. Refactor step 7: effects dispatch — the giant quaff/readScroll/doZap
|
6. Refactor step 7: effects dispatch — the giant quaff/readScroll/doZap
|
||||||
switches become per-kind handler tables of small named methods,
|
switches become per-kind handler tables of small named methods,
|
||||||
keeping effect order and RNG call sequence identical.
|
keeping effect order and RNG call sequence identical.
|
||||||
8. Refactor step 8: constructor and style pass per the house
|
7. Refactor step 8: constructor and style pass per the house
|
||||||
styleguide — game.New(game.Params{...}) replacing NewGame(Config);
|
styleguide — game.New(game.Params{...}) replacing NewGame(Config);
|
||||||
replace the gameEnd panic unwind with error-based turn results where
|
replace the gameEnd panic unwind with error-based turn results where
|
||||||
feasible; 77-column wrap sweep.
|
feasible; 77-column wrap sweep.
|
||||||
9. Docs refresh: update ARCHITECTURE.md Part 2 and README.md for the
|
8. Docs refresh: update ARCHITECTURE.md Part 2 and README.md for the
|
||||||
post-refactor names; add the C name → Go name rename table.
|
post-refactor names; add the C name → Go name rename table.
|
||||||
10. Playtest hardening pass: play several full games with the tcell
|
9. Playtest hardening pass: play several full games with the tcell
|
||||||
binary and extend run_test.go to script a deeper multi-level
|
binary and extend run_test.go to script a deeper multi-level
|
||||||
playthrough (descend past level 5, use potions, scrolls, zapping,
|
playthrough (descend past level 5, use potions, scrolls, zapping,
|
||||||
save/restore). Fix any panics, message mismatches, or divergences
|
save/restore). Fix any panics, message mismatches, or divergences
|
||||||
from the C behavior that this uncovers, with regression tests.
|
from the C behavior that this uncovers, with regression tests.
|
||||||
11. Verify the seed-compatibility claim against the C reference on
|
10. Verify the seed-compatibility claim against the C reference on
|
||||||
c-master: same seed, same dungeon, same item tables, for several
|
c-master: same seed, same dungeon, same item tables, for several
|
||||||
seeds.
|
seeds.
|
||||||
12. Broaden unit test coverage where playtesting finds thin spots
|
11. Broaden unit test coverage where playtesting finds thin spots
|
||||||
(rings, sticks, wizard commands).
|
(rings, sticks, wizard commands).
|
||||||
13. Tag a release once a full game (Amulet retrieval and score entry)
|
12. Tag a release once a full game (Amulet retrieval and score entry)
|
||||||
completes without defects.
|
completes without defects.
|
||||||
14. Full-terminal-size support (deferred by explicit decision
|
13. Full-terminal-size support (deferred by explicit decision
|
||||||
2026-07-06): per-game dungeon dimensions instead of the 80x24
|
2026-07-06): per-game dungeon dimensions instead of the 80x24
|
||||||
constants; open design questions are resize policy, gameplay
|
constants; open design questions are resize policy, gameplay
|
||||||
tuning at larger sizes, and a --classic 80x24 mode.
|
tuning at larger sizes, and a --classic 80x24 mode.
|
||||||
15. Note: this repo is exempt from the standard policy scaffold. Do not
|
14. Note: this repo is exempt from the standard policy scaffold. Do not
|
||||||
add Makefile, Dockerfile, or REPO_POLICIES.md.
|
add Makefile, Dockerfile, or REPO_POLICIES.md.
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func (g *RogueGame) wear() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
g.wasteTime()
|
g.wasteTime()
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
sp := g.invName(obj, true)
|
sp := g.invName(obj, true)
|
||||||
p.CurArmor = obj
|
p.CurArmor = obj
|
||||||
if !g.Options.Terse {
|
if !g.Options.Terse {
|
||||||
|
|||||||
@@ -9,19 +9,19 @@ const dragonShot = 5
|
|||||||
func (g *RogueGame) runners(int) {
|
func (g *RogueGame) runners(int) {
|
||||||
list := append([]*Monster(nil), g.Level.Monsters...)
|
list := append([]*Monster(nil), g.Level.Monsters...)
|
||||||
for _, tp := range list {
|
for _, tp := range list {
|
||||||
if !tp.On(IsHeld) && tp.On(IsRun) {
|
if !tp.On(Held) && tp.On(Awake) {
|
||||||
origPos := tp.Pos
|
origPos := tp.Pos
|
||||||
wastarget := tp.On(IsTarget)
|
wastarget := tp.On(Targeted)
|
||||||
if g.moveMonst(tp) == -1 {
|
if g.moveMonst(tp) == -1 {
|
||||||
continue
|
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 {
|
if g.moveMonst(tp) == -1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if wastarget && origPos != tp.Pos {
|
if wastarget && origPos != tp.Pos {
|
||||||
tp.Flags.Clear(IsTarget)
|
tp.Flags.Clear(Targeted)
|
||||||
g.ToDeath = false
|
g.ToDeath = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,12 +35,12 @@ func (g *RogueGame) runners(int) {
|
|||||||
// moveMonst executes a single turn of running for a monster (chase.c
|
// moveMonst executes a single turn of running for a monster (chase.c
|
||||||
// move_monst). Returns -1 if the monster died or left the level.
|
// move_monst). Returns -1 if the monster died or left the level.
|
||||||
func (g *RogueGame) moveMonst(tp *Monster) int {
|
func (g *RogueGame) moveMonst(tp *Monster) int {
|
||||||
if !tp.On(IsSlow) || tp.Turn {
|
if !tp.On(Slowed) || tp.Turn {
|
||||||
if g.doChase(tp) == -1 {
|
if g.doChase(tp) == -1 {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if tp.On(IsHaste) {
|
if tp.On(Hasted) {
|
||||||
if g.doChase(tp) == -1 {
|
if g.doChase(tp) == -1 {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ func (g *RogueGame) relocate(th *Monster, newLoc Coord) {
|
|||||||
g.move(newLoc.Y, newLoc.X)
|
g.move(newLoc.Y, newLoc.X)
|
||||||
if g.seeMonst(th) {
|
if g.seeMonst(th) {
|
||||||
g.addch(th.Disguise)
|
g.addch(th.Disguise)
|
||||||
} else if g.Player.On(SeeMonst) {
|
} else if g.Player.On(SenseMonsters) {
|
||||||
g.standout()
|
g.standout()
|
||||||
g.addch(th.Type)
|
g.addch(th.Type)
|
||||||
g.standend()
|
g.standend()
|
||||||
@@ -83,7 +83,7 @@ func (g *RogueGame) doChase(th *Monster) int {
|
|||||||
mindist := 32767
|
mindist := 32767
|
||||||
|
|
||||||
rer := th.Room // find room of chaser
|
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
|
th.Dest = &p.Pos // if gold has been taken, run after hero
|
||||||
}
|
}
|
||||||
var ree *Room // find room of chasee
|
var ree *Room // find room of chasee
|
||||||
@@ -108,7 +108,7 @@ over:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if door {
|
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
|
door = false
|
||||||
goto over
|
goto over
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ over:
|
|||||||
if th.Type == 'D' && (th.Pos.Y == p.Pos.Y || th.Pos.X == p.Pos.X ||
|
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)) &&
|
abs(th.Pos.Y-p.Pos.Y) == abs(th.Pos.X-p.Pos.X)) &&
|
||||||
distCp(th.Pos, p.Pos) <= BoltLength*BoltLength &&
|
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.Y = sign(p.Pos.Y - th.Pos.Y)
|
||||||
g.Delta.X = sign(p.Pos.X - th.Pos.X)
|
g.Delta.X = sign(p.Pos.X - th.Pos.X)
|
||||||
if g.HasHit {
|
if g.HasHit {
|
||||||
@@ -130,7 +130,7 @@ over:
|
|||||||
g.Running = false
|
g.Running = false
|
||||||
g.Count = 0
|
g.Count = 0
|
||||||
g.Quiet = 0
|
g.Quiet = 0
|
||||||
if g.ToDeath && !th.On(IsTarget) {
|
if g.ToDeath && !th.On(Targeted) {
|
||||||
g.ToDeath = false
|
g.ToDeath = false
|
||||||
g.Kamikaze = false
|
g.Kamikaze = false
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ over:
|
|||||||
if th.Dest == &obj.Pos {
|
if th.Dest == &obj.Pos {
|
||||||
detachObj(&g.Level.Objects, obj)
|
detachObj(&g.Level.Objects, obj)
|
||||||
attachObj(&th.Pack, 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)
|
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, Passage)
|
||||||
} else {
|
} else {
|
||||||
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, Floor)
|
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, Floor)
|
||||||
@@ -168,7 +168,7 @@ over:
|
|||||||
g.relocate(th, g.chRet)
|
g.relocate(th, g.chRet)
|
||||||
// And stop running if need be
|
// And stop running if need be
|
||||||
if stoprun && th.Pos == *th.Dest {
|
if stoprun && th.Pos == *th.Dest {
|
||||||
th.Flags.Clear(IsRun)
|
th.Flags.Clear(Awake)
|
||||||
}
|
}
|
||||||
return 0
|
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
|
// If the thing is confused, let it move randomly. Invisible Stalkers
|
||||||
// are slightly confused all of the time, and bats are quite confused
|
// are slightly confused all of the time, and bats are quite confused
|
||||||
// all the time
|
// 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) {
|
(tp.Type == 'B' && g.rnd(2) == 0) {
|
||||||
// get a valid random move
|
// get a valid random move
|
||||||
g.chRet = g.rndmove(&tp.Creature)
|
g.chRet = g.rndmove(&tp.Creature)
|
||||||
curdist = distCp(g.chRet, ee)
|
curdist = distCp(g.chRet, ee)
|
||||||
// Small chance that it will become un-confused
|
// Small chance that it will become un-confused
|
||||||
if g.rnd(20) == 0 {
|
if g.rnd(20) == 0 {
|
||||||
tp.Flags.Clear(IsHuh)
|
tp.Flags.Clear(Confused)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, find the empty spot next to the chaser that is
|
// 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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if found != nil && found.Which == SScare {
|
if found != nil && found.Which == ScrollScareMonster {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,8 +268,8 @@ func (g *RogueGame) setOldch(tp *Monster, cp Coord) {
|
|||||||
}
|
}
|
||||||
sch := tp.OldCh
|
sch := tp.OldCh
|
||||||
tp.OldCh = g.mvinch(cp.Y, cp.X)
|
tp.OldCh = g.mvinch(cp.Y, cp.X)
|
||||||
if !g.Player.On(IsBlind) {
|
if !g.Player.On(Blind) {
|
||||||
if (sch == Floor || tp.OldCh == Floor) && tp.Room.Flags.Has(IsDark) {
|
if (sch == Floor || tp.OldCh == Floor) && tp.Room.Flags.Has(Dark) {
|
||||||
tp.OldCh = ' '
|
tp.OldCh = ' '
|
||||||
} else if distCp(cp, g.Player.Pos) <= LampDist && g.Options.SeeFloor {
|
} else if distCp(cp, g.Player.Pos) <= LampDist && g.Options.SeeFloor {
|
||||||
tp.OldCh = g.Level.Char(cp.Y, cp.X)
|
tp.OldCh = g.Level.Char(cp.Y, cp.X)
|
||||||
@@ -281,10 +281,10 @@ func (g *RogueGame) setOldch(tp *Monster, cp Coord) {
|
|||||||
// see_monst).
|
// see_monst).
|
||||||
func (g *RogueGame) seeMonst(mp *Monster) bool {
|
func (g *RogueGame) seeMonst(mp *Monster) bool {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
if p.On(IsBlind) {
|
if p.On(Blind) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if mp.On(IsInvis) && !p.On(CanSee) {
|
if mp.On(Invisible) && !p.On(CanSeeInvisible) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
y, x := mp.Pos.Y, mp.Pos.X
|
y, x := mp.Pos.Y, mp.Pos.X
|
||||||
@@ -298,7 +298,7 @@ func (g *RogueGame) seeMonst(mp *Monster) bool {
|
|||||||
if mp.Room != p.Room {
|
if mp.Room != p.Room {
|
||||||
return false
|
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).
|
// runto sets a monster running after the hero (chase.c runto).
|
||||||
@@ -308,8 +308,8 @@ func (g *RogueGame) runto(runner Coord) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Start the beastie running
|
// Start the beastie running
|
||||||
tp.Flags.Set(IsRun)
|
tp.Flags.Set(Awake)
|
||||||
tp.Flags.Clear(IsHeld)
|
tp.Flags.Clear(Held)
|
||||||
tp.Dest = g.findDest(tp)
|
tp.Dest = g.findDest(tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,8 +317,8 @@ func (g *RogueGame) runto(runner Coord) {
|
|||||||
// any room (chase.c roomin).
|
// any room (chase.c roomin).
|
||||||
func (g *RogueGame) roomin(cp Coord) *Room {
|
func (g *RogueGame) roomin(cp Coord) *Room {
|
||||||
fp := *g.Level.FlagsAt(cp.Y, cp.X)
|
fp := *g.Level.FlagsAt(cp.Y, cp.X)
|
||||||
if fp.Has(FPass) {
|
if fp.Has(FPassage) {
|
||||||
return &g.Level.Passages[fp&FPNum]
|
return &g.Level.Passages[fp&FPassNum]
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range g.Level.Rooms {
|
for i := range g.Level.Rooms {
|
||||||
@@ -348,11 +348,11 @@ func (g *RogueGame) diagOk(sp, ep Coord) bool {
|
|||||||
// cansee).
|
// cansee).
|
||||||
func (g *RogueGame) cansee(y, x int) bool {
|
func (g *RogueGame) cansee(y, x int) bool {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
if p.On(IsBlind) {
|
if p.On(Blind) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if distance(y, x, p.Pos.Y, p.Pos.X) < LampDist {
|
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 &&
|
if y != p.Pos.Y && x != p.Pos.X &&
|
||||||
!stepOk(g.Level.Char(y, p.Pos.X)) &&
|
!stepOk(g.Level.Char(y, p.Pos.X)) &&
|
||||||
!stepOk(g.Level.Char(p.Pos.Y, 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
|
// 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.
|
// and the room is lit, or if it is close.
|
||||||
rer := g.roomin(Coord{X: x, Y: y})
|
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
|
// 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
|
return &g.Player.Pos
|
||||||
}
|
}
|
||||||
for _, obj := range g.Level.Objects {
|
for _, obj := range g.Level.Objects {
|
||||||
if obj.Type == Scroll && obj.Which == SScare {
|
if obj.Type == Scroll && obj.Which == ScrollScareMonster {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if g.roomin(obj.Pos) == tp.Room && g.rnd(100) < prob {
|
if g.roomin(obj.Pos) == tp.Room && g.rnd(100) < prob {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package game
|
|||||||
func (g *RogueGame) command() {
|
func (g *RogueGame) command() {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
ntimes := 1 // number of player moves
|
ntimes := 1 // number of player moves
|
||||||
if p.On(IsHaste) {
|
if p.On(Hasted) {
|
||||||
ntimes++
|
ntimes++
|
||||||
}
|
}
|
||||||
// Let the daemons start up
|
// 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
|
// these are illegal things for the player to be, so if any are
|
||||||
// set, someone's been poking in memory
|
// 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")
|
panic("player flags corrupted")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ func (g *RogueGame) command() {
|
|||||||
}
|
}
|
||||||
if g.NoCommand != 0 {
|
if g.NoCommand != 0 {
|
||||||
if g.NoCommand--; g.NoCommand == 0 {
|
if g.NoCommand--; g.NoCommand == 0 {
|
||||||
p.Flags.Set(IsRun)
|
p.Flags.Set(Awake)
|
||||||
g.msg("you can move again")
|
g.msg("you can move again")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -121,14 +121,14 @@ func (g *RogueGame) command() {
|
|||||||
}
|
}
|
||||||
g.DoDaemons(After)
|
g.DoDaemons(After)
|
||||||
g.DoFuses(After)
|
g.DoFuses(After)
|
||||||
if p.IsRing(Left, RSearch) {
|
if p.IsRing(Left, RingSearching) {
|
||||||
g.search()
|
g.search()
|
||||||
} else if p.IsRing(Left, RTeleport) && g.rnd(50) == 0 {
|
} else if p.IsRing(Left, RingTeleportation) && g.rnd(50) == 0 {
|
||||||
g.teleport()
|
g.teleport()
|
||||||
}
|
}
|
||||||
if p.IsRing(Right, RSearch) {
|
if p.IsRing(Right, RingSearching) {
|
||||||
g.search()
|
g.search()
|
||||||
} else if p.IsRing(Right, RTeleport) && g.rnd(50) == 0 {
|
} else if p.IsRing(Right, RingTeleportation) && g.rnd(50) == 0 {
|
||||||
g.teleport()
|
g.teleport()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ over:
|
|||||||
g.doRun('n')
|
g.doRun('n')
|
||||||
case CTRL('H'), CTRL('J'), CTRL('K'), CTRL('L'),
|
case CTRL('H'), CTRL('J'), CTRL('K'), CTRL('L'),
|
||||||
CTRL('Y'), CTRL('U'), CTRL('B'), CTRL('N'):
|
CTRL('Y'), CTRL('U'), CTRL('B'), CTRL('N'):
|
||||||
if !p.On(IsBlind) {
|
if !p.On(Blind) {
|
||||||
g.DoorStop = true
|
g.DoorStop = true
|
||||||
g.Firstmove = true
|
g.Firstmove = true
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ over:
|
|||||||
g.Delta.Y += p.Pos.Y
|
g.Delta.Y += p.Pos.Y
|
||||||
g.Delta.X += p.Pos.X
|
g.Delta.X += p.Pos.X
|
||||||
mp := g.Level.MonsterAt(g.Delta.Y, g.Delta.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 {
|
if !g.Options.Terse {
|
||||||
g.addmsg("I see ")
|
g.addmsg("I see ")
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ over:
|
|||||||
} else if g.diagOk(p.Pos, g.Delta) {
|
} else if g.diagOk(p.Pos, g.Delta) {
|
||||||
g.ToDeath = true
|
g.ToDeath = true
|
||||||
g.MaxHit = 0
|
g.MaxHit = 0
|
||||||
mp.Flags.Set(IsTarget)
|
mp.Flags.Set(Targeted)
|
||||||
g.RunCh = g.DirCh
|
g.RunCh = g.DirCh
|
||||||
ch = g.DirCh
|
ch = g.DirCh
|
||||||
goto over
|
goto over
|
||||||
@@ -333,10 +333,10 @@ over:
|
|||||||
}
|
}
|
||||||
if g.Level.Char(g.Delta.Y, g.Delta.X) != Trap {
|
if g.Level.Char(g.Delta.Y, g.Delta.X) != Trap {
|
||||||
g.msg("no trap there")
|
g.msg("no trap there")
|
||||||
} else if p.On(IsHalu) {
|
} else if p.On(Hallucinating) {
|
||||||
g.msg("%s", trName[g.rnd(NTraps)])
|
g.msg("%s", trName[g.rnd(NumTrapTypes)])
|
||||||
} else {
|
} else {
|
||||||
g.msg("%s", trName[*fp&FTMask])
|
g.msg("%s", trName[*fp&FTrapMask])
|
||||||
fp.Set(FSeen)
|
fp.Set(FSeen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,7 +407,7 @@ func (g *RogueGame) wizardCommand(ch byte) {
|
|||||||
case CTRL('C'):
|
case CTRL('C'):
|
||||||
g.addPass()
|
g.addPass()
|
||||||
case CTRL('X'):
|
case CTRL('X'):
|
||||||
g.turnSee(p.On(SeeMonst))
|
g.turnSee(p.On(SenseMonsters))
|
||||||
case CTRL('~'):
|
case CTRL('~'):
|
||||||
if item := g.getItem("charge", int(Stick)); item != nil {
|
if item := g.getItem("charge", int(Stick)); item != nil {
|
||||||
item.SetCharges(10000)
|
item.SetCharges(10000)
|
||||||
@@ -418,7 +418,7 @@ func (g *RogueGame) wizardCommand(ch byte) {
|
|||||||
}
|
}
|
||||||
// Give him a sword (+1,+1)
|
// Give him a sword (+1,+1)
|
||||||
obj := newObject()
|
obj := newObject()
|
||||||
g.initWeapon(obj, TwoSword)
|
g.initWeapon(obj, WeaponTwoHandedSword)
|
||||||
obj.HPlus = 1
|
obj.HPlus = 1
|
||||||
obj.DPlus = 1
|
obj.DPlus = 1
|
||||||
g.addPack(obj, true)
|
g.addPack(obj, true)
|
||||||
@@ -426,9 +426,9 @@ func (g *RogueGame) wizardCommand(ch byte) {
|
|||||||
// And his suit of armor
|
// And his suit of armor
|
||||||
obj = newObject()
|
obj = newObject()
|
||||||
obj.Type = Armor
|
obj.Type = Armor
|
||||||
obj.Which = PlateMail
|
obj.Which = ArmorPlateMail
|
||||||
obj.Arm = -5
|
obj.Arm = -5
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
obj.Count = 1
|
obj.Count = 1
|
||||||
p.CurArmor = obj
|
p.CurArmor = obj
|
||||||
g.addPack(obj, true)
|
g.addPack(obj, true)
|
||||||
@@ -453,10 +453,10 @@ func (g *RogueGame) search() {
|
|||||||
ey := p.Pos.Y + 1
|
ey := p.Pos.Y + 1
|
||||||
ex := p.Pos.X + 1
|
ex := p.Pos.X + 1
|
||||||
probinc := 0
|
probinc := 0
|
||||||
if p.On(IsHalu) {
|
if p.On(Hallucinating) {
|
||||||
probinc = 3
|
probinc = 3
|
||||||
}
|
}
|
||||||
if p.On(IsBlind) {
|
if p.On(Blind) {
|
||||||
probinc += 2
|
probinc += 2
|
||||||
}
|
}
|
||||||
found := false
|
found := false
|
||||||
@@ -486,10 +486,10 @@ func (g *RogueGame) search() {
|
|||||||
if !g.Options.Terse {
|
if !g.Options.Terse {
|
||||||
g.addmsg("you found ")
|
g.addmsg("you found ")
|
||||||
}
|
}
|
||||||
if p.On(IsHalu) {
|
if p.On(Hallucinating) {
|
||||||
g.msg("%s", trName[g.rnd(NTraps)])
|
g.msg("%s", trName[g.rnd(NumTrapTypes)])
|
||||||
} else {
|
} else {
|
||||||
g.msg("%s", trName[*fp&FTMask])
|
g.msg("%s", trName[*fp&FTrapMask])
|
||||||
fp.Set(FSeen)
|
fp.Set(FSeen)
|
||||||
}
|
}
|
||||||
foundone = true
|
foundone = true
|
||||||
@@ -661,7 +661,7 @@ func (g *RogueGame) uLevel() {
|
|||||||
// levitCheck checks whether she's levitating, and if she is, prints an
|
// levitCheck checks whether she's levitating, and if she is, prints an
|
||||||
// appropriate message (command.c levit_check).
|
// appropriate message (command.c levit_check).
|
||||||
func (g *RogueGame) levitCheck() bool {
|
func (g *RogueGame) levitCheck() bool {
|
||||||
if !g.Player.On(IsLevit) {
|
if !g.Player.On(Levitating) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
g.msg("You can't. You're floating off the ground!")
|
g.msg("You can't. You're floating off the ground!")
|
||||||
|
|||||||
@@ -53,10 +53,10 @@ func (g *RogueGame) doctor(int) {
|
|||||||
} else if g.Quiet >= 3 {
|
} else if g.Quiet >= 3 {
|
||||||
p.Stats.HP += g.rnd(lv-7) + 1
|
p.Stats.HP += g.rnd(lv-7) + 1
|
||||||
}
|
}
|
||||||
if p.IsRing(Left, RRegen) {
|
if p.IsRing(Left, RingRegeneration) {
|
||||||
p.Stats.HP++
|
p.Stats.HP++
|
||||||
}
|
}
|
||||||
if p.IsRing(Right, RRegen) {
|
if p.IsRing(Right, RingRegeneration) {
|
||||||
p.Stats.HP++
|
p.Stats.HP++
|
||||||
}
|
}
|
||||||
if ohp != 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 releases the poor player from his confusion (daemons.c
|
||||||
// unconfuse).
|
// unconfuse).
|
||||||
func (g *RogueGame) unconfuse(int) {
|
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"))
|
g.msg("you feel less %s now", g.chooseStr("trippy", "confused"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsee turns off the ability to see invisible (daemons.c unsee).
|
// unsee turns off the ability to see invisible (daemons.c unsee).
|
||||||
func (g *RogueGame) unsee(int) {
|
func (g *RogueGame) unsee(int) {
|
||||||
for _, th := range g.Level.Monsters {
|
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.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).
|
// sight gives the hero his sight back (daemons.c sight).
|
||||||
func (g *RogueGame) sight(int) {
|
func (g *RogueGame) sight(int) {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
if p.On(IsBlind) {
|
if p.On(Blind) {
|
||||||
g.Extinguish(DSight)
|
g.Extinguish(DSight)
|
||||||
p.Flags.Clear(IsBlind)
|
p.Flags.Clear(Blind)
|
||||||
if !p.Room.Flags.Has(IsGone) {
|
if !p.Room.Flags.Has(Gone) {
|
||||||
g.enterRoom(p.Pos)
|
g.enterRoom(p.Pos)
|
||||||
}
|
}
|
||||||
g.msg("%s", g.chooseStr("far out! Everything is all cosmic again",
|
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).
|
// nohaste ends the hasting (daemons.c nohaste).
|
||||||
func (g *RogueGame) nohaste(int) {
|
func (g *RogueGame) nohaste(int) {
|
||||||
g.Player.Flags.Clear(IsHaste)
|
g.Player.Flags.Clear(Hasted)
|
||||||
g.msg("you feel yourself slowing down")
|
g.msg("you feel yourself slowing down")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ func (g *RogueGame) stomach(int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.HungryState != origHungry {
|
if p.HungryState != origHungry {
|
||||||
p.Flags.Clear(IsRun)
|
p.Flags.Clear(Awake)
|
||||||
g.Running = false
|
g.Running = false
|
||||||
g.ToDeath = false
|
g.ToDeath = false
|
||||||
g.Count = 0
|
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).
|
// comeDown takes the hero down off her acid trip (daemons.c come_down).
|
||||||
func (g *RogueGame) comeDown(int) {
|
func (g *RogueGame) comeDown(int) {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
if !p.On(IsHalu) {
|
if !p.On(Hallucinating) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
g.KillDaemon(DVisuals)
|
g.KillDaemon(DVisuals)
|
||||||
p.Flags.Clear(IsHalu)
|
p.Flags.Clear(Hallucinating)
|
||||||
|
|
||||||
if p.On(IsBlind) {
|
if p.On(Blind) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,11 +199,11 @@ func (g *RogueGame) comeDown(int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// undo the monsters
|
// undo the monsters
|
||||||
seemonst := p.On(SeeMonst)
|
seemonst := p.On(SenseMonsters)
|
||||||
for _, tp := range g.Level.Monsters {
|
for _, tp := range g.Level.Monsters {
|
||||||
g.move(tp.Pos.Y, tp.Pos.X)
|
g.move(tp.Pos.Y, tp.Pos.X)
|
||||||
if g.cansee(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)
|
g.addch(tp.Disguise)
|
||||||
} else {
|
} else {
|
||||||
g.addch(g.Level.Char(tp.Pos.Y, tp.Pos.X))
|
g.addch(g.Level.Char(tp.Pos.Y, tp.Pos.X))
|
||||||
@@ -237,7 +237,7 @@ func (g *RogueGame) visuals(int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// change the monsters
|
// change the monsters
|
||||||
seemonst := p.On(SeeMonst)
|
seemonst := p.On(SenseMonsters)
|
||||||
for _, tp := range g.Level.Monsters {
|
for _, tp := range g.Level.Monsters {
|
||||||
g.move(tp.Pos.Y, tp.Pos.X)
|
g.move(tp.Pos.Y, tp.Pos.X)
|
||||||
if g.seeMonst(tp) {
|
if g.seeMonst(tp) {
|
||||||
@@ -256,7 +256,7 @@ func (g *RogueGame) visuals(int) {
|
|||||||
|
|
||||||
// land lands the hero from a levitation potion (daemons.c land).
|
// land lands the hero from a levitation potion (daemons.c land).
|
||||||
func (g *RogueGame) land(int) {
|
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",
|
g.msg("%s", g.chooseStr("bummer! You've hit the ground",
|
||||||
"you float gently to the ground"))
|
"you float gently to the ground"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func TestQuaffHealingPotion(t *testing.T) {
|
|||||||
g := mkGameInput(t, 5, "")
|
g := mkGameInput(t, 5, "")
|
||||||
pot := newObject()
|
pot := newObject()
|
||||||
pot.Type = Potion
|
pot.Type = Potion
|
||||||
pot.Which = PHealing
|
pot.Which = PotionHealing
|
||||||
ch := give(g, pot)
|
ch := give(g, pot)
|
||||||
g.scr.term.(*testTerm).input = []byte{ch}
|
g.scr.term.(*testTerm).input = []byte{ch}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ func TestQuaffHealingPotion(t *testing.T) {
|
|||||||
if g.Player.Stats.HP <= 1 {
|
if g.Player.Stats.HP <= 1 {
|
||||||
t.Error("healing potion did not heal")
|
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")
|
t.Error("healing potion not identified after drinking")
|
||||||
}
|
}
|
||||||
if len(g.Player.Pack) != 5 {
|
if len(g.Player.Pack) != 5 {
|
||||||
@@ -44,12 +44,12 @@ func TestQuaffConfusionSetsFlagAndFuse(t *testing.T) {
|
|||||||
g := mkGameInput(t, 5, "")
|
g := mkGameInput(t, 5, "")
|
||||||
pot := newObject()
|
pot := newObject()
|
||||||
pot.Type = Potion
|
pot.Type = Potion
|
||||||
pot.Which = PConfuse
|
pot.Which = PotionConfusion
|
||||||
ch := give(g, pot)
|
ch := give(g, pot)
|
||||||
g.scr.term.(*testTerm).input = []byte{ch}
|
g.scr.term.(*testTerm).input = []byte{ch}
|
||||||
|
|
||||||
g.quaff()
|
g.quaff()
|
||||||
if !g.Player.On(IsHuh) {
|
if !g.Player.On(Confused) {
|
||||||
t.Error("confusion potion did not confuse")
|
t.Error("confusion potion did not confuse")
|
||||||
}
|
}
|
||||||
if g.findSlot(DUnconfuse) == nil {
|
if g.findSlot(DUnconfuse) == nil {
|
||||||
@@ -59,7 +59,7 @@ func TestQuaffConfusionSetsFlagAndFuse(t *testing.T) {
|
|||||||
for range 30 {
|
for range 30 {
|
||||||
g.DoFuses(After)
|
g.DoFuses(After)
|
||||||
}
|
}
|
||||||
if g.Player.On(IsHuh) {
|
if g.Player.On(Confused) {
|
||||||
t.Error("confusion never wore off")
|
t.Error("confusion never wore off")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ func TestReadEnchantArmor(t *testing.T) {
|
|||||||
g := mkGameInput(t, 5, "")
|
g := mkGameInput(t, 5, "")
|
||||||
scr := newObject()
|
scr := newObject()
|
||||||
scr.Type = Scroll
|
scr.Type = Scroll
|
||||||
scr.Which = SArmor
|
scr.Which = ScrollEnchantArmor
|
||||||
ch := give(g, scr)
|
ch := give(g, scr)
|
||||||
g.scr.term.(*testTerm).input = []byte{ch}
|
g.scr.term.(*testTerm).input = []byte{ch}
|
||||||
|
|
||||||
@@ -88,16 +88,16 @@ func TestReadHoldMonsterFreezesAdjacent(t *testing.T) {
|
|||||||
// TestHoldScrollGreedyMonsterQuirk.
|
// TestHoldScrollGreedyMonsterQuirk.
|
||||||
g := mkGameInput(t, 5, "")
|
g := mkGameInput(t, 5, "")
|
||||||
tp := spawnAdjacent(g, 'Z')
|
tp := spawnAdjacent(g, 'Z')
|
||||||
tp.Flags.Set(IsRun)
|
tp.Flags.Set(Awake)
|
||||||
scr := newObject()
|
scr := newObject()
|
||||||
scr.Type = Scroll
|
scr.Type = Scroll
|
||||||
scr.Which = SHold
|
scr.Which = ScrollHoldMonster
|
||||||
ch := give(g, scr)
|
ch := give(g, scr)
|
||||||
g.scr.term.(*testTerm).input = []byte{ch}
|
g.scr.term.(*testTerm).input = []byte{ch}
|
||||||
|
|
||||||
g.readScroll()
|
g.readScroll()
|
||||||
t.Logf("after scroll: flags=%o huh=%q", tp.Flags, g.Msgs.Huh)
|
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")
|
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) {
|
func TestHoldScrollGreedyMonsterQuirk(t *testing.T) {
|
||||||
g := mkGameInput(t, 5, "")
|
g := mkGameInput(t, 5, "")
|
||||||
tp := spawnAdjacent(g, 'O')
|
tp := spawnAdjacent(g, 'O')
|
||||||
tp.Flags.Set(IsRun)
|
tp.Flags.Set(Awake)
|
||||||
scr := newObject()
|
scr := newObject()
|
||||||
scr.Type = Scroll
|
scr.Type = Scroll
|
||||||
scr.Which = SHold
|
scr.Which = ScrollHoldMonster
|
||||||
ch := give(g, scr)
|
ch := give(g, scr)
|
||||||
g.scr.term.(*testTerm).input = []byte{ch}
|
g.scr.term.(*testTerm).input = []byte{ch}
|
||||||
|
|
||||||
g.readScroll()
|
g.readScroll()
|
||||||
t.Logf("orc after scroll: flags=%o (IsRun=%v IsHeld=%v)",
|
t.Logf("orc after scroll: flags=%o (Awake=%v Held=%v)",
|
||||||
tp.Flags, tp.On(IsRun), tp.On(IsHeld))
|
tp.Flags, tp.On(Awake), tp.On(Held))
|
||||||
if !tp.On(IsHeld) {
|
if !tp.On(Held) {
|
||||||
t.Error("orc lost IsHeld entirely")
|
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 " +
|
t.Error("quirk changed: greedy monster stayed held; if this is a " +
|
||||||
"deliberate fix, update this test and ARCHITECTURE.md")
|
"deliberate fix, update this test and ARCHITECTURE.md")
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ func TestZapSlowMonster(t *testing.T) {
|
|||||||
tp := spawnAdjacent(g, 'Z')
|
tp := spawnAdjacent(g, 'Z')
|
||||||
stick := newObject()
|
stick := newObject()
|
||||||
stick.Type = Stick
|
stick.Type = Stick
|
||||||
stick.Which = WsSlowM
|
stick.Which = WandSlowMonster
|
||||||
g.fixStick(stick)
|
g.fixStick(stick)
|
||||||
ch := give(g, stick)
|
ch := give(g, stick)
|
||||||
g.scr.term.(*testTerm).input = []byte{ch}
|
g.scr.term.(*testTerm).input = []byte{ch}
|
||||||
@@ -141,7 +141,7 @@ func TestZapSlowMonster(t *testing.T) {
|
|||||||
|
|
||||||
charges := stick.Charges()
|
charges := stick.Charges()
|
||||||
g.doZap()
|
g.doZap()
|
||||||
if !tp.On(IsSlow) {
|
if !tp.On(Slowed) {
|
||||||
t.Error("slow monster wand did not slow")
|
t.Error("slow monster wand did not slow")
|
||||||
}
|
}
|
||||||
if stick.Charges() != charges-1 {
|
if stick.Charges() != charges-1 {
|
||||||
|
|||||||
@@ -48,14 +48,14 @@ var addDam = [32]int{
|
|||||||
// setMname returns the monster name for the given monster (fight.c
|
// setMname returns the monster name for the given monster (fight.c
|
||||||
// set_mname).
|
// set_mname).
|
||||||
func (g *RogueGame) setMname(tp *Monster) string {
|
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 {
|
if g.Options.Terse {
|
||||||
return "it"
|
return "it"
|
||||||
}
|
}
|
||||||
return "something"
|
return "something"
|
||||||
}
|
}
|
||||||
var mname string
|
var mname string
|
||||||
if g.Player.On(IsHalu) {
|
if g.Player.On(Hallucinating) {
|
||||||
ch := int(g.mvinch(tp.Pos.Y, tp.Pos.X))
|
ch := int(g.mvinch(tp.Pos.Y, tp.Pos.X))
|
||||||
if !isUpper(byte(ch)) {
|
if !isUpper(byte(ch)) {
|
||||||
ch = g.rnd(26)
|
ch = g.rnd(26)
|
||||||
@@ -83,9 +83,9 @@ func (g *RogueGame) fight(mp Coord, weap *Object, thrown bool) bool {
|
|||||||
g.Quiet = 0
|
g.Quiet = 0
|
||||||
g.runto(mp)
|
g.runto(mp)
|
||||||
// Let him know it was really a xeroc (if it was one).
|
// 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'
|
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.mvaddch(tp.Pos.Y, tp.Pos.X, byte(g.rnd(26)+'A'))
|
||||||
}
|
}
|
||||||
g.msg("%s", g.chooseStr("heavy! That's a nasty critter!",
|
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 {
|
} else {
|
||||||
g.hit("", mname, g.Options.Terse)
|
g.hit("", mname, g.Options.Terse)
|
||||||
}
|
}
|
||||||
if p.On(CanHuh) {
|
if p.On(CanConfuse) {
|
||||||
didHit = true
|
didHit = true
|
||||||
tp.Flags.Set(IsHuh)
|
tp.Flags.Set(Confused)
|
||||||
p.Flags.Clear(CanHuh)
|
p.Flags.Clear(CanConfuse)
|
||||||
g.endmsg()
|
g.endmsg()
|
||||||
g.HasHit = false
|
g.HasHit = false
|
||||||
g.msg("your hands stop glowing %s", g.pickColor("red"))
|
g.msg("your hands stop glowing %s", g.pickColor("red"))
|
||||||
}
|
}
|
||||||
if tp.Stats.HP <= 0 {
|
if tp.Stats.HP <= 0 {
|
||||||
g.killed(tp, true)
|
g.killed(tp, true)
|
||||||
} else if didHit && !p.On(IsBlind) {
|
} else if didHit && !p.On(Blind) {
|
||||||
g.msg("%s appears confused", mname)
|
g.msg("%s appears confused", mname)
|
||||||
}
|
}
|
||||||
didHit = true
|
didHit = true
|
||||||
@@ -137,13 +137,13 @@ func (g *RogueGame) attack(mp *Monster) int {
|
|||||||
g.Running = false
|
g.Running = false
|
||||||
g.Count = 0
|
g.Count = 0
|
||||||
g.Quiet = 0
|
g.Quiet = 0
|
||||||
if g.ToDeath && !mp.On(IsTarget) {
|
if g.ToDeath && !mp.On(Targeted) {
|
||||||
g.ToDeath = false
|
g.ToDeath = false
|
||||||
g.Kamikaze = 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'
|
mp.Disguise = 'X'
|
||||||
if p.On(IsHalu) {
|
if p.On(Hallucinating) {
|
||||||
g.mvaddch(mp.Pos.Y, mp.Pos.X, byte(g.rnd(26)+'A'))
|
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
|
g.ToDeath = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !mp.On(IsCanc) {
|
if !mp.On(Cancelled) {
|
||||||
switch mp.Type {
|
switch mp.Type {
|
||||||
case 'A':
|
case 'A':
|
||||||
// If an aquator hits, you can lose armor class.
|
// If an aquator hits, you can lose armor class.
|
||||||
g.rustArmor(p.CurArmor)
|
g.rustArmor(p.CurArmor)
|
||||||
case 'I':
|
case 'I':
|
||||||
// The ice monster freezes you
|
// The ice monster freezes you
|
||||||
p.Flags.Clear(IsRun)
|
p.Flags.Clear(Awake)
|
||||||
if g.NoCommand == 0 {
|
if g.NoCommand == 0 {
|
||||||
g.addmsg("you are frozen")
|
g.addmsg("you are frozen")
|
||||||
if !g.Options.Terse {
|
if !g.Options.Terse {
|
||||||
@@ -193,7 +193,7 @@ func (g *RogueGame) attack(mp *Monster) int {
|
|||||||
case 'R':
|
case 'R':
|
||||||
// Rattlesnakes have poisonous bites
|
// Rattlesnakes have poisonous bites
|
||||||
if !g.save(VsPoison) {
|
if !g.save(VsPoison) {
|
||||||
if !p.IsWearing(RSustStr) {
|
if !p.IsWearing(RingSustainStrength) {
|
||||||
g.chgStr(-1)
|
g.chgStr(-1)
|
||||||
if !g.Options.Terse {
|
if !g.Options.Terse {
|
||||||
g.msg("you feel a bite in your leg and now feel weaker")
|
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':
|
case 'F':
|
||||||
// Venus Flytrap stops the poor guy from moving
|
// Venus Flytrap stops the poor guy from moving
|
||||||
p.Flags.Set(IsHeld)
|
p.Flags.Set(Held)
|
||||||
p.VfHit++
|
p.VfHit++
|
||||||
g.Monsters['F'-'A'].Stats.Dmg = fmt.Sprintf("%dx1", p.VfHit)
|
g.Monsters['F'-'A'].Stats.Dmg = fmt.Sprintf("%dx1", p.VfHit)
|
||||||
if p.Stats.HP--; p.Stats.HP <= 0 {
|
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
|
hplus = weap.HPlus
|
||||||
dplus = weap.DPlus
|
dplus = weap.DPlus
|
||||||
if weap == p.CurWeapon {
|
if weap == p.CurWeapon {
|
||||||
if p.IsRing(Left, RAddDam) {
|
if p.IsRing(Left, RingIncreaseDamage) {
|
||||||
dplus += p.CurRing[Left].Arm
|
dplus += p.CurRing[Left].Arm
|
||||||
} else if p.IsRing(Left, RAddHit) {
|
} else if p.IsRing(Left, RingDexterity) {
|
||||||
hplus += p.CurRing[Left].Arm
|
hplus += p.CurRing[Left].Arm
|
||||||
}
|
}
|
||||||
if p.IsRing(Right, RAddDam) {
|
if p.IsRing(Right, RingIncreaseDamage) {
|
||||||
dplus += p.CurRing[Right].Arm
|
dplus += p.CurRing[Right].Arm
|
||||||
} else if p.IsRing(Right, RAddHit) {
|
} else if p.IsRing(Right, RingDexterity) {
|
||||||
hplus += p.CurRing[Right].Arm
|
hplus += p.CurRing[Right].Arm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cp = weap.Damage
|
cp = weap.Damage
|
||||||
if hurl {
|
if hurl {
|
||||||
if weap.Flags.Has(IsMissl) && p.CurWeapon != nil &&
|
if weap.Flags.Has(Missile) && p.CurWeapon != nil &&
|
||||||
p.CurWeapon.Which == weap.Launch {
|
p.CurWeapon.Which == weap.Launch {
|
||||||
cp = weap.HurlDmg
|
cp = weap.HurlDmg
|
||||||
hplus += p.CurWeapon.HPlus
|
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
|
// If the creature being attacked is not running (asleep or held) then
|
||||||
// the attacker gets a plus four bonus to hit.
|
// the attacker gets a plus four bonus to hit.
|
||||||
if !thdef.Flags.Has(IsRun) {
|
if !thdef.Flags.Has(Awake) {
|
||||||
hplus += 4
|
hplus += 4
|
||||||
}
|
}
|
||||||
defArm := def.Arm
|
defArm := def.Arm
|
||||||
@@ -363,10 +363,10 @@ func (g *RogueGame) rollEm(thatt, thdef *Creature, weap *Object, hurl bool) bool
|
|||||||
if p.CurArmor != nil {
|
if p.CurArmor != nil {
|
||||||
defArm = p.CurArmor.Arm
|
defArm = p.CurArmor.Arm
|
||||||
}
|
}
|
||||||
if p.IsRing(Left, RProtect) {
|
if p.IsRing(Left, RingProtection) {
|
||||||
defArm -= p.CurRing[Left].Arm
|
defArm -= p.CurRing[Left].Arm
|
||||||
}
|
}
|
||||||
if p.IsRing(Right, RProtect) {
|
if p.IsRing(Right, RingProtection) {
|
||||||
defArm -= p.CurRing[Right].Arm
|
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.Level.SetMonsterAt(mp.Y, mp.X, nil)
|
||||||
g.mvaddch(mp.Y, mp.X, tp.OldCh)
|
g.mvaddch(mp.Y, mp.X, tp.OldCh)
|
||||||
detachMon(&g.Level.Monsters, tp)
|
detachMon(&g.Level.Monsters, tp)
|
||||||
if tp.On(IsTarget) {
|
if tp.On(Targeted) {
|
||||||
g.Kamikaze = false
|
g.Kamikaze = false
|
||||||
g.ToDeath = false
|
g.ToDeath = false
|
||||||
if g.Options.FightFlush {
|
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
|
// If the monster was a venus flytrap, un-hold him
|
||||||
switch tp.Type {
|
switch tp.Type {
|
||||||
case 'F':
|
case 'F':
|
||||||
p.Flags.Clear(IsHeld)
|
p.Flags.Clear(Held)
|
||||||
p.VfHit = 0
|
p.VfHit = 0
|
||||||
g.Monsters['F'-'A'].Stats.Dmg = "000x0"
|
g.Monsters['F'-'A'].Stats.Dmg = "000x0"
|
||||||
case 'L':
|
case 'L':
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func TestRollEmParsesMultiAttackDice(t *testing.T) {
|
|||||||
g := mkGame(t, 42)
|
g := mkGame(t, 42)
|
||||||
att := &Creature{Stats: Stats{Str: 16, Lvl: 20, Dmg: "1x4/1x4/1x4"}}
|
att := &Creature{Stats: Stats{Str: 16, Lvl: 20, Dmg: "1x4/1x4/1x4"}}
|
||||||
def := &Creature{Stats: Stats{Arm: 10, HP: 1000}}
|
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
|
// With attacker level 20 vs armor 10, swing always hits
|
||||||
// (rnd(20)+wplus >= (20-20)-10 is always true), so three attacks of
|
// (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.
|
// 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)
|
g := mkGame(t, 9)
|
||||||
tp := spawnAdjacent(g, 'T') // troll: 1x8/1x8/2x6
|
tp := spawnAdjacent(g, 'T') // troll: 1x8/1x8/2x6
|
||||||
tp.Stats.Lvl = 20 // always hits
|
tp.Stats.Lvl = 20 // always hits
|
||||||
tp.Flags.Clear(IsCanc)
|
tp.Flags.Clear(Cancelled)
|
||||||
hpBefore := g.Player.Stats.HP
|
hpBefore := g.Player.Stats.HP
|
||||||
g.Player.Stats.HP = 500
|
g.Player.Stats.HP = 500
|
||||||
g.Player.Stats.MaxHP = 500
|
g.Player.Stats.MaxHP = 500
|
||||||
@@ -96,7 +96,7 @@ func TestRunnersChaseHero(t *testing.T) {
|
|||||||
}
|
}
|
||||||
tp := &Monster{}
|
tp := &Monster{}
|
||||||
g.newMonster(tp, 'H', pos)
|
g.newMonster(tp, 'H', pos)
|
||||||
tp.Flags.Set(IsRun)
|
tp.Flags.Set(Awake)
|
||||||
tp.Dest = &p.Pos
|
tp.Dest = &p.Pos
|
||||||
d0 := distCp(tp.Pos, p.Pos)
|
d0 := distCp(tp.Pos, p.Pos)
|
||||||
g.runners(0)
|
g.runners(0)
|
||||||
|
|||||||
26
game/game.go
26
game/game.go
@@ -3,19 +3,19 @@ package game
|
|||||||
// ItemLore is the per-game item identity state: the randomized appearance
|
// ItemLore is the per-game item identity state: the randomized appearance
|
||||||
// names and the seven mutable ObjInfo tables (extern.c/init.c).
|
// names and the seven mutable ObjInfo tables (extern.c/init.c).
|
||||||
type ItemLore struct {
|
type ItemLore struct {
|
||||||
PotColors [MaxPotions]string // p_colors: colors of the potions
|
PotColors [NumPotionTypes]string // p_colors: colors of the potions
|
||||||
ScrNames [MaxScrolls]string // s_names: names of the scrolls
|
ScrNames [NumScrollTypes]string // s_names: names of the scrolls
|
||||||
RingStones [MaxRings]string // r_stones: stone settings of the rings
|
RingStones [NumRingTypes]string // r_stones: stone settings of the rings
|
||||||
WandMade [MaxSticks]string // ws_made: what sticks are made of
|
WandMade [NumWandTypes]string // ws_made: what sticks are made of
|
||||||
WandType [MaxSticks]string // ws_type: "wand" or "staff"
|
WandType [NumWandTypes]string // ws_type: "wand" or "staff"
|
||||||
|
|
||||||
Things [NumThings]ObjInfo
|
Things [NumThings]ObjInfo
|
||||||
Potions [MaxPotions]ObjInfo
|
Potions [NumPotionTypes]ObjInfo
|
||||||
Scrolls [MaxScrolls]ObjInfo
|
Scrolls [NumScrollTypes]ObjInfo
|
||||||
Rings [MaxRings]ObjInfo
|
Rings [NumRingTypes]ObjInfo
|
||||||
Sticks [MaxSticks]ObjInfo
|
Sticks [NumWandTypes]ObjInfo
|
||||||
Weapons [MaxWeapons + 1]ObjInfo
|
Weapons [NumWeaponTypes + 1]ObjInfo
|
||||||
Armors [MaxArmors]ObjInfo
|
Armors [NumArmorTypes]ObjInfo
|
||||||
|
|
||||||
Group int // group number for the next stack of missiles (weapons.c `group`)
|
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.FileName = cfg.Home + "/rogue.save"
|
||||||
g.rogueOpts = cfg.RogueOpts
|
g.rogueOpts = cfg.RogueOpts
|
||||||
if cfg.Wizard {
|
if cfg.Wizard {
|
||||||
g.Player.Flags.Set(SeeMonst)
|
g.Player.Flags.Set(SenseMonsters)
|
||||||
}
|
}
|
||||||
if cfg.RogueOpts != "" {
|
if cfg.RogueOpts != "" {
|
||||||
g.ParseOpts(cfg.RogueOpts)
|
g.ParseOpts(cfg.RogueOpts)
|
||||||
@@ -177,7 +177,7 @@ func NewGame(cfg Config) *RogueGame {
|
|||||||
g.Monsters = monsterTable
|
g.Monsters = monsterTable
|
||||||
g.Items.Group = 2 // weapons.c: int group = 2
|
g.Items.Group = 2 // weapons.c: int group = 2
|
||||||
for i := range g.Level.Passages {
|
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
|
g.initProbs() // set up prob tables for objects
|
||||||
|
|||||||
30
game/init.go
30
game/init.go
@@ -19,31 +19,31 @@ func (g *RogueGame) initPlayer() {
|
|||||||
// And his suit of armor
|
// And his suit of armor
|
||||||
obj = newObject()
|
obj = newObject()
|
||||||
obj.Type = Armor
|
obj.Type = Armor
|
||||||
obj.Which = RingMail
|
obj.Which = ArmorRingMail
|
||||||
obj.Arm = aClass[RingMail] - 1
|
obj.Arm = aClass[ArmorRingMail] - 1
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
obj.Count = 1
|
obj.Count = 1
|
||||||
p.CurArmor = obj
|
p.CurArmor = obj
|
||||||
g.addPack(obj, true)
|
g.addPack(obj, true)
|
||||||
// Give him his weaponry. First a mace.
|
// Give him his weaponry. First a mace.
|
||||||
obj = newObject()
|
obj = newObject()
|
||||||
g.initWeapon(obj, Mace)
|
g.initWeapon(obj, WeaponMace)
|
||||||
obj.HPlus = 1
|
obj.HPlus = 1
|
||||||
obj.DPlus = 1
|
obj.DPlus = 1
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
g.addPack(obj, true)
|
g.addPack(obj, true)
|
||||||
p.CurWeapon = obj
|
p.CurWeapon = obj
|
||||||
// Now a +1 bow
|
// Now a +1 bow
|
||||||
obj = newObject()
|
obj = newObject()
|
||||||
g.initWeapon(obj, Bow)
|
g.initWeapon(obj, WeaponBow)
|
||||||
obj.HPlus = 1
|
obj.HPlus = 1
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
g.addPack(obj, true)
|
g.addPack(obj, true)
|
||||||
// Now some arrows
|
// Now some arrows
|
||||||
obj = newObject()
|
obj = newObject()
|
||||||
g.initWeapon(obj, Arrow)
|
g.initWeapon(obj, WeaponArrow)
|
||||||
obj.Count = g.rnd(15) + 25
|
obj.Count = g.rnd(15) + 25
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
g.addPack(obj, true)
|
g.addPack(obj, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ func (g *RogueGame) initPlayer() {
|
|||||||
// (init.c init_colors).
|
// (init.c init_colors).
|
||||||
func (g *RogueGame) initColors() {
|
func (g *RogueGame) initColors() {
|
||||||
used := make([]bool, len(rainbow))
|
used := make([]bool, len(rainbow))
|
||||||
for i := 0; i < MaxPotions; i++ {
|
for i := 0; i < NumPotionTypes; i++ {
|
||||||
var j int
|
var j int
|
||||||
for {
|
for {
|
||||||
j = g.rnd(len(rainbow))
|
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).
|
// initNames generates the names of the various scrolls (init.c init_names).
|
||||||
func (g *RogueGame) initNames() {
|
func (g *RogueGame) initNames() {
|
||||||
for i := 0; i < MaxScrolls; i++ {
|
for i := 0; i < NumScrollTypes; i++ {
|
||||||
var cp strings.Builder
|
var cp strings.Builder
|
||||||
nwords := g.rnd(3) + 2
|
nwords := g.rnd(3) + 2
|
||||||
for ; nwords > 0; nwords-- {
|
for ; nwords > 0; nwords-- {
|
||||||
@@ -88,7 +88,7 @@ func (g *RogueGame) initNames() {
|
|||||||
// (init.c init_stones).
|
// (init.c init_stones).
|
||||||
func (g *RogueGame) initStones() {
|
func (g *RogueGame) initStones() {
|
||||||
used := make([]bool, len(stoneTable))
|
used := make([]bool, len(stoneTable))
|
||||||
for i := 0; i < MaxRings; i++ {
|
for i := 0; i < NumRingTypes; i++ {
|
||||||
var j int
|
var j int
|
||||||
for {
|
for {
|
||||||
j = g.rnd(len(stoneTable))
|
j = g.rnd(len(stoneTable))
|
||||||
@@ -107,7 +107,7 @@ func (g *RogueGame) initStones() {
|
|||||||
func (g *RogueGame) initMaterials() {
|
func (g *RogueGame) initMaterials() {
|
||||||
used := make([]bool, len(woods))
|
used := make([]bool, len(woods))
|
||||||
metused := make([]bool, len(metals))
|
metused := make([]bool, len(metals))
|
||||||
for i := 0; i < MaxSticks; i++ {
|
for i := 0; i < NumWandTypes; i++ {
|
||||||
var str string
|
var str string
|
||||||
for {
|
for {
|
||||||
if g.rnd(2) == 0 {
|
if g.rnd(2) == 0 {
|
||||||
@@ -156,14 +156,14 @@ func (g *RogueGame) initProbs() {
|
|||||||
sumProbs(g.Items.Scrolls[:])
|
sumProbs(g.Items.Scrolls[:])
|
||||||
sumProbs(g.Items.Rings[:])
|
sumProbs(g.Items.Rings[:])
|
||||||
sumProbs(g.Items.Sticks[:])
|
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[:])
|
sumProbs(g.Items.Armors[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// pickColor returns the given color, or a random one if the hero is
|
// pickColor returns the given color, or a random one if the hero is
|
||||||
// hallucinating (init.c pick_color).
|
// hallucinating (init.c pick_color).
|
||||||
func (g *RogueGame) pickColor(col string) string {
|
func (g *RogueGame) pickColor(col string) string {
|
||||||
if g.Player.On(IsHalu) {
|
if g.Player.On(Hallucinating) {
|
||||||
return rainbow[g.rnd(len(rainbow))]
|
return rainbow[g.rnd(len(rainbow))]
|
||||||
}
|
}
|
||||||
return col
|
return col
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ type Place struct {
|
|||||||
// Level is the current dungeon level: the map and everything on it. It is
|
// 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.
|
// reset in place by NewLevel, matching the C reuse of the global arrays.
|
||||||
type Level struct {
|
type Level struct {
|
||||||
Places [MaxLines * MaxCols]Place
|
Places [MaxLines * MaxCols]Place
|
||||||
Rooms [MaxRooms]Room
|
Rooms [MaxRooms]Room
|
||||||
Passages [MaxPass]Room // one pseudo-room per passage network
|
Passages [MaxPass]Room // one pseudo-room per passage network
|
||||||
Objects []*Object // lvl_obj: objects on this level
|
Objects []*Object // lvl_obj: objects on this level
|
||||||
Monsters []*Monster // mlist: monsters on the level
|
Monsters []*Monster // mlist: monsters on the level
|
||||||
Stairs Coord // location of the staircase
|
Stairs Coord // location of the staircase
|
||||||
NTraps int // number of traps on this level
|
TrapCount int // number of traps on this level
|
||||||
}
|
}
|
||||||
|
|
||||||
// At returns the map cell at (y, x); the C INDEX(y,x) macro, including its
|
// At returns the map cell at (y, x); the C INDEX(y,x) macro, including its
|
||||||
|
|||||||
36
game/misc.go
36
game/misc.go
@@ -36,7 +36,7 @@ func (g *RogueGame) look(wakeup bool) {
|
|||||||
if x < 0 || x >= NumCols {
|
if x < 0 || x >= NumCols {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !p.On(IsBlind) {
|
if !p.On(Blind) {
|
||||||
if y == hero.Y && x == hero.X {
|
if y == hero.Y && x == hero.X {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -49,11 +49,11 @@ func (g *RogueGame) look(wakeup bool) {
|
|||||||
}
|
}
|
||||||
fp := &pp.Flags
|
fp := &pp.Flags
|
||||||
if pch != Door && ch != Door {
|
if pch != Door && ch != Door {
|
||||||
if (pfl & FPass) != (*fp & FPass) {
|
if (pfl & FPassage) != (*fp & FPassage) {
|
||||||
continue
|
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 &&
|
if hero.X != x && hero.Y != y &&
|
||||||
!stepOk(g.Level.Char(y, hero.X)) && !stepOk(g.Level.Char(hero.Y, x)) {
|
!stepOk(g.Level.Char(y, hero.X)) && !stepOk(g.Level.Char(hero.Y, x)) {
|
||||||
continue
|
continue
|
||||||
@@ -63,7 +63,7 @@ func (g *RogueGame) look(wakeup bool) {
|
|||||||
tp := pp.Monst
|
tp := pp.Monst
|
||||||
if tp == nil {
|
if tp == nil {
|
||||||
ch = g.tripCh(y, x, ch)
|
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 {
|
if g.DoorStop && !g.Firstmove {
|
||||||
g.Running = false
|
g.Running = false
|
||||||
}
|
}
|
||||||
@@ -73,20 +73,20 @@ func (g *RogueGame) look(wakeup bool) {
|
|||||||
g.wakeMonster(y, x)
|
g.wakeMonster(y, x)
|
||||||
}
|
}
|
||||||
if g.seeMonst(tp) {
|
if g.seeMonst(tp) {
|
||||||
if p.On(IsHalu) {
|
if p.On(Hallucinating) {
|
||||||
ch = byte(g.rnd(26) + 'A')
|
ch = byte(g.rnd(26) + 'A')
|
||||||
} else {
|
} else {
|
||||||
ch = tp.Disguise
|
ch = tp.Disguise
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.On(IsBlind) && (y != hero.Y || x != hero.X) {
|
if p.On(Blind) && (y != hero.Y || x != hero.X) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
g.move(y, x)
|
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 = ' '
|
ch = ' '
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ func (g *RogueGame) look(wakeup bool) {
|
|||||||
// tripCh returns the character for this space, taking into account whether
|
// tripCh returns the character for this space, taking into account whether
|
||||||
// or not the player is tripping (misc.c trip_ch).
|
// or not the player is tripping (misc.c trip_ch).
|
||||||
func (g *RogueGame) tripCh(y, x int, ch byte) byte {
|
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 {
|
switch ch {
|
||||||
case Floor, ' ', Passage, '-', '|', Door, Trap:
|
case Floor, ' ', Passage, '-', '|', Door, Trap:
|
||||||
default:
|
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
|
// eraseLamp erases the area shown by a lamp in a dark room
|
||||||
// (misc.c erase_lamp).
|
// (misc.c erase_lamp).
|
||||||
func (g *RogueGame) eraseLamp(pos Coord, rp *Room) {
|
func (g *RogueGame) eraseLamp(pos Coord, rp *Room) {
|
||||||
if !(g.Options.SeeFloor && rp.Flags&(IsGone|IsDark) == IsDark &&
|
if !(g.Options.SeeFloor && rp.Flags&(Gone|Dark) == Dark &&
|
||||||
!g.Player.On(IsBlind)) {
|
!g.Player.On(Blind)) {
|
||||||
return
|
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
|
// showFloor reports whether we show the floor in her room at this time
|
||||||
// (misc.c show_floor).
|
// (misc.c show_floor).
|
||||||
func (g *RogueGame) showFloor() bool {
|
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 g.Options.SeeFloor
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@@ -278,10 +278,10 @@ func (g *RogueGame) chgStr(amt int) {
|
|||||||
p := &g.Player
|
p := &g.Player
|
||||||
addStr(&p.Stats.Str, amt)
|
addStr(&p.Stats.Str, amt)
|
||||||
comp := p.Stats.Str
|
comp := p.Stats.Str
|
||||||
if p.IsRing(Left, RAddStr) {
|
if p.IsRing(Left, RingAddStrength) {
|
||||||
addStr(&comp, -p.CurRing[Left].Arm)
|
addStr(&comp, -p.CurRing[Left].Arm)
|
||||||
}
|
}
|
||||||
if p.IsRing(Right, RAddStr) {
|
if p.IsRing(Right, RingAddStrength) {
|
||||||
addStr(&comp, -p.CurRing[Right].Arm)
|
addStr(&comp, -p.CurRing[Right].Arm)
|
||||||
}
|
}
|
||||||
if comp > p.MaxStats.Str {
|
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).
|
// addHaste adds a haste to the player (misc.c add_haste).
|
||||||
func (g *RogueGame) addHaste(potion bool) bool {
|
func (g *RogueGame) addHaste(potion bool) bool {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
if p.On(IsHaste) {
|
if p.On(Hasted) {
|
||||||
g.NoCommand += g.rnd(8)
|
g.NoCommand += g.rnd(8)
|
||||||
p.Flags.Clear(IsRun | IsHaste)
|
p.Flags.Clear(Awake | Hasted)
|
||||||
g.Extinguish(DNohaste)
|
g.Extinguish(DNohaste)
|
||||||
g.msg("you faint from exhaustion")
|
g.msg("you faint from exhaustion")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
p.Flags.Set(IsHaste)
|
p.Flags.Set(Hasted)
|
||||||
if potion {
|
if potion {
|
||||||
g.Fuse(DNohaste, 0, g.rnd(4)+4, After)
|
g.Fuse(DNohaste, 0, g.rnd(4)+4, After)
|
||||||
}
|
}
|
||||||
@@ -403,7 +403,7 @@ func (g *RogueGame) getDir() bool {
|
|||||||
g.LastDir = g.DirCh
|
g.LastDir = g.DirCh
|
||||||
g.lastDelt = g.Delta
|
g.lastDelt = g.Delta
|
||||||
}
|
}
|
||||||
if g.Player.On(IsHuh) && g.rnd(5) == 0 {
|
if g.Player.On(Confused) && g.rnd(5) == 0 {
|
||||||
for {
|
for {
|
||||||
g.Delta.Y = g.rnd(3) - 1
|
g.Delta.Y = g.rnd(3) - 1
|
||||||
g.Delta.X = 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
|
// chooseStr picks the first or second string depending on whether the
|
||||||
// player is tripping (misc.c choose_str).
|
// player is tripping (misc.c choose_str).
|
||||||
func (g *RogueGame) chooseStr(ts, ns string) string {
|
func (g *RogueGame) chooseStr(ts, ns string) string {
|
||||||
if g.Player.On(IsHalu) {
|
if g.Player.On(Hallucinating) {
|
||||||
return ts
|
return ts
|
||||||
}
|
}
|
||||||
return ns
|
return ns
|
||||||
|
|||||||
@@ -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.Stats.Exp = mp.Stats.Exp + levAdd*10 + expAdd(tp)
|
||||||
tp.Flags = mp.Flags
|
tp.Flags = mp.Flags
|
||||||
if g.Depth > 29 {
|
if g.Depth > 29 {
|
||||||
tp.Flags.Set(IsHaste)
|
tp.Flags.Set(Hasted)
|
||||||
}
|
}
|
||||||
tp.Turn = true
|
tp.Turn = true
|
||||||
tp.Pack = nil
|
tp.Pack = nil
|
||||||
if g.Player.IsWearing(RAggr) {
|
if g.Player.IsWearing(RingAggravateMonsters) {
|
||||||
g.runto(cp)
|
g.runto(cp)
|
||||||
}
|
}
|
||||||
if typ == 'X' {
|
if typ == 'X' {
|
||||||
@@ -101,9 +101,9 @@ func (g *RogueGame) wanderer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.newMonster(tp, g.randMonster(true), cp)
|
g.newMonster(tp, g.randMonster(true), cp)
|
||||||
if g.Player.On(SeeMonst) {
|
if g.Player.On(SenseMonsters) {
|
||||||
g.standout()
|
g.standout()
|
||||||
if !g.Player.On(IsHalu) {
|
if !g.Player.On(Hallucinating) {
|
||||||
g.addch(tp.Type)
|
g.addch(tp.Type)
|
||||||
} else {
|
} else {
|
||||||
g.addch(byte(g.rnd(26) + 'A'))
|
g.addch(byte(g.rnd(26) + 'A'))
|
||||||
@@ -123,24 +123,24 @@ func (g *RogueGame) wakeMonster(y, x int) *Monster {
|
|||||||
}
|
}
|
||||||
ch := tp.Type
|
ch := tp.Type
|
||||||
// Every time he sees a mean monster, it might start chasing him
|
// 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) &&
|
if !tp.On(Awake) && g.rnd(3) != 0 && tp.On(Mean) && !tp.On(Held) &&
|
||||||
!p.IsWearing(RStealth) && !p.On(IsLevit) {
|
!p.IsWearing(RingStealth) && !p.On(Levitating) {
|
||||||
tp.Dest = &p.Pos
|
tp.Dest = &p.Pos
|
||||||
tp.Flags.Set(IsRun)
|
tp.Flags.Set(Awake)
|
||||||
}
|
}
|
||||||
if ch == 'M' && !p.On(IsBlind) && !p.On(IsHalu) &&
|
if ch == 'M' && !p.On(Blind) && !p.On(Hallucinating) &&
|
||||||
!tp.On(IsFound) && !tp.On(IsCanc) && tp.On(IsRun) {
|
!tp.On(Found) && !tp.On(Cancelled) && tp.On(Awake) {
|
||||||
rp := p.Room
|
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 {
|
distance(y, x, p.Pos.Y, p.Pos.X) < LampDist {
|
||||||
tp.Flags.Set(IsFound)
|
tp.Flags.Set(Found)
|
||||||
if !g.save(VsMagic) {
|
if !g.save(VsMagic) {
|
||||||
if p.On(IsHuh) {
|
if p.On(Confused) {
|
||||||
g.Lengthen(DUnconfuse, g.spread(HuhDuration))
|
g.Lengthen(DUnconfuse, g.spread(HuhDuration))
|
||||||
} else {
|
} else {
|
||||||
g.Fuse(DUnconfuse, 0, g.spread(HuhDuration), After)
|
g.Fuse(DUnconfuse, 0, g.spread(HuhDuration), After)
|
||||||
}
|
}
|
||||||
p.Flags.Set(IsHuh)
|
p.Flags.Set(Confused)
|
||||||
mname := g.setMname(tp)
|
mname := g.setMname(tp)
|
||||||
g.addmsg("%s", mname)
|
g.addmsg("%s", mname)
|
||||||
if mname != "it" {
|
if mname != "it" {
|
||||||
@@ -151,8 +151,8 @@ func (g *RogueGame) wakeMonster(y, x int) *Monster {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Let greedy ones guard gold
|
// Let greedy ones guard gold
|
||||||
if tp.On(IsGreed) && !tp.On(IsRun) {
|
if tp.On(Greedy) && !tp.On(Awake) {
|
||||||
tp.Flags.Set(IsRun)
|
tp.Flags.Set(Awake)
|
||||||
if p.Room.GoldVal != 0 {
|
if p.Room.GoldVal != 0 {
|
||||||
tp.Dest = &p.Room.Gold
|
tp.Dest = &p.Room.Gold
|
||||||
} else {
|
} else {
|
||||||
@@ -182,10 +182,10 @@ func (g *RogueGame) saveThrow(which int, st *Stats) bool {
|
|||||||
func (g *RogueGame) save(which int) bool {
|
func (g *RogueGame) save(which int) bool {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
if which == VsMagic {
|
if which == VsMagic {
|
||||||
if p.IsRing(Left, RProtect) {
|
if p.IsRing(Left, RingProtection) {
|
||||||
which -= p.CurRing[Left].Arm
|
which -= p.CurRing[Left].Arm
|
||||||
}
|
}
|
||||||
if p.IsRing(Right, RProtect) {
|
if p.IsRing(Right, RingProtection) {
|
||||||
which -= p.CurRing[Right].Arm
|
which -= p.CurRing[Right].Arm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
54
game/move.go
54
game/move.go
@@ -21,7 +21,7 @@ func (g *RogueGame) doMove(dy, dx int) {
|
|||||||
}
|
}
|
||||||
// Do a confused move (maybe)
|
// Do a confused move (maybe)
|
||||||
var nh Coord
|
var nh Coord
|
||||||
if p.On(IsHuh) && g.rnd(5) != 0 {
|
if p.On(Confused) && g.rnd(5) != 0 {
|
||||||
nh = g.rndmove(&p.Creature)
|
nh = g.rndmove(&p.Creature)
|
||||||
if nh == p.Pos {
|
if nh == p.Pos {
|
||||||
g.After = false
|
g.After = false
|
||||||
@@ -52,12 +52,12 @@ over:
|
|||||||
fl = *g.Level.FlagsAt(nh.Y, nh.X)
|
fl = *g.Level.FlagsAt(nh.Y, nh.X)
|
||||||
ch = g.Level.VisibleChar(nh.Y, nh.X)
|
ch = g.Level.VisibleChar(nh.Y, nh.X)
|
||||||
if !fl.Has(FReal) && ch == Floor {
|
if !fl.Has(FReal) && ch == Floor {
|
||||||
if !p.On(IsLevit) {
|
if !p.On(Levitating) {
|
||||||
ch = Trap
|
ch = Trap
|
||||||
g.Level.SetChar(nh.Y, nh.X, Trap)
|
g.Level.SetChar(nh.Y, nh.X, Trap)
|
||||||
g.Level.FlagsAt(nh.Y, nh.X).Set(FReal)
|
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")
|
g.msg("you are being held")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -67,8 +67,8 @@ over:
|
|||||||
}
|
}
|
||||||
switch ch {
|
switch ch {
|
||||||
case ' ', '|', '-':
|
case ' ', '|', '-':
|
||||||
if g.Options.PassGo && g.Running && p.Room.Flags.Has(IsGone) &&
|
if g.Options.PassGo && g.Running && p.Room.Flags.Has(Gone) &&
|
||||||
!p.On(IsBlind) {
|
!p.On(Blind) {
|
||||||
var b1, b2 bool
|
var b1, b2 bool
|
||||||
switch g.RunCh {
|
switch g.RunCh {
|
||||||
case 'h', 'l':
|
case 'h', 'l':
|
||||||
@@ -109,13 +109,13 @@ over:
|
|||||||
g.After = false
|
g.After = false
|
||||||
case Door:
|
case Door:
|
||||||
g.Running = false
|
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.enterRoom(nh)
|
||||||
}
|
}
|
||||||
g.moveStuff(nh, fl)
|
g.moveStuff(nh, fl)
|
||||||
case Trap:
|
case Trap:
|
||||||
tr := g.beTrapped(nh)
|
tr := g.beTrapped(nh)
|
||||||
if tr == TDoor || tr == TTelep {
|
if tr == TrapDoor || tr == TrapTeleport {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
g.moveStuff(nh, fl)
|
g.moveStuff(nh, fl)
|
||||||
@@ -151,7 +151,7 @@ over:
|
|||||||
func (g *RogueGame) moveStuff(nh Coord, fl PlaceFlags) {
|
func (g *RogueGame) moveStuff(nh Coord, fl PlaceFlags) {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorAt())
|
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)
|
g.leaveRoom(nh)
|
||||||
}
|
}
|
||||||
p.Pos = nh
|
p.Pos = nh
|
||||||
@@ -161,7 +161,7 @@ func (g *RogueGame) moveStuff(nh Coord, fl PlaceFlags) {
|
|||||||
// (move.c turn_ok).
|
// (move.c turn_ok).
|
||||||
func (g *RogueGame) turnOk(y, x int) bool {
|
func (g *RogueGame) turnOk(y, x int) bool {
|
||||||
pp := g.Level.At(y, x)
|
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).
|
// 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
|
// doorOpen is called to wake up things in a room that might move when the
|
||||||
// hero enters (move.c door_open).
|
// hero enters (move.c door_open).
|
||||||
func (g *RogueGame) doorOpen(rp *Room) {
|
func (g *RogueGame) doorOpen(rp *Room) {
|
||||||
if rp.Flags.Has(IsGone) {
|
if rp.Flags.Has(Gone) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for y := rp.Pos.Y; y < rp.Pos.Y+rp.Max.Y; y++ {
|
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).
|
// beTrapped makes him pay for stepping on a trap (move.c be_trapped).
|
||||||
func (g *RogueGame) beTrapped(tc Coord) int {
|
func (g *RogueGame) beTrapped(tc Coord) int {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
if p.On(IsLevit) {
|
if p.On(Levitating) {
|
||||||
return TRust // anything that's not a door or teleport
|
return TrapRust // anything that's not a door or teleport
|
||||||
}
|
}
|
||||||
g.Running = false
|
g.Running = false
|
||||||
g.Count = 0
|
g.Count = 0
|
||||||
pp := g.Level.At(tc.Y, tc.X)
|
pp := g.Level.At(tc.Y, tc.X)
|
||||||
pp.Ch = Trap
|
pp.Ch = Trap
|
||||||
tr := int(pp.Flags & FTMask)
|
tr := int(pp.Flags & FTrapMask)
|
||||||
pp.Flags.Set(FSeen)
|
pp.Flags.Set(FSeen)
|
||||||
switch tr {
|
switch tr {
|
||||||
case TDoor:
|
case TrapDoor:
|
||||||
g.Depth++
|
g.Depth++
|
||||||
g.NewLevel()
|
g.NewLevel()
|
||||||
g.msg("you fell into a trap!")
|
g.msg("you fell into a trap!")
|
||||||
case TBear:
|
case TrapBear:
|
||||||
g.NoMove += g.spread(3) // BEARTIME
|
g.NoMove += g.spread(3) // BEARTIME
|
||||||
g.msg("you are caught in a bear trap")
|
g.msg("you are caught in a bear trap")
|
||||||
case TMyst:
|
case TrapMystery:
|
||||||
switch g.rnd(11) {
|
switch g.rnd(11) {
|
||||||
case 0:
|
case 0:
|
||||||
g.msg("you are suddenly in a parallel dimension")
|
g.msg("you are suddenly in a parallel dimension")
|
||||||
@@ -236,11 +236,11 @@ func (g *RogueGame) beTrapped(tc Coord) int {
|
|||||||
case 10:
|
case 10:
|
||||||
g.msg("you pack turns %s!", rainbow[g.rnd(len(rainbow))])
|
g.msg("you pack turns %s!", rainbow[g.rnd(len(rainbow))])
|
||||||
}
|
}
|
||||||
case TSleep:
|
case TrapSleep:
|
||||||
g.NoCommand += g.spread(5) // SLEEPTIME
|
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")
|
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) {
|
if g.swing(p.Stats.Lvl-1, p.Stats.Arm, 1) {
|
||||||
p.Stats.HP -= g.roll(1, 6)
|
p.Stats.HP -= g.roll(1, 6)
|
||||||
if p.Stats.HP <= 0 {
|
if p.Stats.HP <= 0 {
|
||||||
@@ -251,18 +251,18 @@ func (g *RogueGame) beTrapped(tc Coord) int {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
arrow := newObject()
|
arrow := newObject()
|
||||||
g.initWeapon(arrow, Arrow)
|
g.initWeapon(arrow, WeaponArrow)
|
||||||
arrow.Count = 1
|
arrow.Count = 1
|
||||||
arrow.Pos = p.Pos
|
arrow.Pos = p.Pos
|
||||||
g.fall(arrow, false)
|
g.fall(arrow, false)
|
||||||
g.msg("an arrow shoots past you")
|
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,
|
// since the hero's leaving, look() won't put a TRAP down for us,
|
||||||
// so we have to do it ourself
|
// so we have to do it ourself
|
||||||
g.teleport()
|
g.teleport()
|
||||||
g.mvaddch(tc.Y, tc.X, Trap)
|
g.mvaddch(tc.Y, tc.X, Trap)
|
||||||
case TDart:
|
case TrapDart:
|
||||||
if !g.swing(p.Stats.Lvl+1, p.Stats.Arm, 1) {
|
if !g.swing(p.Stats.Lvl+1, p.Stats.Arm, 1) {
|
||||||
g.msg("a small dart whizzes by your ear and vanishes")
|
g.msg("a small dart whizzes by your ear and vanishes")
|
||||||
} else {
|
} else {
|
||||||
@@ -271,12 +271,12 @@ func (g *RogueGame) beTrapped(tc Coord) int {
|
|||||||
g.msg("a poisoned dart killed you")
|
g.msg("a poisoned dart killed you")
|
||||||
g.death('d')
|
g.death('d')
|
||||||
}
|
}
|
||||||
if !p.IsWearing(RSustStr) && !g.save(VsPoison) {
|
if !p.IsWearing(RingSustainStrength) && !g.save(VsPoison) {
|
||||||
g.chgStr(-1)
|
g.chgStr(-1)
|
||||||
}
|
}
|
||||||
g.msg("a small dart just hit you in the shoulder")
|
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.msg("a gush of water hits you on the head")
|
||||||
g.rustArmor(p.CurArmor)
|
g.rustArmor(p.CurArmor)
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ func (g *RogueGame) rndmove(who *Creature) Coord {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if found != nil && found.Which == SScare {
|
if found != nil && found.Which == ScrollScareMonster {
|
||||||
return who.Pos
|
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
|
// 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).
|
// aren't wearing a magic ring (move.c rust_armor).
|
||||||
func (g *RogueGame) rustArmor(arm *Object) {
|
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 {
|
arm.Arm >= 9 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if arm.Flags.Has(IsProt) || g.Player.IsWearing(RSustArm) {
|
if arm.Flags.Has(Protected) || g.Player.IsWearing(RingMaintainArmor) {
|
||||||
if !g.ToDeath {
|
if !g.ToDeath {
|
||||||
g.msg("the rust vanishes instantly")
|
g.msg("the rust vanishes instantly")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const (
|
|||||||
// NewLevel digs and draws a new level (new_level.c new_level).
|
// NewLevel digs and draws a new level (new_level.c new_level).
|
||||||
func (g *RogueGame) NewLevel() {
|
func (g *RogueGame) NewLevel() {
|
||||||
p := &g.Player
|
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 {
|
if g.Depth > g.MaxDepth {
|
||||||
g.MaxDepth = g.Depth
|
g.MaxDepth = g.Depth
|
||||||
}
|
}
|
||||||
@@ -31,11 +31,11 @@ func (g *RogueGame) NewLevel() {
|
|||||||
g.putThings() // Place objects (if any)
|
g.putThings() // Place objects (if any)
|
||||||
// Place the traps
|
// Place the traps
|
||||||
if g.rnd(10) < g.Depth {
|
if g.rnd(10) < g.Depth {
|
||||||
g.Level.NTraps = g.rnd(g.Depth/4) + 1
|
g.Level.TrapCount = g.rnd(g.Depth/4) + 1
|
||||||
if g.Level.NTraps > MaxTraps {
|
if g.Level.TrapCount > MaxTraps {
|
||||||
g.Level.NTraps = 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
|
// not only wouldn't it be NICE to have traps in mazes (not
|
||||||
// that we care about being nice), since the trap number is
|
// that we care about being nice), since the trap number is
|
||||||
// stored where the passage number is, we can't actually do it.
|
// 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 := g.Level.FlagsAt(stairs.Y, stairs.X)
|
||||||
sp.Clear(FReal)
|
sp.Clear(FReal)
|
||||||
*sp |= PlaceFlags(g.rnd(NTraps))
|
*sp |= PlaceFlags(g.rnd(NumTrapTypes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Place the staircase down.
|
// Place the staircase down.
|
||||||
@@ -65,10 +65,10 @@ func (g *RogueGame) NewLevel() {
|
|||||||
p.Pos = hero
|
p.Pos = hero
|
||||||
g.enterRoom(hero)
|
g.enterRoom(hero)
|
||||||
g.mvaddch(hero.Y, hero.X, PlayerCh)
|
g.mvaddch(hero.Y, hero.X, PlayerCh)
|
||||||
if p.On(SeeMonst) {
|
if p.On(SenseMonsters) {
|
||||||
g.turnSee(false)
|
g.turnSee(false)
|
||||||
}
|
}
|
||||||
if p.On(IsHalu) {
|
if p.On(Hallucinating) {
|
||||||
g.visuals(0)
|
g.visuals(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ func (g *RogueGame) NewLevel() {
|
|||||||
func (g *RogueGame) rndRoom() int {
|
func (g *RogueGame) rndRoom() int {
|
||||||
for {
|
for {
|
||||||
rm := g.rnd(MaxRooms)
|
rm := g.rnd(MaxRooms)
|
||||||
if !g.Level.Rooms[rm].Flags.Has(IsGone) {
|
if !g.Level.Rooms[rm].Flags.Has(Gone) {
|
||||||
return rm
|
return rm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ func (g *RogueGame) treasRoom() {
|
|||||||
if mp, ok := g.findFloorIn(rp, maxTries, true); ok {
|
if mp, ok := g.findFloorIn(rp, maxTries, true); ok {
|
||||||
tp := &Monster{}
|
tp := &Monster{}
|
||||||
g.newMonster(tp, g.randMonster(false), mp)
|
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)
|
g.givePack(tp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,10 +86,10 @@ func TestNewLevelInvariants(t *testing.T) {
|
|||||||
t.Errorf("seed %d: starting pack has %d items, want 5",
|
t.Errorf("seed %d: starting pack has %d items, want 5",
|
||||||
seed, len(g.Player.Pack))
|
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)
|
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)
|
t.Errorf("seed %d: not wearing the starting ring mail", seed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
game/pack.go
14
game/pack.go
@@ -15,10 +15,10 @@ func (g *RogueGame) addPack(obj *Object, silent bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for and deal with scare monster scrolls
|
// 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)
|
detachObj(&g.Level.Objects, obj)
|
||||||
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorCh())
|
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)
|
g.Level.SetChar(p.Pos.Y, p.Pos.X, Passage)
|
||||||
} else {
|
} else {
|
||||||
g.Level.SetChar(p.Pos.Y, p.Pos.X, Floor)
|
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
|
// If this was the object of something's desire, that monster will get
|
||||||
// mad and run at the hero.
|
// mad and run at the hero.
|
||||||
@@ -146,7 +146,7 @@ func (g *RogueGame) packRoom(fromFloor bool, obj *Object) bool {
|
|||||||
if fromFloor {
|
if fromFloor {
|
||||||
detachObj(&g.Level.Objects, obj)
|
detachObj(&g.Level.Objects, obj)
|
||||||
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorCh())
|
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)
|
g.Level.SetChar(p.Pos.Y, p.Pos.X, Passage)
|
||||||
} else {
|
} else {
|
||||||
g.Level.SetChar(p.Pos.Y, p.Pos.X, Floor)
|
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).
|
// pickUp adds something to the character's pack (pack.c pick_up).
|
||||||
func (g *RogueGame) pickUp(ch byte) {
|
func (g *RogueGame) pickUp(ch byte) {
|
||||||
p := &g.Player
|
p := &g.Player
|
||||||
if p.On(IsLevit) {
|
if p.On(Levitating) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ func (g *RogueGame) money(value int) {
|
|||||||
p := &g.Player
|
p := &g.Player
|
||||||
p.Purse += value
|
p.Purse += value
|
||||||
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorCh())
|
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)
|
g.Level.SetChar(p.Pos.Y, p.Pos.X, Passage)
|
||||||
} else {
|
} else {
|
||||||
g.Level.SetChar(p.Pos.Y, p.Pos.X, Floor)
|
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
|
// floorCh returns the appropriate floor character for her room
|
||||||
// (pack.c floor_ch).
|
// (pack.c floor_ch).
|
||||||
func (g *RogueGame) floorCh() byte {
|
func (g *RogueGame) floorCh() byte {
|
||||||
if g.Player.Room.Flags.Has(IsGone) {
|
if g.Player.Room.Flags.Has(Gone) {
|
||||||
return Passage
|
return Passage
|
||||||
}
|
}
|
||||||
if g.showFloor() {
|
if g.showFloor() {
|
||||||
|
|||||||
@@ -110,24 +110,24 @@ func (g *RogueGame) conn(r1, r2 int) {
|
|||||||
var del, turnDelta, spos, epos Coord
|
var del, turnDelta, spos, epos Coord
|
||||||
var distance, turnDistance int
|
var distance, turnDistance int
|
||||||
if direc == 'd' {
|
if direc == 'd' {
|
||||||
rmt := rm + 3 // room # of dest
|
rmt := rm + 3 // room # of dest
|
||||||
rpt = &g.Level.Rooms[rmt] // room pointer of dest
|
rpt = &g.Level.Rooms[rmt] // room pointer of dest
|
||||||
del = Coord{X: 0, Y: 1} // direction of move
|
del = Coord{X: 0, Y: 1} // direction of move
|
||||||
spos = rpf.Pos // start of move
|
spos = rpf.Pos // start of move
|
||||||
epos = rpt.Pos // end of move
|
epos = rpt.Pos // end of move
|
||||||
if !rpf.Flags.Has(IsGone) { // if not gone pick door pos
|
if !rpf.Flags.Has(Gone) { // if not gone pick door pos
|
||||||
for {
|
for {
|
||||||
spos.X = rpf.Pos.X + g.rnd(rpf.Max.X-2) + 1
|
spos.X = rpf.Pos.X + g.rnd(rpf.Max.X-2) + 1
|
||||||
spos.Y = rpf.Pos.Y + rpf.Max.Y - 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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !rpt.Flags.Has(IsGone) {
|
if !rpt.Flags.Has(Gone) {
|
||||||
for {
|
for {
|
||||||
epos.X = rpt.Pos.X + g.rnd(rpt.Max.X-2) + 1
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,19 +146,19 @@ func (g *RogueGame) conn(r1, r2 int) {
|
|||||||
del = Coord{X: 1, Y: 0}
|
del = Coord{X: 1, Y: 0}
|
||||||
spos = rpf.Pos
|
spos = rpf.Pos
|
||||||
epos = rpt.Pos
|
epos = rpt.Pos
|
||||||
if !rpf.Flags.Has(IsGone) {
|
if !rpf.Flags.Has(Gone) {
|
||||||
for {
|
for {
|
||||||
spos.X = rpf.Pos.X + rpf.Max.X - 1
|
spos.X = rpf.Pos.X + rpf.Max.X - 1
|
||||||
spos.Y = rpf.Pos.Y + g.rnd(rpf.Max.Y-2) + 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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !rpt.Flags.Has(IsGone) {
|
if !rpt.Flags.Has(Gone) {
|
||||||
for {
|
for {
|
||||||
epos.Y = rpt.Pos.Y + g.rnd(rpt.Max.Y-2) + 1
|
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
|
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
|
// Draw in the doors on either side of the passage or just put #'s if
|
||||||
// the rooms are gone.
|
// the rooms are gone.
|
||||||
if !rpf.Flags.Has(IsGone) {
|
if !rpf.Flags.Has(Gone) {
|
||||||
g.door(rpf, spos)
|
g.door(rpf, spos)
|
||||||
} else {
|
} else {
|
||||||
g.putpass(spos)
|
g.putpass(spos)
|
||||||
}
|
}
|
||||||
if !rpt.Flags.Has(IsGone) {
|
if !rpt.Flags.Has(Gone) {
|
||||||
g.door(rpt, epos)
|
g.door(rpt, epos)
|
||||||
} else {
|
} else {
|
||||||
g.putpass(epos)
|
g.putpass(epos)
|
||||||
@@ -216,7 +216,7 @@ func (g *RogueGame) conn(r1, r2 int) {
|
|||||||
// putpass).
|
// putpass).
|
||||||
func (g *RogueGame) putpass(cp Coord) {
|
func (g *RogueGame) putpass(cp Coord) {
|
||||||
pp := g.Level.At(cp.Y, cp.X)
|
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 {
|
if g.rnd(10)+1 < g.Depth && g.rnd(40) == 0 {
|
||||||
pp.Flags.Clear(FReal)
|
pp.Flags.Clear(FReal)
|
||||||
} else {
|
} else {
|
||||||
@@ -229,7 +229,7 @@ func (g *RogueGame) putpass(cp Coord) {
|
|||||||
func (g *RogueGame) door(rm *Room, cp Coord) {
|
func (g *RogueGame) door(rm *Room, cp Coord) {
|
||||||
rm.Exits = append(rm.Exits, cp)
|
rm.Exits = append(rm.Exits, cp)
|
||||||
|
|
||||||
if rm.Flags.Has(IsMaze) {
|
if rm.Flags.Has(Maze) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,10 +252,10 @@ func (g *RogueGame) addPass() {
|
|||||||
for y := 1; y < NumLines-1; y++ {
|
for y := 1; y < NumLines-1; y++ {
|
||||||
for x := 0; x < NumCols; x++ {
|
for x := 0; x < NumCols; x++ {
|
||||||
pp := g.Level.At(y, 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 == '-')) {
|
(!pp.Flags.Has(FReal) && (pp.Ch == '|' || pp.Ch == '-')) {
|
||||||
ch := pp.Ch
|
ch := pp.Ch
|
||||||
if pp.Flags.Has(FPass) {
|
if pp.Flags.Has(FPassage) {
|
||||||
ch = Passage
|
ch = Passage
|
||||||
}
|
}
|
||||||
pp.Flags.Set(FSeen)
|
pp.Flags.Set(FSeen)
|
||||||
@@ -266,7 +266,7 @@ func (g *RogueGame) addPass() {
|
|||||||
g.addch(ch)
|
g.addch(ch)
|
||||||
} else {
|
} else {
|
||||||
g.standout()
|
g.standout()
|
||||||
if pp.Flags.Has(FPass) {
|
if pp.Flags.Has(FPassage) {
|
||||||
g.addch(Passage)
|
g.addch(Passage)
|
||||||
} else {
|
} else {
|
||||||
g.addch(Door)
|
g.addch(Door)
|
||||||
@@ -301,7 +301,7 @@ func (g *RogueGame) numpass(y, x int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
fp := g.Level.FlagsAt(y, x)
|
fp := g.Level.FlagsAt(y, x)
|
||||||
if fp.Has(FPNum) {
|
if fp.Has(FPassNum) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if g.newpnum {
|
if g.newpnum {
|
||||||
@@ -314,7 +314,7 @@ func (g *RogueGame) numpass(y, x int) {
|
|||||||
(!fp.Has(FReal) && (ch == '|' || ch == '-')) {
|
(!fp.Has(FReal) && (ch == '|' || ch == '-')) {
|
||||||
rp := &g.Level.Passages[g.pnum]
|
rp := &g.Level.Passages[g.pnum]
|
||||||
rp.Exits = append(rp.Exits, Coord{Y: y, X: x})
|
rp.Exits = append(rp.Exits, Coord{Y: y, X: x})
|
||||||
} else if !fp.Has(FPass) {
|
} else if !fp.Has(FPassage) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
*fp |= PlaceFlags(g.pnum)
|
*fp |= PlaceFlags(g.pnum)
|
||||||
|
|||||||
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
|
// pActions is potions.c p_actions[]. The P_SEEINVIS message is dynamic
|
||||||
// (it names the fruit) and is computed in doPot.
|
// (it names the fruit) and is computed in doPot.
|
||||||
var pActions = [MaxPotions]pact{
|
var pActions = [NumPotionTypes]pact{
|
||||||
PConfuse: {IsHuh, DUnconfuse, HuhDuration,
|
PotionConfusion: {Confused, DUnconfuse, HuhDuration,
|
||||||
"what a tripy feeling!",
|
"what a tripy feeling!",
|
||||||
"wait, what's going on here. Huh? What? Who?"},
|
"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!",
|
||||||
"Oh, wow! Everything seems so cosmic!"},
|
"Oh, wow! Everything seems so cosmic!"},
|
||||||
PSeeInvis: {CanSee, DUnsee, SeeDuration, "", ""},
|
PotionSeeInvisible: {CanSeeInvisible, DUnsee, SeeDuration, "", ""},
|
||||||
PBlind: {IsBlind, DSight, SeeDuration,
|
PotionBlindness: {Blind, DSight, SeeDuration,
|
||||||
"oh, bummer! Everything is dark! Help!",
|
"oh, bummer! Everything is dark! Help!",
|
||||||
"a cloak of darkness falls around you"},
|
"a cloak of darkness falls around you"},
|
||||||
PLevit: {IsLevit, DLand, HealTime,
|
PotionLevitation: {Levitating, DLand, HealTime,
|
||||||
"oh, wow! You're floating in the air!",
|
"oh, wow! You're floating in the air!",
|
||||||
"you start to float 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.
|
// Calculate the effect it has on the poor guy.
|
||||||
trip := p.On(IsHalu)
|
trip := p.On(Hallucinating)
|
||||||
g.leavePack(obj, false, false)
|
g.leavePack(obj, false, false)
|
||||||
switch obj.Which {
|
switch obj.Which {
|
||||||
case PConfuse:
|
case PotionConfusion:
|
||||||
g.doPot(PConfuse, !trip)
|
g.doPot(PotionConfusion, !trip)
|
||||||
case PPoison:
|
case PotionPoison:
|
||||||
g.Items.Potions[PPoison].Know = true
|
g.Items.Potions[PotionPoison].Know = true
|
||||||
if p.IsWearing(RSustStr) {
|
if p.IsWearing(RingSustainStrength) {
|
||||||
g.msg("you feel momentarily sick")
|
g.msg("you feel momentarily sick")
|
||||||
} else {
|
} else {
|
||||||
g.chgStr(-(g.rnd(3) + 1))
|
g.chgStr(-(g.rnd(3) + 1))
|
||||||
g.msg("you feel very sick now")
|
g.msg("you feel very sick now")
|
||||||
g.comeDown(0)
|
g.comeDown(0)
|
||||||
}
|
}
|
||||||
case PHealing:
|
case PotionHealing:
|
||||||
g.Items.Potions[PHealing].Know = true
|
g.Items.Potions[PotionHealing].Know = true
|
||||||
if p.Stats.HP += g.roll(p.Stats.Lvl, 4); p.Stats.HP > p.Stats.MaxHP {
|
if p.Stats.HP += g.roll(p.Stats.Lvl, 4); p.Stats.HP > p.Stats.MaxHP {
|
||||||
p.Stats.MaxHP++
|
p.Stats.MaxHP++
|
||||||
p.Stats.HP = p.Stats.MaxHP
|
p.Stats.HP = p.Stats.MaxHP
|
||||||
}
|
}
|
||||||
g.sight(0)
|
g.sight(0)
|
||||||
g.msg("you begin to feel better")
|
g.msg("you begin to feel better")
|
||||||
case PStrength:
|
case PotionGainStrength:
|
||||||
g.Items.Potions[PStrength].Know = true
|
g.Items.Potions[PotionGainStrength].Know = true
|
||||||
g.chgStr(1)
|
g.chgStr(1)
|
||||||
g.msg("you feel stronger, now. What bulging muscles!")
|
g.msg("you feel stronger, now. What bulging muscles!")
|
||||||
case PMFind:
|
case PotionDetectMonsters:
|
||||||
p.Flags.Set(SeeMonst)
|
p.Flags.Set(SenseMonsters)
|
||||||
g.Fuse(DTurnSee, 1, HuhDuration, After)
|
g.Fuse(DTurnSee, 1, HuhDuration, After)
|
||||||
if !g.turnSee(false) {
|
if !g.turnSee(false) {
|
||||||
g.msg("you have a %s feeling for a moment, then it passes",
|
g.msg("you have a %s feeling for a moment, then it passes",
|
||||||
g.chooseStr("normal", "strange"))
|
g.chooseStr("normal", "strange"))
|
||||||
}
|
}
|
||||||
case PTFind:
|
case PotionDetectMagic:
|
||||||
// Potion of magic detection. Show the potions and scrolls
|
// Potion of magic detection. Show the potions and scrolls
|
||||||
show := false
|
show := false
|
||||||
if len(g.Level.Objects) > 0 {
|
if len(g.Level.Objects) > 0 {
|
||||||
@@ -94,7 +94,7 @@ func (g *RogueGame) quaff() {
|
|||||||
if tp.isMagic() {
|
if tp.isMagic() {
|
||||||
show = true
|
show = true
|
||||||
g.scr.Hw.MvAddCh(tp.Pos.Y, tp.Pos.X, Magic)
|
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 {
|
for _, mp := range g.Level.Monsters {
|
||||||
@@ -107,34 +107,34 @@ func (g *RogueGame) quaff() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if show {
|
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--")
|
g.showWin("You sense the presence of magic on this level.--More--")
|
||||||
} else {
|
} else {
|
||||||
g.msg("you have a %s feeling for a moment, then it passes",
|
g.msg("you have a %s feeling for a moment, then it passes",
|
||||||
g.chooseStr("normal", "strange"))
|
g.chooseStr("normal", "strange"))
|
||||||
}
|
}
|
||||||
case PLSD:
|
case PotionLSD:
|
||||||
if !trip {
|
if !trip {
|
||||||
if p.On(SeeMonst) {
|
if p.On(SenseMonsters) {
|
||||||
g.turnSee(false)
|
g.turnSee(false)
|
||||||
}
|
}
|
||||||
g.StartDaemon(DVisuals, 0, Before)
|
g.StartDaemon(DVisuals, 0, Before)
|
||||||
g.SeenStairs = g.seenStairs()
|
g.SeenStairs = g.seenStairs()
|
||||||
}
|
}
|
||||||
g.doPot(PLSD, true)
|
g.doPot(PotionLSD, true)
|
||||||
case PSeeInvis:
|
case PotionSeeInvisible:
|
||||||
show := p.On(CanSee)
|
show := p.On(CanSeeInvisible)
|
||||||
g.doPot(PSeeInvis, false)
|
g.doPot(PotionSeeInvisible, false)
|
||||||
if !show {
|
if !show {
|
||||||
g.invisOn()
|
g.invisOn()
|
||||||
}
|
}
|
||||||
g.sight(0)
|
g.sight(0)
|
||||||
case PRaise:
|
case PotionRaiseLevel:
|
||||||
g.Items.Potions[PRaise].Know = true
|
g.Items.Potions[PotionRaiseLevel].Know = true
|
||||||
g.msg("you suddenly feel much more skillful")
|
g.msg("you suddenly feel much more skillful")
|
||||||
g.raiseLevel()
|
g.raiseLevel()
|
||||||
case PXHeal:
|
case PotionExtraHealing:
|
||||||
g.Items.Potions[PXHeal].Know = true
|
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 += g.roll(p.Stats.Lvl, 8); p.Stats.HP > p.Stats.MaxHP {
|
||||||
if p.Stats.HP > p.Stats.MaxHP+p.Stats.Lvl+1 {
|
if p.Stats.HP > p.Stats.MaxHP+p.Stats.Lvl+1 {
|
||||||
p.Stats.MaxHP++
|
p.Stats.MaxHP++
|
||||||
@@ -145,33 +145,33 @@ func (g *RogueGame) quaff() {
|
|||||||
g.sight(0)
|
g.sight(0)
|
||||||
g.comeDown(0)
|
g.comeDown(0)
|
||||||
g.msg("you begin to feel much better")
|
g.msg("you begin to feel much better")
|
||||||
case PHaste:
|
case PotionHaste:
|
||||||
g.Items.Potions[PHaste].Know = true
|
g.Items.Potions[PotionHaste].Know = true
|
||||||
g.After = false
|
g.After = false
|
||||||
if g.addHaste(true) {
|
if g.addHaste(true) {
|
||||||
g.msg("you feel yourself moving much faster")
|
g.msg("you feel yourself moving much faster")
|
||||||
}
|
}
|
||||||
case PRestore:
|
case PotionRestoreStrength:
|
||||||
if p.IsRing(Left, RAddStr) {
|
if p.IsRing(Left, RingAddStrength) {
|
||||||
addStr(&p.Stats.Str, -p.CurRing[Left].Arm)
|
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)
|
addStr(&p.Stats.Str, -p.CurRing[Right].Arm)
|
||||||
}
|
}
|
||||||
if p.Stats.Str < p.MaxStats.Str {
|
if p.Stats.Str < p.MaxStats.Str {
|
||||||
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)
|
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)
|
addStr(&p.Stats.Str, p.CurRing[Right].Arm)
|
||||||
}
|
}
|
||||||
g.msg("hey, this tastes great. It make you feel warm all over")
|
g.msg("hey, this tastes great. It make you feel warm all over")
|
||||||
case PBlind:
|
case PotionBlindness:
|
||||||
g.doPot(PBlind, true)
|
g.doPot(PotionBlindness, true)
|
||||||
case PLevit:
|
case PotionLevitation:
|
||||||
g.doPot(PLevit, true)
|
g.doPot(PotionLevitation, true)
|
||||||
}
|
}
|
||||||
g.status()
|
g.status()
|
||||||
// Throw the item away
|
// Throw the item away
|
||||||
@@ -201,7 +201,7 @@ func (g *RogueGame) doPot(typ int, knowit bool) {
|
|||||||
g.Lengthen(pp.daemon, t)
|
g.Lengthen(pp.daemon, t)
|
||||||
}
|
}
|
||||||
high, straight := pp.high, pp.straight
|
high, straight := pp.high, pp.straight
|
||||||
if typ == PSeeInvis {
|
if typ == PotionSeeInvisible {
|
||||||
s := fmt.Sprintf("this potion tastes like %s juice", g.Fruit)
|
s := fmt.Sprintf("this potion tastes like %s juice", g.Fruit)
|
||||||
high, straight = s, s
|
high, straight = s, s
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,7 @@ func (g *RogueGame) doPot(typ int, knowit bool) {
|
|||||||
func (o *Object) isMagic() bool {
|
func (o *Object) isMagic() bool {
|
||||||
switch o.Type {
|
switch o.Type {
|
||||||
case Armor:
|
case Armor:
|
||||||
return o.Flags.Has(IsProt) || o.Arm != aClass[o.Which]
|
return o.Flags.Has(Protected) || o.Arm != aClass[o.Which]
|
||||||
case Weapon:
|
case Weapon:
|
||||||
return o.HPlus != 0 || o.DPlus != 0
|
return o.HPlus != 0 || o.DPlus != 0
|
||||||
case Potion, Scroll, Stick, Ring, Amulet:
|
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
|
// invisOn turns on the ability to see invisible monsters (potions.c
|
||||||
// invis_on).
|
// invis_on).
|
||||||
func (g *RogueGame) invisOn() {
|
func (g *RogueGame) invisOn() {
|
||||||
g.Player.Flags.Set(CanSee)
|
g.Player.Flags.Set(CanSeeInvisible)
|
||||||
for _, mp := range g.Level.Monsters {
|
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)
|
g.mvaddch(mp.Pos.Y, mp.Pos.X, mp.Disguise)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,7 +247,7 @@ func (g *RogueGame) turnSee(turnOff bool) bool {
|
|||||||
if !canSee {
|
if !canSee {
|
||||||
g.standout()
|
g.standout()
|
||||||
}
|
}
|
||||||
if !g.Player.On(IsHalu) {
|
if !g.Player.On(Hallucinating) {
|
||||||
g.addch(mp.Type)
|
g.addch(mp.Type)
|
||||||
} else {
|
} else {
|
||||||
g.addch(byte(g.rnd(26) + 'A'))
|
g.addch(byte(g.rnd(26) + 'A'))
|
||||||
@@ -259,9 +259,9 @@ func (g *RogueGame) turnSee(turnOff bool) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if turnOff {
|
if turnOff {
|
||||||
g.Player.Flags.Clear(SeeMonst)
|
g.Player.Flags.Clear(SenseMonsters)
|
||||||
} else {
|
} else {
|
||||||
g.Player.Flags.Set(SeeMonst)
|
g.Player.Flags.Set(SenseMonsters)
|
||||||
}
|
}
|
||||||
return addNew
|
return addNew
|
||||||
}
|
}
|
||||||
@@ -279,10 +279,10 @@ func (g *RogueGame) seenStairs() bool {
|
|||||||
}
|
}
|
||||||
// if a monster is on the stairs, this gets hairy
|
// if a monster is on the stairs, this gets hairy
|
||||||
if tp := g.Level.MonsterAt(st.Y, st.X); tp != nil {
|
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
|
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
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ func (g *RogueGame) ringOn() {
|
|||||||
|
|
||||||
// Calculate the effect it has on the poor guy.
|
// Calculate the effect it has on the poor guy.
|
||||||
switch obj.Which {
|
switch obj.Which {
|
||||||
case RAddStr:
|
case RingAddStrength:
|
||||||
g.chgStr(obj.Arm)
|
g.chgStr(obj.Arm)
|
||||||
case RSeeInvis:
|
case RingSeeInvisible:
|
||||||
g.invisOn()
|
g.invisOn()
|
||||||
case RAggr:
|
case RingAggravateMonsters:
|
||||||
g.aggravate()
|
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
|
// 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).
|
// 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_PROTECT
|
||||||
1, // R_ADDSTR
|
1, // R_ADDSTR
|
||||||
1, // R_SUSTSTR
|
1, // R_SUSTSTR
|
||||||
@@ -155,7 +155,7 @@ func (g *RogueGame) ringEat(hand int) int {
|
|||||||
eat = 0
|
eat = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ring.Which == RDigest {
|
if ring.Which == RingSlowDigestion {
|
||||||
eat = -eat
|
eat = -eat
|
||||||
}
|
}
|
||||||
return eat
|
return eat
|
||||||
@@ -163,11 +163,11 @@ func (g *RogueGame) ringEat(hand int) int {
|
|||||||
|
|
||||||
// ringNum prints ring bonuses (rings.c ring_num).
|
// ringNum prints ring bonuses (rings.c ring_num).
|
||||||
func ringNum(g *RogueGame, obj *Object) string {
|
func ringNum(g *RogueGame, obj *Object) string {
|
||||||
if !obj.Flags.Has(IsKnow) {
|
if !obj.Flags.Has(Known) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
switch obj.Which {
|
switch obj.Which {
|
||||||
case RProtect, RAddStr, RAddDam, RAddHit:
|
case RingProtection, RingAddStrength, RingIncreaseDamage, RingDexterity:
|
||||||
return fmt.Sprintf(" [%s]", num(obj.Arm, 0, Ring))
|
return fmt.Sprintf(" [%s]", num(obj.Arm, 0, Ring))
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
16
game/rip.go
16
game/rip.go
@@ -121,12 +121,12 @@ func (g *RogueGame) totalWinner() {
|
|||||||
case Weapon:
|
case Weapon:
|
||||||
worth = it.Weapons[obj.Which].Worth
|
worth = it.Weapons[obj.Which].Worth
|
||||||
worth *= 3*(obj.HPlus+obj.DPlus) + obj.Count
|
worth *= 3*(obj.HPlus+obj.DPlus) + obj.Count
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
case Armor:
|
case Armor:
|
||||||
worth = it.Armors[obj.Which].Worth
|
worth = it.Armors[obj.Which].Worth
|
||||||
worth += (9 - obj.Arm) * 100
|
worth += (9 - obj.Arm) * 100
|
||||||
worth += 10 * (aClass[obj.Which] - obj.Arm)
|
worth += 10 * (aClass[obj.Which] - obj.Arm)
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
case Scroll:
|
case Scroll:
|
||||||
op := &it.Scrolls[obj.Which]
|
op := &it.Scrolls[obj.Which]
|
||||||
worth = op.Worth * obj.Count
|
worth = op.Worth * obj.Count
|
||||||
@@ -144,27 +144,27 @@ func (g *RogueGame) totalWinner() {
|
|||||||
case Ring:
|
case Ring:
|
||||||
op := &it.Rings[obj.Which]
|
op := &it.Rings[obj.Which]
|
||||||
worth = op.Worth
|
worth = op.Worth
|
||||||
if obj.Which == RAddStr || obj.Which == RAddDam ||
|
if obj.Which == RingAddStrength || obj.Which == RingIncreaseDamage ||
|
||||||
obj.Which == RProtect || obj.Which == RAddHit {
|
obj.Which == RingProtection || obj.Which == RingDexterity {
|
||||||
if obj.Arm > 0 {
|
if obj.Arm > 0 {
|
||||||
worth += obj.Arm * 100
|
worth += obj.Arm * 100
|
||||||
} else {
|
} else {
|
||||||
worth = 10
|
worth = 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !obj.Flags.Has(IsKnow) {
|
if !obj.Flags.Has(Known) {
|
||||||
worth /= 2
|
worth /= 2
|
||||||
}
|
}
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
op.Know = true
|
op.Know = true
|
||||||
case Stick:
|
case Stick:
|
||||||
op := &it.Sticks[obj.Which]
|
op := &it.Sticks[obj.Which]
|
||||||
worth = op.Worth
|
worth = op.Worth
|
||||||
worth += 20 * obj.Charges()
|
worth += 20 * obj.Charges()
|
||||||
if !obj.Flags.Has(IsKnow) {
|
if !obj.Flags.Has(Known) {
|
||||||
worth /= 2
|
worth /= 2
|
||||||
}
|
}
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
op.Know = true
|
op.Know = true
|
||||||
case Amulet:
|
case Amulet:
|
||||||
worth = 1000
|
worth = 1000
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ func (g *RogueGame) doRooms() {
|
|||||||
// Put the gone rooms, if any, on the level
|
// Put the gone rooms, if any, on the level
|
||||||
leftOut := g.rnd(4)
|
leftOut := g.rnd(4)
|
||||||
for i := 0; i < leftOut; i++ {
|
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
|
// dig and populate all the rooms on the level
|
||||||
for i := range g.Level.Rooms {
|
for i := range g.Level.Rooms {
|
||||||
rp := &g.Level.Rooms[i]
|
rp := &g.Level.Rooms[i]
|
||||||
// Find upper left corner of box that this room goes in
|
// Find upper left corner of box that this room goes in
|
||||||
top := Coord{X: (i%3)*bsze.X + 1, Y: (i / 3) * bsze.Y}
|
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
|
// Place a gone room. Make certain that there is a blank line
|
||||||
// for passage drawing.
|
// for passage drawing.
|
||||||
for {
|
for {
|
||||||
@@ -56,13 +56,13 @@ func (g *RogueGame) doRooms() {
|
|||||||
}
|
}
|
||||||
// set room type
|
// set room type
|
||||||
if g.rnd(10) < g.Depth-1 {
|
if g.rnd(10) < g.Depth-1 {
|
||||||
rp.Flags.Set(IsDark) // dark room
|
rp.Flags.Set(Dark) // dark room
|
||||||
if g.rnd(15) == 0 {
|
if g.rnd(15) == 0 {
|
||||||
rp.Flags = IsMaze // maze room
|
rp.Flags = Maze // maze room
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Find a place and size for a random 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.X = bsze.X - 1
|
||||||
rp.Max.Y = bsze.Y - 1
|
rp.Max.Y = bsze.Y - 1
|
||||||
if rp.Pos.X = top.X; rp.Pos.X == 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)
|
rp.Gold, _ = g.findFloorIn(rp, 0, false)
|
||||||
gold.Pos = rp.Gold
|
gold.Pos = rp.Gold
|
||||||
g.Level.SetChar(rp.Gold.Y, rp.Gold.X, Gold)
|
g.Level.SetChar(rp.Gold.Y, rp.Gold.X, Gold)
|
||||||
gold.Flags = IsMany
|
gold.Flags = Stackable
|
||||||
gold.Group = goldGrp
|
gold.Group = goldGrp
|
||||||
gold.Type = Gold
|
gold.Type = Gold
|
||||||
attachObj(&g.Level.Objects, 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
|
// 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).
|
// rooms; for maze rooms, draws the maze (rooms.c draw_room).
|
||||||
func (g *RogueGame) drawRoom(rp *Room) {
|
func (g *RogueGame) drawRoom(rp *Room) {
|
||||||
if rp.Flags.Has(IsMaze) {
|
if rp.Flags.Has(Maze) {
|
||||||
g.doMaze(rp)
|
g.doMaze(rp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ func (g *RogueGame) dig(y, x int) {
|
|||||||
if newy < 0 || newy > m.maxy || newx < 0 || newx > m.maxx {
|
if newy < 0 || newy > m.maxy || newx < 0 || newx > m.maxx {
|
||||||
continue
|
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
|
continue
|
||||||
}
|
}
|
||||||
if cnt++; g.rnd(cnt) == 0 {
|
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
|
var compchar byte
|
||||||
if !pickroom {
|
if !pickroom {
|
||||||
compchar = Floor
|
compchar = Floor
|
||||||
if rp.Flags.Has(IsMaze) {
|
if rp.Flags.Has(Maze) {
|
||||||
compchar = Passage
|
compchar = Passage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ func (g *RogueGame) findFloorImpl(rp *Room, limit int, monst, pickroom bool) (Co
|
|||||||
if pickroom {
|
if pickroom {
|
||||||
rp = &g.Level.Rooms[g.rndRoom()]
|
rp = &g.Level.Rooms[g.rndRoom()]
|
||||||
compchar = Floor
|
compchar = Floor
|
||||||
if rp.Flags.Has(IsMaze) {
|
if rp.Flags.Has(Maze) {
|
||||||
compchar = Passage
|
compchar = Passage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ func (g *RogueGame) enterRoom(cp Coord) {
|
|||||||
rp := g.roomin(cp)
|
rp := g.roomin(cp)
|
||||||
p.Room = rp
|
p.Room = rp
|
||||||
g.doorOpen(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++ {
|
for y := rp.Pos.Y; y < rp.Max.Y+rp.Pos.Y; y++ {
|
||||||
g.move(y, rp.Pos.X)
|
g.move(y, rp.Pos.X)
|
||||||
for x := rp.Pos.X; x < rp.Max.X+rp.Pos.X; 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 {
|
} else {
|
||||||
tp.OldCh = ch
|
tp.OldCh = ch
|
||||||
if !g.seeMonst(tp) {
|
if !g.seeMonst(tp) {
|
||||||
if p.On(SeeMonst) {
|
if p.On(SenseMonsters) {
|
||||||
g.standout()
|
g.standout()
|
||||||
g.addch(tp.Disguise)
|
g.addch(tp.Disguise)
|
||||||
g.standend()
|
g.standend()
|
||||||
@@ -330,21 +330,21 @@ func (g *RogueGame) leaveRoom(cp Coord) {
|
|||||||
p := &g.Player
|
p := &g.Player
|
||||||
rp := p.Room
|
rp := p.Room
|
||||||
|
|
||||||
if rp.Flags.Has(IsMaze) {
|
if rp.Flags.Has(Maze) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var floor byte
|
var floor byte
|
||||||
switch {
|
switch {
|
||||||
case rp.Flags.Has(IsGone):
|
case rp.Flags.Has(Gone):
|
||||||
floor = Passage
|
floor = Passage
|
||||||
case !rp.Flags.Has(IsDark) || p.On(IsBlind):
|
case !rp.Flags.Has(Dark) || p.On(Blind):
|
||||||
floor = Floor
|
floor = Floor
|
||||||
default:
|
default:
|
||||||
floor = ' '
|
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 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++ {
|
for x := rp.Pos.X; x < rp.Max.X+rp.Pos.X; x++ {
|
||||||
g.move(y, 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
|
// to check for monster, we have to strip out the standout
|
||||||
// bit (our Window returns the bare character already)
|
// bit (our Window returns the bare character already)
|
||||||
if isUpper(ch) {
|
if isUpper(ch) {
|
||||||
if p.On(SeeMonst) {
|
if p.On(SenseMonsters) {
|
||||||
g.standout()
|
g.standout()
|
||||||
g.addch(ch)
|
g.addch(ch)
|
||||||
g.standend()
|
g.standend()
|
||||||
|
|||||||
20
game/save.go
20
game/save.go
@@ -74,14 +74,14 @@ type SaveState struct {
|
|||||||
HasAmulet bool
|
HasAmulet bool
|
||||||
SeenStairs bool
|
SeenStairs bool
|
||||||
|
|
||||||
Places []savedPlace
|
Places []savedPlace
|
||||||
Rooms [MaxRooms]Room
|
Rooms [MaxRooms]Room
|
||||||
Passages [MaxPass]Room
|
Passages [MaxPass]Room
|
||||||
Objects []Object
|
Objects []Object
|
||||||
Monsters []savedCreature
|
Monsters []savedCreature
|
||||||
Dests []destRef // parallel to Monsters
|
Dests []destRef // parallel to Monsters
|
||||||
Stairs Coord
|
Stairs Coord
|
||||||
NTraps int
|
TrapCount int
|
||||||
|
|
||||||
After bool
|
After bool
|
||||||
Again bool
|
Again bool
|
||||||
@@ -179,7 +179,7 @@ func (g *RogueGame) snapshot() *SaveState {
|
|||||||
Rooms: g.Level.Rooms,
|
Rooms: g.Level.Rooms,
|
||||||
Passages: g.Level.Passages,
|
Passages: g.Level.Passages,
|
||||||
Stairs: g.Level.Stairs,
|
Stairs: g.Level.Stairs,
|
||||||
NTraps: g.Level.NTraps,
|
TrapCount: g.Level.TrapCount,
|
||||||
After: g.After,
|
After: g.After,
|
||||||
Again: g.Again,
|
Again: g.Again,
|
||||||
NoScoreF: g.NoScore,
|
NoScoreF: g.NoScore,
|
||||||
@@ -308,7 +308,7 @@ func (g *RogueGame) applySnapshot(st *SaveState) {
|
|||||||
g.Level.Rooms = st.Rooms
|
g.Level.Rooms = st.Rooms
|
||||||
g.Level.Passages = st.Passages
|
g.Level.Passages = st.Passages
|
||||||
g.Level.Stairs = st.Stairs
|
g.Level.Stairs = st.Stairs
|
||||||
g.Level.NTraps = st.NTraps
|
g.Level.TrapCount = st.TrapCount
|
||||||
g.After = st.After
|
g.After = st.After
|
||||||
g.Again = st.Again
|
g.Again = st.Again
|
||||||
g.NoScore = st.NoScoreF
|
g.NoScore = st.NoScoreF
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ func TestSaveRestoreRoundTrip(t *testing.T) {
|
|||||||
g.Player.Purse = 123
|
g.Player.Purse = 123
|
||||||
g.Player.FoodLeft = 777
|
g.Player.FoodLeft = 777
|
||||||
g.HasAmulet = true
|
g.HasAmulet = true
|
||||||
g.Items.Potions[PHealing].Know = true
|
g.Items.Potions[PotionHealing].Know = true
|
||||||
g.Items.Scrolls[SMap].Guess = "map???"
|
g.Items.Scrolls[ScrollMagicMapping].Guess = "map???"
|
||||||
g.Monsters['F'-'A'].Stats.Dmg = "3x1" // mutated bestiary must survive
|
g.Monsters['F'-'A'].Stats.Dmg = "3x1" // mutated bestiary must survive
|
||||||
if len(g.Level.Monsters) > 0 {
|
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
|
g.Level.Monsters[0].Dest = &g.Player.Pos
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@ func TestSaveRestoreRoundTrip(t *testing.T) {
|
|||||||
if !h.HasAmulet {
|
if !h.HasAmulet {
|
||||||
t.Error("amulet flag lost")
|
t.Error("amulet flag lost")
|
||||||
}
|
}
|
||||||
if !h.Items.Potions[PHealing].Know {
|
if !h.Items.Potions[PotionHealing].Know {
|
||||||
t.Error("potion identification lost")
|
t.Error("potion identification lost")
|
||||||
}
|
}
|
||||||
if h.Items.Scrolls[SMap].Guess != "map???" {
|
if h.Items.Scrolls[ScrollMagicMapping].Guess != "map???" {
|
||||||
t.Error("scroll guess lost")
|
t.Error("scroll guess lost")
|
||||||
}
|
}
|
||||||
if h.Monsters['F'-'A'].Stats.Dmg != "3x1" {
|
if h.Monsters['F'-'A'].Stats.Dmg != "3x1" {
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ package game
|
|||||||
|
|
||||||
// idType maps identify scrolls to the type they identify (scrolls.c
|
// idType maps identify scrolls to the type they identify (scrolls.c
|
||||||
// static id_type).
|
// static id_type).
|
||||||
var idType = [SIDRorS + 1]int{
|
var idType = [ScrollIdentifyRingOrStick + 1]int{
|
||||||
SIDPotion: int(Potion),
|
ScrollIdentifyPotion: int(Potion),
|
||||||
SIDScroll: int(Scroll),
|
ScrollIdentifyScroll: int(Scroll),
|
||||||
SIDWeapon: int(Weapon),
|
ScrollIdentifyWeapon: int(Weapon),
|
||||||
SIDArmor: int(Armor),
|
ScrollIdentifyArmor: int(Armor),
|
||||||
SIDRorS: RorS,
|
ScrollIdentifyRingOrStick: RorS,
|
||||||
}
|
}
|
||||||
|
|
||||||
// readScroll reads a scroll from the pack and does the appropriate thing
|
// 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)
|
g.leavePack(obj, false, false)
|
||||||
|
|
||||||
switch obj.Which {
|
switch obj.Which {
|
||||||
case SConfuse:
|
case ScrollMonsterConfusion:
|
||||||
// Scroll of monster confusion. Give him that power.
|
// 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"))
|
g.msg("your hands begin to glow %s", g.pickColor("red"))
|
||||||
case SArmor:
|
case ScrollEnchantArmor:
|
||||||
if p.CurArmor != nil {
|
if p.CurArmor != nil {
|
||||||
p.CurArmor.Arm--
|
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"))
|
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
|
// Hold monster scroll. Stop all monsters within two spaces from
|
||||||
// chasing after the hero.
|
// chasing after the hero.
|
||||||
held := 0
|
held := 0
|
||||||
@@ -58,9 +58,9 @@ func (g *RogueGame) readScroll() {
|
|||||||
if y < 0 || y > NumLines-1 {
|
if y < 0 || y > NumLines-1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if mp := g.Level.MonsterAt(y, x); mp != nil && mp.On(IsRun) {
|
if mp := g.Level.MonsterAt(y, x); mp != nil && mp.On(Awake) {
|
||||||
mp.Flags.Clear(IsRun)
|
mp.Flags.Clear(Awake)
|
||||||
mp.Flags.Set(IsHeld)
|
mp.Flags.Set(Held)
|
||||||
held++
|
held++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,17 +75,17 @@ func (g *RogueGame) readScroll() {
|
|||||||
g.addmsg("s")
|
g.addmsg("s")
|
||||||
}
|
}
|
||||||
g.endmsg()
|
g.endmsg()
|
||||||
g.Items.Scrolls[SHold].Know = true
|
g.Items.Scrolls[ScrollHoldMonster].Know = true
|
||||||
} else {
|
} else {
|
||||||
g.msg("you feel a strange sense of loss")
|
g.msg("you feel a strange sense of loss")
|
||||||
}
|
}
|
||||||
case SSleep:
|
case ScrollSleep:
|
||||||
// Scroll which makes you fall asleep
|
// 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
|
g.NoCommand += g.rnd(g.spread(5)) + 4 // SLEEPTIME
|
||||||
p.Flags.Clear(IsRun)
|
p.Flags.Clear(Awake)
|
||||||
g.msg("you fall asleep")
|
g.msg("you fall asleep")
|
||||||
case SCreate:
|
case ScrollCreateMonster:
|
||||||
// Create a monster: first look in a circle around him, next try
|
// Create a monster: first look in a circle around him, next try
|
||||||
// his room, otherwise give up
|
// his room, otherwise give up
|
||||||
i := 0
|
i := 0
|
||||||
@@ -99,7 +99,7 @@ func (g *RogueGame) readScroll() {
|
|||||||
// Or anything else nasty
|
// Or anything else nasty
|
||||||
if ch := g.Level.VisibleChar(y, x); stepOk(ch) {
|
if ch := g.Level.VisibleChar(y, x); stepOk(ch) {
|
||||||
if ch == Scroll {
|
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
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,14 +115,14 @@ func (g *RogueGame) readScroll() {
|
|||||||
tp := &Monster{}
|
tp := &Monster{}
|
||||||
g.newMonster(tp, g.randMonster(false), mp)
|
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
|
// Identify, let him figure something out
|
||||||
g.Items.Scrolls[obj.Which].Know = true
|
g.Items.Scrolls[obj.Which].Know = true
|
||||||
g.msg("this scroll is an %s scroll", g.Items.Scrolls[obj.Which].Name)
|
g.msg("this scroll is an %s scroll", g.Items.Scrolls[obj.Which].Name)
|
||||||
g.whatis(true, idType[obj.Which])
|
g.whatis(true, idType[obj.Which])
|
||||||
case SMap:
|
case ScrollMagicMapping:
|
||||||
// Scroll of magic mapping.
|
// 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")
|
g.msg("oh, now this scroll has a map on it")
|
||||||
// take all the things we want to keep hidden out of the window
|
// take all the things we want to keep hidden out of the window
|
||||||
for y := 1; y < NumLines-1; y++ {
|
for y := 1; y < NumLines-1; y++ {
|
||||||
@@ -141,7 +141,7 @@ func (g *RogueGame) readScroll() {
|
|||||||
case ' ':
|
case ' ':
|
||||||
if pp.Flags.Has(FReal) {
|
if pp.Flags.Has(FReal) {
|
||||||
// def: hidden things in walls stay hidden
|
// def: hidden things in walls stay hidden
|
||||||
if pp.Flags.Has(FPass) {
|
if pp.Flags.Has(FPassage) {
|
||||||
pass = true
|
pass = true
|
||||||
} else {
|
} else {
|
||||||
ch = ' '
|
ch = ' '
|
||||||
@@ -162,7 +162,7 @@ func (g *RogueGame) readScroll() {
|
|||||||
pp.Flags.Set(FSeen | FReal)
|
pp.Flags.Set(FSeen | FReal)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if pp.Flags.Has(FPass) {
|
if pp.Flags.Has(FPassage) {
|
||||||
pass = true
|
pass = true
|
||||||
} else {
|
} else {
|
||||||
ch = ' '
|
ch = ' '
|
||||||
@@ -178,7 +178,7 @@ func (g *RogueGame) readScroll() {
|
|||||||
if ch != ' ' {
|
if ch != ' ' {
|
||||||
if tp := pp.Monst; tp != nil {
|
if tp := pp.Monst; tp != nil {
|
||||||
tp.OldCh = ch
|
tp.OldCh = ch
|
||||||
if !p.On(SeeMonst) {
|
if !p.On(SenseMonsters) {
|
||||||
g.mvaddch(y, x, ch)
|
g.mvaddch(y, x, ch)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -187,7 +187,7 @@ func (g *RogueGame) readScroll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case SFDet:
|
case ScrollFoodDetection:
|
||||||
// Food detection
|
// Food detection
|
||||||
found := false
|
found := false
|
||||||
g.scr.Hw.Clear()
|
g.scr.Hw.Clear()
|
||||||
@@ -198,23 +198,23 @@ func (g *RogueGame) readScroll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if found {
|
if found {
|
||||||
g.Items.Scrolls[SFDet].Know = true
|
g.Items.Scrolls[ScrollFoodDetection].Know = true
|
||||||
g.showWin("Your nose tingles and you smell food.--More--")
|
g.showWin("Your nose tingles and you smell food.--More--")
|
||||||
} else {
|
} else {
|
||||||
g.msg("your nose tingles")
|
g.msg("your nose tingles")
|
||||||
}
|
}
|
||||||
case STelep:
|
case ScrollTeleportation:
|
||||||
// Scroll of teleportation: make him disappear and reappear
|
// Scroll of teleportation: make him disappear and reappear
|
||||||
curRoom := p.Room
|
curRoom := p.Room
|
||||||
g.teleport()
|
g.teleport()
|
||||||
if curRoom != p.Room {
|
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 {
|
if p.CurWeapon == nil || p.CurWeapon.Type != Weapon {
|
||||||
g.msg("you feel a strange sense of loss")
|
g.msg("you feel a strange sense of loss")
|
||||||
} else {
|
} else {
|
||||||
p.CurWeapon.Flags.Clear(IsCursed)
|
p.CurWeapon.Flags.Clear(Cursed)
|
||||||
if g.rnd(2) == 0 {
|
if g.rnd(2) == 0 {
|
||||||
p.CurWeapon.HPlus++
|
p.CurWeapon.HPlus++
|
||||||
} else {
|
} else {
|
||||||
@@ -223,25 +223,25 @@ func (g *RogueGame) readScroll() {
|
|||||||
g.msg("your %s glows %s for a moment",
|
g.msg("your %s glows %s for a moment",
|
||||||
g.Items.Weapons[p.CurWeapon.Which].Name, g.pickColor("blue"))
|
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
|
// Reading it is a mistake and produces laughter at her poor boo
|
||||||
// boo.
|
// boo.
|
||||||
g.msg("you hear maniacal laughter in the distance")
|
g.msg("you hear maniacal laughter in the distance")
|
||||||
case SRemove:
|
case ScrollRemoveCurse:
|
||||||
uncurse(p.CurArmor)
|
uncurse(p.CurArmor)
|
||||||
uncurse(p.CurWeapon)
|
uncurse(p.CurWeapon)
|
||||||
uncurse(p.CurRing[Left])
|
uncurse(p.CurRing[Left])
|
||||||
uncurse(p.CurRing[Right])
|
uncurse(p.CurRing[Right])
|
||||||
g.msg("%s", g.chooseStr("you feel in touch with the Universal Onenes",
|
g.msg("%s", g.chooseStr("you feel in touch with the Universal Onenes",
|
||||||
"you feel as if somebody is watching over you"))
|
"you feel as if somebody is watching over you"))
|
||||||
case SAggr:
|
case ScrollAggravateMonsters:
|
||||||
// This scroll aggravates all the monsters on the current level
|
// This scroll aggravates all the monsters on the current level
|
||||||
// and sets them running towards the hero
|
// and sets them running towards the hero
|
||||||
g.aggravate()
|
g.aggravate()
|
||||||
g.msg("you hear a high pitched humming noise")
|
g.msg("you hear a high pitched humming noise")
|
||||||
case SProtect:
|
case ScrollProtectArmor:
|
||||||
if p.CurArmor != nil {
|
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.msg("your armor is covered by a shimmering %s shield",
|
||||||
g.pickColor("gold"))
|
g.pickColor("gold"))
|
||||||
} else {
|
} else {
|
||||||
@@ -257,6 +257,6 @@ func (g *RogueGame) readScroll() {
|
|||||||
// uncurse uncurses an item (scrolls.c uncurse).
|
// uncurse uncurses an item (scrolls.c uncurse).
|
||||||
func uncurse(obj *Object) {
|
func uncurse(obj *Object) {
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
obj.Flags.Clear(IsCursed)
|
obj.Flags.Clear(Cursed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ func (g *RogueGame) doZap() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch obj.Which {
|
switch obj.Which {
|
||||||
case WsLight:
|
case WandLight:
|
||||||
// Reddy Kilowatt wand. Light up the room
|
// Reddy Kilowatt wand. Light up the room
|
||||||
g.Items.Sticks[WsLight].Know = true
|
g.Items.Sticks[WandLight].Know = true
|
||||||
if p.Room.Flags.Has(IsGone) {
|
if p.Room.Flags.Has(Gone) {
|
||||||
g.msg("the corridor glows and then fades")
|
g.msg("the corridor glows and then fades")
|
||||||
} else {
|
} else {
|
||||||
p.Room.Flags.Clear(IsDark)
|
p.Room.Flags.Clear(Dark)
|
||||||
// Light the room and put the player back up
|
// Light the room and put the player back up
|
||||||
g.enterRoom(p.Pos)
|
g.enterRoom(p.Pos)
|
||||||
g.addmsg("the room is lit")
|
g.addmsg("the room is lit")
|
||||||
@@ -36,7 +36,7 @@ func (g *RogueGame) doZap() {
|
|||||||
}
|
}
|
||||||
g.endmsg()
|
g.endmsg()
|
||||||
}
|
}
|
||||||
case WsDrain:
|
case WandDrainLife:
|
||||||
// take away 1/2 of hero's hit points, then take it away evenly
|
// 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
|
// from the monsters in the room (or next to hero if he is in a
|
||||||
// passage)
|
// passage)
|
||||||
@@ -45,7 +45,7 @@ func (g *RogueGame) doZap() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
g.drain()
|
g.drain()
|
||||||
case WsInvis, WsPolymorph, WsTelAway, WsTelTo, WsCancel:
|
case WandInvisibility, WandPolymorph, WandTeleportAway, WandTeleportTo, WandCancellation:
|
||||||
y := p.Pos.Y
|
y := p.Pos.Y
|
||||||
x := p.Pos.X
|
x := p.Pos.X
|
||||||
for stepOk(g.Level.VisibleChar(y, 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 {
|
if tp := g.Level.MonsterAt(y, x); tp != nil {
|
||||||
monster := tp.Type
|
monster := tp.Type
|
||||||
if monster == 'F' {
|
if monster == 'F' {
|
||||||
p.Flags.Clear(IsHeld)
|
p.Flags.Clear(Held)
|
||||||
}
|
}
|
||||||
switch obj.Which {
|
switch obj.Which {
|
||||||
case WsInvis:
|
case WandInvisibility:
|
||||||
tp.Flags.Set(IsInvis)
|
tp.Flags.Set(Invisible)
|
||||||
if g.cansee(y, x) {
|
if g.cansee(y, x) {
|
||||||
g.mvaddch(y, x, tp.OldCh)
|
g.mvaddch(y, x, tp.OldCh)
|
||||||
}
|
}
|
||||||
case WsPolymorph:
|
case WandPolymorph:
|
||||||
pp := tp.Pack
|
pp := tp.Pack
|
||||||
detachMon(&g.Level.Monsters, tp)
|
detachMon(&g.Level.Monsters, tp)
|
||||||
if g.seeMonst(tp) {
|
if g.seeMonst(tp) {
|
||||||
@@ -80,18 +80,18 @@ func (g *RogueGame) doZap() {
|
|||||||
tp.OldCh = oldch
|
tp.OldCh = oldch
|
||||||
tp.Pack = pp
|
tp.Pack = pp
|
||||||
if g.seeMonst(tp) {
|
if g.seeMonst(tp) {
|
||||||
g.Items.Sticks[WsPolymorph].Know = true
|
g.Items.Sticks[WandPolymorph].Know = true
|
||||||
}
|
}
|
||||||
case WsCancel:
|
case WandCancellation:
|
||||||
tp.Flags.Set(IsCanc)
|
tp.Flags.Set(Cancelled)
|
||||||
tp.Flags.Clear(IsInvis | CanHuh)
|
tp.Flags.Clear(Invisible | CanConfuse)
|
||||||
tp.Disguise = tp.Type
|
tp.Disguise = tp.Type
|
||||||
if g.seeMonst(tp) {
|
if g.seeMonst(tp) {
|
||||||
g.mvaddch(y, x, tp.Disguise)
|
g.mvaddch(y, x, tp.Disguise)
|
||||||
}
|
}
|
||||||
case WsTelAway, WsTelTo:
|
case WandTeleportAway, WandTeleportTo:
|
||||||
var newPos Coord
|
var newPos Coord
|
||||||
if obj.Which == WsTelAway {
|
if obj.Which == WandTeleportAway {
|
||||||
for {
|
for {
|
||||||
newPos, _ = g.findFloor(nil, 0, true)
|
newPos, _ = g.findFloor(nil, 0, true)
|
||||||
if newPos != p.Pos {
|
if newPos != p.Pos {
|
||||||
@@ -103,18 +103,18 @@ func (g *RogueGame) doZap() {
|
|||||||
newPos.X = p.Pos.X + g.Delta.X
|
newPos.X = p.Pos.X + g.Delta.X
|
||||||
}
|
}
|
||||||
tp.Dest = &p.Pos
|
tp.Dest = &p.Pos
|
||||||
tp.Flags.Set(IsRun)
|
tp.Flags.Set(Awake)
|
||||||
g.relocate(tp, newPos)
|
g.relocate(tp, newPos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case WsMissile:
|
case WandMagicMissile:
|
||||||
g.Items.Sticks[WsMissile].Know = true
|
g.Items.Sticks[WandMagicMissile].Know = true
|
||||||
bolt := newObject()
|
bolt := newObject()
|
||||||
bolt.Type = '*'
|
bolt.Type = '*'
|
||||||
bolt.HurlDmg = "1x4"
|
bolt.HurlDmg = "1x4"
|
||||||
bolt.HPlus = 100
|
bolt.HPlus = 100
|
||||||
bolt.DPlus = 1
|
bolt.DPlus = 1
|
||||||
bolt.Flags = IsMissl
|
bolt.Flags = Missile
|
||||||
if p.CurWeapon != nil {
|
if p.CurWeapon != nil {
|
||||||
bolt.Launch = p.CurWeapon.Which
|
bolt.Launch = p.CurWeapon.Which
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ func (g *RogueGame) doZap() {
|
|||||||
} else {
|
} else {
|
||||||
g.msg("the missle vanishes with a puff of smoke")
|
g.msg("the missle vanishes with a puff of smoke")
|
||||||
}
|
}
|
||||||
case WsHasteM, WsSlowM:
|
case WandHasteMonster, WandSlowMonster:
|
||||||
y := p.Pos.Y
|
y := p.Pos.Y
|
||||||
x := p.Pos.X
|
x := p.Pos.X
|
||||||
for stepOk(g.Level.VisibleChar(y, x)) {
|
for stepOk(g.Level.VisibleChar(y, x)) {
|
||||||
@@ -135,17 +135,17 @@ func (g *RogueGame) doZap() {
|
|||||||
x += g.Delta.X
|
x += g.Delta.X
|
||||||
}
|
}
|
||||||
if tp := g.Level.MonsterAt(y, x); tp != nil {
|
if tp := g.Level.MonsterAt(y, x); tp != nil {
|
||||||
if obj.Which == WsHasteM {
|
if obj.Which == WandHasteMonster {
|
||||||
if tp.On(IsSlow) {
|
if tp.On(Slowed) {
|
||||||
tp.Flags.Clear(IsSlow)
|
tp.Flags.Clear(Slowed)
|
||||||
} else {
|
} else {
|
||||||
tp.Flags.Set(IsHaste)
|
tp.Flags.Set(Hasted)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if tp.On(IsHaste) {
|
if tp.On(Hasted) {
|
||||||
tp.Flags.Clear(IsHaste)
|
tp.Flags.Clear(Hasted)
|
||||||
} else {
|
} else {
|
||||||
tp.Flags.Set(IsSlow)
|
tp.Flags.Set(Slowed)
|
||||||
}
|
}
|
||||||
tp.Turn = true
|
tp.Turn = true
|
||||||
}
|
}
|
||||||
@@ -153,19 +153,19 @@ func (g *RogueGame) doZap() {
|
|||||||
g.Delta.X = x
|
g.Delta.X = x
|
||||||
g.runto(g.Delta)
|
g.runto(g.Delta)
|
||||||
}
|
}
|
||||||
case WsElect, WsFire, WsCold:
|
case WandLightning, WandFire, WandCold:
|
||||||
var name string
|
var name string
|
||||||
switch obj.Which {
|
switch obj.Which {
|
||||||
case WsElect:
|
case WandLightning:
|
||||||
name = "bolt"
|
name = "bolt"
|
||||||
case WsFire:
|
case WandFire:
|
||||||
name = "flame"
|
name = "flame"
|
||||||
default:
|
default:
|
||||||
name = "ice"
|
name = "ice"
|
||||||
}
|
}
|
||||||
g.fireBolt(p.Pos, &g.Delta, name)
|
g.fireBolt(p.Pos, &g.Delta, name)
|
||||||
g.Items.Sticks[obj.Which].Know = true
|
g.Items.Sticks[obj.Which].Know = true
|
||||||
case WsNop:
|
case WandNothing:
|
||||||
}
|
}
|
||||||
obj.SetCharges(obj.Charges() - 1)
|
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
|
// First count how many things we need to spread the hit points among
|
||||||
var corp *Room
|
var corp *Room
|
||||||
if g.Level.Char(p.Pos.Y, p.Pos.X) == Door {
|
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
|
var drainee []*Monster
|
||||||
for _, mp := range g.Level.Monsters {
|
for _, mp := range g.Level.Monsters {
|
||||||
if mp.Room == p.Room || mp.Room == corp ||
|
if mp.Room == p.Room || mp.Room == corp ||
|
||||||
(inpass && g.Level.Char(mp.Pos.Y, mp.Pos.X) == Door &&
|
(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)
|
drainee = append(drainee, mp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,11 +212,11 @@ func (g *RogueGame) fireBolt(start Coord, dir *Coord, name string) {
|
|||||||
|
|
||||||
bolt := newObject()
|
bolt := newObject()
|
||||||
bolt.Type = Weapon
|
bolt.Type = Weapon
|
||||||
bolt.Which = Flame
|
bolt.Which = WeaponFlame
|
||||||
bolt.HurlDmg = "6x6"
|
bolt.HurlDmg = "6x6"
|
||||||
bolt.HPlus = 100
|
bolt.HPlus = 100
|
||||||
bolt.DPlus = 0
|
bolt.DPlus = 0
|
||||||
g.Items.Weapons[Flame].Name = name
|
g.Items.Weapons[WeaponFlame].Name = name
|
||||||
var dirch byte
|
var dirch byte
|
||||||
switch dir.Y + dir.X {
|
switch dir.Y + dir.X {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -329,7 +329,7 @@ func (g *RogueGame) fixStick(cur *Object) {
|
|||||||
cur.HurlDmg = "1x1"
|
cur.HurlDmg = "1x1"
|
||||||
|
|
||||||
switch cur.Which {
|
switch cur.Which {
|
||||||
case WsLight:
|
case WandLight:
|
||||||
cur.SetCharges(g.rnd(10) + 10)
|
cur.SetCharges(g.rnd(10) + 10)
|
||||||
default:
|
default:
|
||||||
cur.SetCharges(g.rnd(5) + 3)
|
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
|
// chargeStr returns the charge-count suffix for an identified stick
|
||||||
// (sticks.c charge_str).
|
// (sticks.c charge_str).
|
||||||
func chargeStr(g *RogueGame, obj *Object) string {
|
func chargeStr(g *RogueGame, obj *Object) string {
|
||||||
if !obj.Flags.Has(IsKnow) {
|
if !obj.Flags.Has(Known) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if g.Options.Terse {
|
if g.Options.Terse {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package game
|
|||||||
var initStats = Stats{Str: 16, Exp: 0, Lvl: 1, Arm: 10, HP: 12, Dmg: "1x4", MaxHP: 12}
|
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.
|
// aClass is extern.c a_class[]: armor class for each armor type.
|
||||||
var aClass = [MaxArmors]int{
|
var aClass = [NumArmorTypes]int{
|
||||||
8, // LEATHER
|
8, // LEATHER
|
||||||
7, // RING_MAIL
|
7, // RING_MAIL
|
||||||
7, // STUDDED_LEATHER
|
7, // STUDDED_LEATHER
|
||||||
@@ -28,7 +28,7 @@ var eLevels = []int{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// trName is extern.c tr_name[]: names of the traps.
|
// trName is extern.c tr_name[]: names of the traps.
|
||||||
var trName = [NTraps]string{
|
var trName = [NumTrapTypes]string{
|
||||||
"a trapdoor",
|
"a trapdoor",
|
||||||
"an arrow trap",
|
"an arrow trap",
|
||||||
"a sleeping gas trap",
|
"a sleeping gas trap",
|
||||||
@@ -47,32 +47,32 @@ var invTName = []string{"Overwrite", "Slow", "Clear"}
|
|||||||
// rolled from the level at creation time.
|
// rolled from the level at creation time.
|
||||||
var monsterTable = [26]MonsterKind{
|
var monsterTable = [26]MonsterKind{
|
||||||
/* Name CARRY FLAGS str exp lvl arm hp dmg */
|
/* Name CARRY FLAGS str exp lvl arm hp dmg */
|
||||||
{"aquator", 0, IsMean, Stats{10, 20, 5, 2, 1, "0x0/0x0", 0}},
|
{"aquator", 0, Mean, Stats{10, 20, 5, 2, 1, "0x0/0x0", 0}},
|
||||||
{"bat", 0, IsFly, Stats{10, 1, 1, 3, 1, "1x2", 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}},
|
{"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}},
|
{"dragon", 100, Mean, Stats{10, 5000, 10, -1, 1, "1x8/1x8/3x10", 0}},
|
||||||
{"emu", 0, IsMean, Stats{10, 2, 1, 7, 1, "1x2", 0}},
|
{"emu", 0, Mean, Stats{10, 2, 1, 7, 1, "1x2", 0}},
|
||||||
{"venus flytrap", 0, IsMean, Stats{10, 80, 8, 3, 1, "%%%x0", 0}},
|
{"venus flytrap", 0, Mean, Stats{10, 80, 8, 3, 1, "%%%x0", 0}},
|
||||||
{"griffin", 20, IsMean | IsFly | IsRegen, Stats{10, 2000, 13, 2, 1, "4x3/3x5", 0}},
|
{"griffin", 20, Mean | Flying | Regenerates, Stats{10, 2000, 13, 2, 1, "4x3/3x5", 0}},
|
||||||
{"hobgoblin", 0, IsMean, Stats{10, 3, 1, 5, 1, "1x8", 0}},
|
{"hobgoblin", 0, Mean, Stats{10, 3, 1, 5, 1, "1x8", 0}},
|
||||||
{"ice monster", 0, 0, Stats{10, 5, 1, 9, 1, "0x0", 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}},
|
{"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}},
|
{"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}},
|
{"nymph", 100, 0, Stats{10, 37, 3, 9, 1, "0x0", 0}},
|
||||||
{"orc", 15, IsGreed, Stats{10, 5, 1, 6, 1, "1x8", 0}},
|
{"orc", 15, Greedy, Stats{10, 5, 1, 6, 1, "1x8", 0}},
|
||||||
{"phantom", 0, IsInvis, Stats{10, 120, 8, 3, 1, "4x4", 0}},
|
{"phantom", 0, Invisible, Stats{10, 120, 8, 3, 1, "4x4", 0}},
|
||||||
{"quagga", 0, IsMean, Stats{10, 15, 3, 3, 1, "1x5/1x5", 0}},
|
{"quagga", 0, Mean, Stats{10, 15, 3, 3, 1, "1x5/1x5", 0}},
|
||||||
{"rattlesnake", 0, IsMean, Stats{10, 9, 2, 3, 1, "1x6", 0}},
|
{"rattlesnake", 0, Mean, Stats{10, 9, 2, 3, 1, "1x6", 0}},
|
||||||
{"snake", 0, IsMean, Stats{10, 2, 1, 5, 1, "1x3", 0}},
|
{"snake", 0, Mean, Stats{10, 2, 1, 5, 1, "1x3", 0}},
|
||||||
{"troll", 50, IsRegen | IsMean, Stats{10, 120, 6, 4, 1, "1x8/1x8/2x6", 0}},
|
{"troll", 50, Regenerates | Mean, Stats{10, 120, 6, 4, 1, "1x8/1x8/2x6", 0}},
|
||||||
{"black unicorn", 0, IsMean, Stats{10, 190, 7, -2, 1, "1x9/1x9/2x9", 0}},
|
{"black unicorn", 0, Mean, Stats{10, 190, 7, -2, 1, "1x9/1x9/2x9", 0}},
|
||||||
{"vampire", 20, IsRegen | IsMean, Stats{10, 350, 8, 1, 1, "1x10", 0}},
|
{"vampire", 20, Regenerates | Mean, Stats{10, 350, 8, 1, 1, "1x10", 0}},
|
||||||
{"wraith", 0, 0, Stats{10, 55, 5, 4, 1, "1x6", 0}},
|
{"wraith", 0, 0, Stats{10, 55, 5, 4, 1, "1x6", 0}},
|
||||||
{"xeroc", 30, 0, Stats{10, 100, 7, 7, 1, "4x4", 0}},
|
{"xeroc", 30, 0, Stats{10, 100, 7, 7, 1, "4x4", 0}},
|
||||||
{"yeti", 30, 0, Stats{10, 50, 4, 6, 1, "1x6/1x6", 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
|
// Base ObjInfo tables (extern.c). These are templates: NewGame copies them
|
||||||
@@ -88,7 +88,7 @@ var baseThings = [NumThings]ObjInfo{
|
|||||||
{Prob: 4}, // stick
|
{Prob: 4}, // stick
|
||||||
}
|
}
|
||||||
|
|
||||||
var baseArmInfo = [MaxArmors]ObjInfo{
|
var baseArmInfo = [NumArmorTypes]ObjInfo{
|
||||||
{Name: "leather armor", Prob: 20, Worth: 20},
|
{Name: "leather armor", Prob: 20, Worth: 20},
|
||||||
{Name: "ring mail", Prob: 15, Worth: 25},
|
{Name: "ring mail", Prob: 15, Worth: 25},
|
||||||
{Name: "studded leather armor", Prob: 15, Worth: 20},
|
{Name: "studded leather armor", Prob: 15, Worth: 20},
|
||||||
@@ -99,7 +99,7 @@ var baseArmInfo = [MaxArmors]ObjInfo{
|
|||||||
{Name: "plate mail", Prob: 5, Worth: 150},
|
{Name: "plate mail", Prob: 5, Worth: 150},
|
||||||
}
|
}
|
||||||
|
|
||||||
var basePotInfo = [MaxPotions]ObjInfo{
|
var basePotInfo = [NumPotionTypes]ObjInfo{
|
||||||
{Name: "confusion", Prob: 7, Worth: 5},
|
{Name: "confusion", Prob: 7, Worth: 5},
|
||||||
{Name: "hallucination", Prob: 8, Worth: 5},
|
{Name: "hallucination", Prob: 8, Worth: 5},
|
||||||
{Name: "poison", Prob: 8, Worth: 5},
|
{Name: "poison", Prob: 8, Worth: 5},
|
||||||
@@ -116,7 +116,7 @@ var basePotInfo = [MaxPotions]ObjInfo{
|
|||||||
{Name: "levitation", Prob: 6, Worth: 75},
|
{Name: "levitation", Prob: 6, Worth: 75},
|
||||||
}
|
}
|
||||||
|
|
||||||
var baseRingInfo = [MaxRings]ObjInfo{
|
var baseRingInfo = [NumRingTypes]ObjInfo{
|
||||||
{Name: "protection", Prob: 9, Worth: 400},
|
{Name: "protection", Prob: 9, Worth: 400},
|
||||||
{Name: "add strength", Prob: 9, Worth: 400},
|
{Name: "add strength", Prob: 9, Worth: 400},
|
||||||
{Name: "sustain strength", Prob: 5, Worth: 280},
|
{Name: "sustain strength", Prob: 5, Worth: 280},
|
||||||
@@ -133,7 +133,7 @@ var baseRingInfo = [MaxRings]ObjInfo{
|
|||||||
{Name: "maintain armor", Prob: 5, Worth: 380},
|
{Name: "maintain armor", Prob: 5, Worth: 380},
|
||||||
}
|
}
|
||||||
|
|
||||||
var baseScrInfo = [MaxScrolls]ObjInfo{
|
var baseScrInfo = [NumScrollTypes]ObjInfo{
|
||||||
{Name: "monster confusion", Prob: 7, Worth: 140},
|
{Name: "monster confusion", Prob: 7, Worth: 140},
|
||||||
{Name: "magic mapping", Prob: 4, Worth: 150},
|
{Name: "magic mapping", Prob: 4, Worth: 150},
|
||||||
{Name: "hold monster", Prob: 2, Worth: 180},
|
{Name: "hold monster", Prob: 2, Worth: 180},
|
||||||
@@ -154,7 +154,7 @@ var baseScrInfo = [MaxScrolls]ObjInfo{
|
|||||||
{Name: "protect armor", Prob: 2, Worth: 250},
|
{Name: "protect armor", Prob: 2, Worth: 250},
|
||||||
}
|
}
|
||||||
|
|
||||||
var baseWeapInfo = [MaxWeapons + 1]ObjInfo{
|
var baseWeapInfo = [NumWeaponTypes + 1]ObjInfo{
|
||||||
{Name: "mace", Prob: 11, Worth: 8},
|
{Name: "mace", Prob: 11, Worth: 8},
|
||||||
{Name: "long sword", Prob: 11, Worth: 15},
|
{Name: "long sword", Prob: 11, Worth: 15},
|
||||||
{Name: "short bow", Prob: 12, 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
|
{}, // DO NOT REMOVE: fake entry for dragon's breath
|
||||||
}
|
}
|
||||||
|
|
||||||
var baseWsInfo = [MaxSticks]ObjInfo{
|
var baseWsInfo = [NumWandTypes]ObjInfo{
|
||||||
{Name: "light", Prob: 12, Worth: 250},
|
{Name: "light", Prob: 12, Worth: 250},
|
||||||
{Name: "invisibility", Prob: 6, Worth: 5},
|
{Name: "invisibility", Prob: 6, Worth: 5},
|
||||||
{Name: "lightning", Prob: 3, Worth: 330},
|
{Name: "lightning", Prob: 3, Worth: 330},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func TestProbabilitiesSumTo100(t *testing.T) {
|
|||||||
"scrolls": baseScrInfo[:],
|
"scrolls": baseScrInfo[:],
|
||||||
"rings": baseRingInfo[:],
|
"rings": baseRingInfo[:],
|
||||||
"sticks": baseWsInfo[:],
|
"sticks": baseWsInfo[:],
|
||||||
"weapons": baseWeapInfo[:MaxWeapons], // excludes the flame entry
|
"weapons": baseWeapInfo[:NumWeaponTypes], // excludes the flame entry
|
||||||
"armor": baseArmInfo[:],
|
"armor": baseArmInfo[:],
|
||||||
}
|
}
|
||||||
for name, tab := range tables {
|
for name, tab := range tables {
|
||||||
@@ -29,11 +29,11 @@ func TestProbabilitiesSumTo100(t *testing.T) {
|
|||||||
|
|
||||||
func TestInitProbsCumulative(t *testing.T) {
|
func TestInitProbsCumulative(t *testing.T) {
|
||||||
g := NewGame(Config{Seed: 1})
|
g := NewGame(Config{Seed: 1})
|
||||||
last := g.Items.Potions[MaxPotions-1].Prob
|
last := g.Items.Potions[NumPotionTypes-1].Prob
|
||||||
if last != 100 {
|
if last != 100 {
|
||||||
t.Errorf("cumulative potion probability ends at %d, want 100", last)
|
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 {
|
if g.Items.Potions[i].Prob < g.Items.Potions[i-1].Prob {
|
||||||
t.Errorf("potion probs not nondecreasing at %d", i)
|
t.Errorf("potion probs not nondecreasing at %d", i)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func (g *RogueGame) invName(obj *Object, drop bool) string {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(&pb, "A%s ", vowelstr(sp))
|
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)
|
fmt.Fprintf(&pb, "%s %s", num(obj.HPlus, obj.DPlus, Weapon), sp)
|
||||||
} else {
|
} else {
|
||||||
pb.WriteString(sp)
|
pb.WriteString(sp)
|
||||||
@@ -68,7 +68,7 @@ func (g *RogueGame) invName(obj *Object, drop bool) string {
|
|||||||
}
|
}
|
||||||
case Armor:
|
case Armor:
|
||||||
sp := it.Armors[which].Name
|
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)
|
fmt.Fprintf(&pb, "%s %s [", num(aClass[which]-obj.Arm, 0, Armor), sp)
|
||||||
if !g.Options.Terse {
|
if !g.Options.Terse {
|
||||||
pb.WriteString("protection ")
|
pb.WriteString("protection ")
|
||||||
@@ -151,7 +151,7 @@ func (g *RogueGame) dropCheck(obj *Object) bool {
|
|||||||
obj != p.CurRing[Left] && obj != p.CurRing[Right] {
|
obj != p.CurRing[Left] && obj != p.CurRing[Right] {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if obj.Flags.Has(IsCursed) {
|
if obj.Flags.Has(Cursed) {
|
||||||
g.msg("you can't. It appears to be cursed")
|
g.msg("you can't. It appears to be cursed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -167,9 +167,9 @@ func (g *RogueGame) dropCheck(obj *Object) bool {
|
|||||||
}
|
}
|
||||||
p.CurRing[hand] = nil
|
p.CurRing[hand] = nil
|
||||||
switch obj.Which {
|
switch obj.Which {
|
||||||
case RAddStr:
|
case RingAddStrength:
|
||||||
g.chgStr(-obj.Arm)
|
g.chgStr(-obj.Arm)
|
||||||
case RSeeInvis:
|
case RingSeeInvisible:
|
||||||
g.unsee(0)
|
g.unsee(0)
|
||||||
g.Extinguish(DUnsee)
|
g.Extinguish(DUnsee)
|
||||||
}
|
}
|
||||||
@@ -209,9 +209,9 @@ func (g *RogueGame) newThing() *Object {
|
|||||||
cur.Which = 1
|
cur.Which = 1
|
||||||
}
|
}
|
||||||
case 3:
|
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 {
|
if r := g.rnd(100); r < 10 {
|
||||||
cur.Flags.Set(IsCursed)
|
cur.Flags.Set(Cursed)
|
||||||
cur.HPlus -= g.rnd(3) + 1
|
cur.HPlus -= g.rnd(3) + 1
|
||||||
} else if r < 15 {
|
} else if r < 15 {
|
||||||
cur.HPlus += g.rnd(3) + 1
|
cur.HPlus += g.rnd(3) + 1
|
||||||
@@ -221,7 +221,7 @@ func (g *RogueGame) newThing() *Object {
|
|||||||
cur.Which = pickOne(g, g.Items.Armors[:])
|
cur.Which = pickOne(g, g.Items.Armors[:])
|
||||||
cur.Arm = aClass[cur.Which]
|
cur.Arm = aClass[cur.Which]
|
||||||
if r := g.rnd(100); r < 20 {
|
if r := g.rnd(100); r < 20 {
|
||||||
cur.Flags.Set(IsCursed)
|
cur.Flags.Set(Cursed)
|
||||||
cur.Arm += g.rnd(3) + 1
|
cur.Arm += g.rnd(3) + 1
|
||||||
} else if r < 28 {
|
} else if r < 28 {
|
||||||
cur.Arm -= g.rnd(3) + 1
|
cur.Arm -= g.rnd(3) + 1
|
||||||
@@ -230,13 +230,13 @@ func (g *RogueGame) newThing() *Object {
|
|||||||
cur.Type = Ring
|
cur.Type = Ring
|
||||||
cur.Which = pickOne(g, g.Items.Rings[:])
|
cur.Which = pickOne(g, g.Items.Rings[:])
|
||||||
switch cur.Which {
|
switch cur.Which {
|
||||||
case RAddStr, RProtect, RAddHit, RAddDam:
|
case RingAddStrength, RingProtection, RingDexterity, RingIncreaseDamage:
|
||||||
if cur.Arm = g.rnd(3); cur.Arm == 0 {
|
if cur.Arm = g.rnd(3); cur.Arm == 0 {
|
||||||
cur.Arm = -1
|
cur.Arm = -1
|
||||||
cur.Flags.Set(IsCursed)
|
cur.Flags.Set(Cursed)
|
||||||
}
|
}
|
||||||
case RAggr, RTeleport:
|
case RingAggravateMonsters, RingTeleportation:
|
||||||
cur.Flags.Set(IsCursed)
|
cur.Flags.Set(Cursed)
|
||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
cur.Type = Stick
|
cur.Type = Stick
|
||||||
@@ -525,7 +525,7 @@ func (g *RogueGame) prList() {
|
|||||||
case Armor:
|
case Armor:
|
||||||
g.prSpec(g.Items.Armors[:])
|
g.prSpec(g.Items.Armors[:])
|
||||||
case Weapon:
|
case Weapon:
|
||||||
g.prSpec(g.Items.Weapons[:MaxWeapons])
|
g.prSpec(g.Items.Weapons[:NumWeaponTypes])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
256
game/types.go
256
game/types.go
@@ -100,9 +100,9 @@ const (
|
|||||||
type RoomFlags int16
|
type RoomFlags int16
|
||||||
|
|
||||||
const (
|
const (
|
||||||
IsDark RoomFlags = 1 << iota // room is dark
|
Dark RoomFlags = 1 << iota // room is dark
|
||||||
IsGone // room is gone (a corridor)
|
Gone // room is gone (a corridor)
|
||||||
IsMaze // room is a maze
|
Maze // room is a maze
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f RoomFlags) Has(b RoomFlags) bool { return f&b != 0 }
|
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
|
type ObjFlags int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
IsCursed ObjFlags = 1 << iota // object is cursed
|
Cursed ObjFlags = 1 << iota // ISCURSED: object is cursed
|
||||||
IsKnow // player knows details about the object
|
Known // ISKNOW: player knows details about the object
|
||||||
IsMissl // object is a missile type
|
Missile // ISMISL: object is a missile type
|
||||||
IsMany // object comes in groups
|
Stackable // ISMANY: object comes in groups
|
||||||
ObjIsFound // object has been seen (ISFOUND shares the bit with creatures)
|
WasFound // ISFOUND (objects): object has been seen (ISFOUND shares the bit with creatures)
|
||||||
IsProt // armor is permanently protected
|
Protected // ISPROT: armor is permanently protected
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f ObjFlags) Has(b ObjFlags) bool { return f&b != 0 }
|
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
|
type CreatureFlags int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CanHuh CreatureFlags = 0o000001 // creature can confuse
|
CanConfuse CreatureFlags = 0o000001 // CANHUH: creature can confuse
|
||||||
CanSee CreatureFlags = 0o000002 // creature can see invisible creatures
|
CanSeeInvisible CreatureFlags = 0o000002 // CANSEE: creature can see invisible creatures
|
||||||
IsBlind CreatureFlags = 0o000004 // creature is blind
|
Blind CreatureFlags = 0o000004 // ISBLIND: creature is blind
|
||||||
IsCanc CreatureFlags = 0o000010 // creature has special qualities cancelled
|
Cancelled CreatureFlags = 0o000010 // ISCANC: creature has special qualities cancelled
|
||||||
IsLevit CreatureFlags = 0o000010 // hero is levitating
|
Levitating CreatureFlags = 0o000010 // ISLEVIT: hero is levitating
|
||||||
IsFound CreatureFlags = 0o000020 // creature has been seen
|
Found CreatureFlags = 0o000020 // ISFOUND: creature has been seen
|
||||||
IsGreed CreatureFlags = 0o000040 // creature runs to protect gold
|
Greedy CreatureFlags = 0o000040 // ISGREED: creature runs to protect gold
|
||||||
IsHaste CreatureFlags = 0o000100 // creature has been hastened
|
Hasted CreatureFlags = 0o000100 // ISHASTE: creature has been hastened
|
||||||
IsTarget CreatureFlags = 0o000200 // creature is the target of an 'f' command
|
Targeted CreatureFlags = 0o000200 // ISTARGET: creature is the target of an 'f' command
|
||||||
IsHeld CreatureFlags = 0o000400 // creature has been held
|
Held CreatureFlags = 0o000400 // ISHELD: creature has been held
|
||||||
IsHuh CreatureFlags = 0o001000 // creature is confused
|
Confused CreatureFlags = 0o001000 // ISHUH: creature is confused
|
||||||
IsInvis CreatureFlags = 0o002000 // creature is invisible
|
Invisible CreatureFlags = 0o002000 // ISINVIS: creature is invisible
|
||||||
IsMean CreatureFlags = 0o004000 // creature can wake when player enters room
|
Mean CreatureFlags = 0o004000 // ISMEAN: creature can wake when player enters room
|
||||||
IsHalu CreatureFlags = 0o004000 // hero is on acid trip
|
Hallucinating CreatureFlags = 0o004000 // ISHALU: hero is on acid trip
|
||||||
IsRegen CreatureFlags = 0o010000 // creature can regenerate
|
Regenerates CreatureFlags = 0o010000 // ISREGEN: creature can regenerate
|
||||||
IsRun CreatureFlags = 0o020000 // creature is running at the player
|
Awake CreatureFlags = 0o020000 // ISRUN: creature is running at the player
|
||||||
SeeMonst CreatureFlags = 0o040000 // hero can detect unseen monsters
|
SenseMonsters CreatureFlags = 0o040000 // SEEMONST: hero can detect unseen monsters
|
||||||
IsFly CreatureFlags = 0o040000 // creature can fly
|
Flying CreatureFlags = 0o040000 // ISFLY: creature can fly
|
||||||
IsSlow CreatureFlags = 0o100000 // creature has been slowed
|
Slowed CreatureFlags = 0o100000 // ISSLOW: creature has been slowed
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f CreatureFlags) Has(b CreatureFlags) bool { return f&b != 0 }
|
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
|
type PlaceFlags uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FPass PlaceFlags = 0x80 // is a passageway
|
FPassage PlaceFlags = 0x80 // F_PASS: is a passageway
|
||||||
FSeen PlaceFlags = 0x40 // have seen this spot before
|
FSeen PlaceFlags = 0x40 // have seen this spot before
|
||||||
FDropped PlaceFlags = 0x20 // object was dropped here
|
FDropped PlaceFlags = 0x20 // object was dropped here
|
||||||
FLocked PlaceFlags = 0x20 // door is locked
|
FLocked PlaceFlags = 0x20 // door is locked
|
||||||
FReal PlaceFlags = 0x10 // what you see is what you get
|
FReal PlaceFlags = 0x10 // what you see is what you get
|
||||||
FPNum PlaceFlags = 0x0f // passage number mask
|
FPassNum PlaceFlags = 0x0f // F_PNUM: passage number mask
|
||||||
FTMask PlaceFlags = 0x07 // trap number mask
|
FTrapMask PlaceFlags = 0x07 // F_TMASK: trap number mask
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f PlaceFlags) Has(b PlaceFlags) bool { return f&b != 0 }
|
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)
|
// Trap types (rogue.h)
|
||||||
const (
|
const (
|
||||||
TDoor = 0
|
TrapDoor = 0
|
||||||
TArrow = 1
|
TrapArrow = 1
|
||||||
TSleep = 2
|
TrapSleep = 2
|
||||||
TBear = 3
|
TrapBear = 3
|
||||||
TTelep = 4
|
TrapTeleport = 4
|
||||||
TDart = 5
|
TrapDart = 5
|
||||||
TRust = 6
|
TrapRust = 6
|
||||||
TMyst = 7
|
TrapMystery = 7
|
||||||
NTraps = 8
|
NumTrapTypes = 8
|
||||||
)
|
)
|
||||||
|
|
||||||
// Potion types (rogue.h)
|
// Potion types (rogue.h)
|
||||||
const (
|
const (
|
||||||
PConfuse = iota
|
PotionConfusion = iota
|
||||||
PLSD
|
PotionLSD
|
||||||
PPoison
|
PotionPoison
|
||||||
PStrength
|
PotionGainStrength
|
||||||
PSeeInvis
|
PotionSeeInvisible
|
||||||
PHealing
|
PotionHealing
|
||||||
PMFind
|
PotionDetectMonsters
|
||||||
PTFind
|
PotionDetectMagic
|
||||||
PRaise
|
PotionRaiseLevel
|
||||||
PXHeal
|
PotionExtraHealing
|
||||||
PHaste
|
PotionHaste
|
||||||
PRestore
|
PotionRestoreStrength
|
||||||
PBlind
|
PotionBlindness
|
||||||
PLevit
|
PotionLevitation
|
||||||
MaxPotions
|
NumPotionTypes
|
||||||
)
|
)
|
||||||
|
|
||||||
// Scroll types (rogue.h)
|
// Scroll types (rogue.h)
|
||||||
const (
|
const (
|
||||||
SConfuse = iota
|
ScrollMonsterConfusion = iota
|
||||||
SMap
|
ScrollMagicMapping
|
||||||
SHold
|
ScrollHoldMonster
|
||||||
SSleep
|
ScrollSleep
|
||||||
SArmor
|
ScrollEnchantArmor
|
||||||
SIDPotion
|
ScrollIdentifyPotion
|
||||||
SIDScroll
|
ScrollIdentifyScroll
|
||||||
SIDWeapon
|
ScrollIdentifyWeapon
|
||||||
SIDArmor
|
ScrollIdentifyArmor
|
||||||
SIDRorS
|
ScrollIdentifyRingOrStick
|
||||||
SScare
|
ScrollScareMonster
|
||||||
SFDet
|
ScrollFoodDetection
|
||||||
STelep
|
ScrollTeleportation
|
||||||
SEnch
|
ScrollEnchantWeapon
|
||||||
SCreate
|
ScrollCreateMonster
|
||||||
SRemove
|
ScrollRemoveCurse
|
||||||
SAggr
|
ScrollAggravateMonsters
|
||||||
SProtect
|
ScrollProtectArmor
|
||||||
MaxScrolls
|
NumScrollTypes
|
||||||
)
|
)
|
||||||
|
|
||||||
// Weapon types (rogue.h)
|
// Weapon types (rogue.h)
|
||||||
const (
|
const (
|
||||||
Mace = iota
|
WeaponMace = iota
|
||||||
Sword
|
WeaponLongSword
|
||||||
Bow
|
WeaponBow
|
||||||
Arrow
|
WeaponArrow
|
||||||
Dagger
|
WeaponDagger
|
||||||
TwoSword
|
WeaponTwoHandedSword
|
||||||
Dart
|
WeaponDart
|
||||||
Shiraken
|
WeaponShuriken
|
||||||
Spear
|
WeaponSpear
|
||||||
Flame // fake entry for dragon breath (ick)
|
WeaponFlame // fake entry for dragon breath (ick)
|
||||||
MaxWeapons = Flame
|
NumWeaponTypes = WeaponFlame
|
||||||
)
|
)
|
||||||
|
|
||||||
// Armor types (rogue.h)
|
// Armor types (rogue.h)
|
||||||
const (
|
const (
|
||||||
Leather = iota
|
ArmorLeather = iota
|
||||||
RingMail
|
ArmorRingMail
|
||||||
StuddedLeather
|
ArmorStuddedLeather
|
||||||
ScaleMail
|
ArmorScaleMail
|
||||||
ChainMail
|
ArmorChainMail
|
||||||
SplintMail
|
ArmorSplintMail
|
||||||
BandedMail
|
ArmorBandedMail
|
||||||
PlateMail
|
ArmorPlateMail
|
||||||
MaxArmors
|
NumArmorTypes
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ring types (rogue.h)
|
// Ring types (rogue.h)
|
||||||
const (
|
const (
|
||||||
RProtect = iota
|
RingProtection = iota
|
||||||
RAddStr
|
RingAddStrength
|
||||||
RSustStr
|
RingSustainStrength
|
||||||
RSearch
|
RingSearching
|
||||||
RSeeInvis
|
RingSeeInvisible
|
||||||
RNop
|
RingAdornment
|
||||||
RAggr
|
RingAggravateMonsters
|
||||||
RAddHit
|
RingDexterity
|
||||||
RAddDam
|
RingIncreaseDamage
|
||||||
RRegen
|
RingRegeneration
|
||||||
RDigest
|
RingSlowDigestion
|
||||||
RTeleport
|
RingTeleportation
|
||||||
RStealth
|
RingStealth
|
||||||
RSustArm
|
RingMaintainArmor
|
||||||
MaxRings
|
NumRingTypes
|
||||||
)
|
)
|
||||||
|
|
||||||
// Rod/Wand/Staff types (rogue.h)
|
// Rod/Wand/Staff types (rogue.h)
|
||||||
const (
|
const (
|
||||||
WsLight = iota
|
WandLight = iota
|
||||||
WsInvis
|
WandInvisibility
|
||||||
WsElect
|
WandLightning
|
||||||
WsFire
|
WandFire
|
||||||
WsCold
|
WandCold
|
||||||
WsPolymorph
|
WandPolymorph
|
||||||
WsMissile
|
WandMagicMissile
|
||||||
WsHasteM
|
WandHasteMonster
|
||||||
WsSlowM
|
WandSlowMonster
|
||||||
WsDrain
|
WandDrainLife
|
||||||
WsNop
|
WandNothing
|
||||||
WsTelAway
|
WandTeleportAway
|
||||||
WsTelTo
|
WandTeleportTo
|
||||||
WsCancel
|
WandCancellation
|
||||||
MaxSticks
|
NumWandTypes
|
||||||
)
|
)
|
||||||
|
|
||||||
// Coord is a position on the level (rogue.h coord). A value type: the C
|
// Coord is a position on the level (rogue.h coord). A value type: the C
|
||||||
|
|||||||
@@ -122,21 +122,21 @@ func (g *RogueGame) wield() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initWeaps is the weapons.c init_dam[] table.
|
// initWeaps is the weapons.c init_dam[] table.
|
||||||
var initWeaps = [MaxWeapons]struct {
|
var initWeaps = [NumWeaponTypes]struct {
|
||||||
dam string // damage when wielded
|
dam string // damage when wielded
|
||||||
hrl string // damage when thrown
|
hrl string // damage when thrown
|
||||||
launch int // launching weapon
|
launch int // launching weapon
|
||||||
flags ObjFlags
|
flags ObjFlags
|
||||||
}{
|
}{
|
||||||
{"2x4", "1x3", noWeapon, 0}, // Mace
|
{"2x4", "1x3", noWeapon, 0}, // WeaponMace
|
||||||
{"3x4", "1x2", noWeapon, 0}, // Long sword
|
{"3x4", "1x2", noWeapon, 0}, // Long sword
|
||||||
{"1x1", "1x1", noWeapon, 0}, // Bow
|
{"1x1", "1x1", noWeapon, 0}, // WeaponBow
|
||||||
{"1x1", "2x3", Bow, IsMany | IsMissl}, // Arrow
|
{"1x1", "2x3", WeaponBow, Stackable | Missile}, // WeaponArrow
|
||||||
{"1x6", "1x4", noWeapon, IsMissl}, // Dagger
|
{"1x6", "1x4", noWeapon, Missile}, // WeaponDagger
|
||||||
{"4x4", "1x2", noWeapon, 0}, // 2h sword
|
{"4x4", "1x2", noWeapon, 0}, // 2h sword
|
||||||
{"1x1", "1x3", noWeapon, IsMany | IsMissl}, // Dart
|
{"1x1", "1x3", noWeapon, Stackable | Missile}, // WeaponDart
|
||||||
{"1x2", "2x4", noWeapon, IsMany | IsMissl}, // Shuriken
|
{"1x2", "2x4", noWeapon, Stackable | Missile}, // Shuriken
|
||||||
{"2x3", "1x6", noWeapon, IsMissl}, // Spear
|
{"2x3", "1x6", noWeapon, Missile}, // WeaponSpear
|
||||||
}
|
}
|
||||||
|
|
||||||
// initWeapon sets up a new weapon (weapons.c init_weapon).
|
// 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.Flags = iwp.flags
|
||||||
weap.HPlus = 0
|
weap.HPlus = 0
|
||||||
weap.DPlus = 0
|
weap.DPlus = 0
|
||||||
if which == Dagger {
|
if which == WeaponDagger {
|
||||||
weap.Count = g.rnd(4) + 2
|
weap.Count = g.rnd(4) + 2
|
||||||
weap.Group = g.Items.Group
|
weap.Group = g.Items.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.Count = g.rnd(8) + 8
|
||||||
weap.Group = g.Items.Group
|
weap.Group = g.Items.Group
|
||||||
g.Items.Group++
|
g.Items.Group++
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (g *RogueGame) createObj() {
|
|||||||
bless := g.readchar()
|
bless := g.readchar()
|
||||||
g.Msgs.Mpos = 0
|
g.Msgs.Mpos = 0
|
||||||
if bless == '-' {
|
if bless == '-' {
|
||||||
obj.Flags.Set(IsCursed)
|
obj.Flags.Set(Cursed)
|
||||||
}
|
}
|
||||||
if obj.Type == Weapon {
|
if obj.Type == Weapon {
|
||||||
g.initWeapon(obj, obj.Which)
|
g.initWeapon(obj, obj.Which)
|
||||||
@@ -48,18 +48,18 @@ func (g *RogueGame) createObj() {
|
|||||||
}
|
}
|
||||||
case obj.Type == Ring:
|
case obj.Type == Ring:
|
||||||
switch obj.Which {
|
switch obj.Which {
|
||||||
case RProtect, RAddStr, RAddHit, RAddDam:
|
case RingProtection, RingAddStrength, RingDexterity, RingIncreaseDamage:
|
||||||
g.msg("blessing? (+,-,n)")
|
g.msg("blessing? (+,-,n)")
|
||||||
bless := g.readchar()
|
bless := g.readchar()
|
||||||
g.Msgs.Mpos = 0
|
g.Msgs.Mpos = 0
|
||||||
if bless == '-' {
|
if bless == '-' {
|
||||||
obj.Flags.Set(IsCursed)
|
obj.Flags.Set(Cursed)
|
||||||
obj.Arm = -1
|
obj.Arm = -1
|
||||||
} else {
|
} else {
|
||||||
obj.Arm = g.rnd(2) + 1
|
obj.Arm = g.rnd(2) + 1
|
||||||
}
|
}
|
||||||
case RAggr, RTeleport:
|
case RingAggravateMonsters, RingTeleportation:
|
||||||
obj.Flags.Set(IsCursed)
|
obj.Flags.Set(Cursed)
|
||||||
}
|
}
|
||||||
case obj.Type == Stick:
|
case obj.Type == Stick:
|
||||||
g.fixStick(obj)
|
g.fixStick(obj)
|
||||||
@@ -131,7 +131,7 @@ func (g *RogueGame) whatis(insist bool, typ int) {
|
|||||||
case Stick:
|
case Stick:
|
||||||
setKnow(obj, g.Items.Sticks[:])
|
setKnow(obj, g.Items.Sticks[:])
|
||||||
case Weapon, Armor:
|
case Weapon, Armor:
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
case Ring:
|
case Ring:
|
||||||
setKnow(obj, g.Items.Rings[:])
|
setKnow(obj, g.Items.Rings[:])
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ func (g *RogueGame) whatis(insist bool, typ int) {
|
|||||||
// set_know).
|
// set_know).
|
||||||
func setKnow(obj *Object, info []ObjInfo) {
|
func setKnow(obj *Object, info []ObjInfo) {
|
||||||
info[obj.Which].Know = true
|
info[obj.Which].Know = true
|
||||||
obj.Flags.Set(IsKnow)
|
obj.Flags.Set(Known)
|
||||||
info[obj.Which].Guess = ""
|
info[obj.Which].Guess = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,8 +187,8 @@ func (g *RogueGame) teleport() {
|
|||||||
g.mvaddch(p.Pos.Y, p.Pos.X, PlayerCh)
|
g.mvaddch(p.Pos.Y, p.Pos.X, PlayerCh)
|
||||||
// turn off ISHELD in case teleportation was done while fighting a
|
// turn off ISHELD in case teleportation was done while fighting a
|
||||||
// Flytrap
|
// Flytrap
|
||||||
if p.On(IsHeld) {
|
if p.On(Held) {
|
||||||
p.Flags.Clear(IsHeld)
|
p.Flags.Clear(Held)
|
||||||
p.VfHit = 0
|
p.VfHit = 0
|
||||||
g.Monsters['F'-'A'].Stats.Dmg = "000x0"
|
g.Monsters['F'-'A'].Stats.Dmg = "000x0"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user