Skip to content

Commit

Permalink
let monsters benefit from rings of searching, as per PLAYING.markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikolaj committed Jul 23, 2011
1 parent d0ae836 commit e696d1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Actions.hs
Expand Up @@ -252,11 +252,14 @@ actorOpenClose actor v o dir =
let isPlayer = actor == pl let isPlayer = actor == pl
let isVerbose = v && isPlayer let isVerbose = v && isPlayer
let dloc = shift loc dir -- location we act upon let dloc = shift loc dir -- location we act upon
let openPower = case strongestItem (mitems body) "ring" of
Just i -> niq (mkind body) + ipower i
Nothing -> niq (mkind body)
in case lmap `at` dloc of in case lmap `at` dloc of
Tile d@(Door hv o') [] Tile d@(Door hv o') []
| secret o' && isPlayer -> -- door is secret, cannot be opened or closed by the player | secret o' && isPlayer -> -- door is secret, cannot be opened or closed by the player
neverMind isVerbose neverMind isVerbose
| maybe o ((|| not o) . (>= (niq (mkind body)))) o' -> | maybe o ((|| not o) . (>= openPower)) o' ->
-- door is in unsuitable state -- door is in unsuitable state
abortIfWith isVerbose ("already " ++ txt) abortIfWith isVerbose ("already " ++ txt)
| not (unoccupied hms dloc) -> | not (unoccupied hms dloc) ->
Expand Down
8 changes: 6 additions & 2 deletions src/StrategyState.hs
Expand Up @@ -97,8 +97,12 @@ strategy actor
onlyKeepsDir_9 = only (\ x -> maybe True (\ d -> neg x /= d) mdir) onlyKeepsDir_9 = only (\ x -> maybe True (\ d -> neg x /= d) mdir)
onlyUnoccupied = onlyMoves (unoccupied (levelMonsterList delState)) me onlyUnoccupied = onlyMoves (unoccupied (levelMonsterList delState)) me
-- Monsters don't see doors more secret than that. Enforced when actually -- Monsters don't see doors more secret than that. Enforced when actually
-- opening doors, too, so that monsters don't cheat. -- opening doors, too, so that monsters don't cheat. TODO: remove the code
openableHere = openable (niq mk) lmap -- duplication, though.
openPower = case strongestItem items "ring" of
Just i -> niq mk + ipower i
Nothing -> niq mk
openableHere = openable openPower lmap
onlyOpenable = onlyMoves openableHere me onlyOpenable = onlyMoves openableHere me
accessibleHere = accessible lmap me accessibleHere = accessible lmap me
onlySensible = onlyMoves (\ l -> accessibleHere l || openableHere l) me onlySensible = onlyMoves (\ l -> accessibleHere l || openableHere l) me
Expand Down

0 comments on commit e696d1f

Please sign in to comment.