Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improve target reset and guard commands that can use items from the f…

…loor
  • Loading branch information...
commit 4dfcb3474ea43e8e8abfdd500eace455095eb302 1 parent e4e6055
@Mikolaj Mikolaj authored
Showing with 9 additions and 6 deletions.
  1. +7 −4 src/Actions.hs
  2. +2 −2 src/Command.hs
View
11 src/Actions.hs
@@ -416,13 +416,16 @@ search =
modify (updateLevel (updateLMap (const slmap)))
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 = do
- target <- gets (mtarget . getPlayerBody)
+ ploc <- gets (mloc . getPlayerBody)
+ target <- gets (mtarget . getPlayerBody)
+ targeting <- gets (ctargeting . scursor)
let tgt = case target of
- TLoc l -> TLoc l -- don't forget the old location target too fast
- _ -> TCursor
+ _ | targeting -> TLoc ploc -- double key press: reset cursor
+ TEnemy _ _ -> TCursor -- forget enemy target, keep the cursor
+ t -> t -- keep the target from previous targeting session
updatePlayerBody (\ p -> p { mtarget = tgt })
setCursor tgt
View
4 src/Command.hs
@@ -23,8 +23,8 @@ ascendCommand = Described "ascend a level" (lvlChange Up)
descendCommand = Described "descend a level" (lvlChange Down)
floorCommand = Described "target location" targetFloor
monsterCommand = Described "target monster" (checkCursor targetMonster)
-quaffCommand = Described "quaff a potion" quaffPotion
-readCommand = Described "read a scroll" readScroll
+quaffCommand = Described "quaff a potion" (checkCursor quaffPotion)
+readCommand = Described "read a scroll" (checkCursor readScroll)
throwCommand = Described "throw a weapon" (checkCursor throwItem)
aimCommand = Described "aim a wand" (checkCursor aimItem)
waitCommand = Described "wait" playerAdvanceTime
Please sign in to comment.
Something went wrong with that request. Please try again.