Skip to content

Commit

Permalink
improve target reset and guard commands that can use items from the f…
Browse files Browse the repository at this point in the history
…loor
  • Loading branch information
Mikolaj committed Apr 8, 2011
1 parent e4e6055 commit 4dfcb34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/Actions.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -416,13 +416,16 @@ search =
modify (updateLevel (updateLMap (const slmap))) modify (updateLevel (updateLMap (const slmap)))
playerAdvanceTime playerAdvanceTime


-- | Start the floor targeting mode or toggle between the two floor modes. -- | Start the floor targeting mode or reset the cursor location to the player.
targetFloor :: Action () targetFloor :: Action ()
targetFloor = do targetFloor = do
target <- gets (mtarget . getPlayerBody) ploc <- gets (mloc . getPlayerBody)
target <- gets (mtarget . getPlayerBody)
targeting <- gets (ctargeting . scursor)
let tgt = case target of let tgt = case target of
TLoc l -> TLoc l -- don't forget the old location target too fast _ | targeting -> TLoc ploc -- double key press: reset cursor
_ -> TCursor TEnemy _ _ -> TCursor -- forget enemy target, keep the cursor
t -> t -- keep the target from previous targeting session
updatePlayerBody (\ p -> p { mtarget = tgt }) updatePlayerBody (\ p -> p { mtarget = tgt })
setCursor tgt setCursor tgt


Expand Down
4 changes: 2 additions & 2 deletions src/Command.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ ascendCommand = Described "ascend a level" (lvlChange Up)
descendCommand = Described "descend a level" (lvlChange Down) descendCommand = Described "descend a level" (lvlChange Down)
floorCommand = Described "target location" targetFloor floorCommand = Described "target location" targetFloor
monsterCommand = Described "target monster" (checkCursor targetMonster) monsterCommand = Described "target monster" (checkCursor targetMonster)
quaffCommand = Described "quaff a potion" quaffPotion quaffCommand = Described "quaff a potion" (checkCursor quaffPotion)
readCommand = Described "read a scroll" readScroll readCommand = Described "read a scroll" (checkCursor readScroll)
throwCommand = Described "throw a weapon" (checkCursor throwItem) throwCommand = Described "throw a weapon" (checkCursor throwItem)
aimCommand = Described "aim a wand" (checkCursor aimItem) aimCommand = Described "aim a wand" (checkCursor aimItem)
waitCommand = Described "wait" playerAdvanceTime waitCommand = Described "wait" playerAdvanceTime
Expand Down

0 comments on commit 4dfcb34

Please sign in to comment.