Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

aiming a wand at a monster puts it under player control

TODO: when the fatigue stat is introduced, monster will be released quickly
TODO: I bet it crashes in cases like inventory management, etc.; review
  • Loading branch information...
commit 4abe66307af6a0f834c813e0343442c8a035c2ae 1 parent c330edb
@Mikolaj Mikolaj authored
Showing with 26 additions and 7 deletions.
  1. +18 −1 src/Actions.hs
  2. +1 −0  src/Command.hs
  3. +6 −6 src/Item.hs
  4. +1 −0  src/Turn.hs
View
19 src/Actions.hs
@@ -663,7 +663,7 @@ fireItem = do
state <- get
per <- currentPerception
pitems <- gets (mitems . getPlayerBody)
- pl <- gets splayer
+ pl <- gets splayer
case findItem (\ i -> itype i == Dart) pitems of
Just (dart, _) -> do
let fired = dart { icount = 1 }
@@ -676,6 +676,23 @@ fireItem = do
Nothing -> modify (updateLevel (scatterItems [fired] loc))
Nothing -> abortWith "nothing to fire"
+applyItem :: Action ()
+applyItem = do
+ state <- get
+ per <- currentPerception
+ pitems <- gets (mitems . getPlayerBody)
+ pl <- gets splayer
+ case findItem (\ i -> itype i == Wand) pitems of
+ Just (wand, _) -> do
+ let applied = wand { icount = 1 }
+ let loc = targetToLoc state per
+ case locToActor state loc of
+ Just target -> do
+ removeFromInventory applied
+ selectHero target >> return ()
+ Nothing -> abortWith "no living target to affect"
+ Nothing -> abortWith "nothing to fire"
+
dropItem :: Action ()
dropItem =
do
View
1  src/Command.hs
@@ -24,6 +24,7 @@ floorCommand = Described "target location" targetFloor -- TODO: should no
monsterCommand = Described "target monster" targetMonster
drinkCommand = Described "quaff a potion" drinkPotion
fireCommand = Described "fire an item" fireItem
+applyCommand = Described "aim a wand " applyItem -- TODO: change descriptions as soon as the command generalized and requires specifying an item
waitCommand = Described "wait" (return () :: Action ())
saveCommand = Described "save and quit the game" saveGame
quitCommand = Described "quit without saving" quitGame
View
12 src/Item.hs
@@ -109,13 +109,13 @@ itemFrequency :: Frequency ItemType
itemFrequency =
Frequency
[
- (100, Gold),
+ (80, Gold),
(70, Sword (-1)),
(40, Dart),
- (30, Gem),
- (20, Ring),
- (30, Scroll),
- (10, Wand),
+ (20, Gem),
+ (10, Ring),
+ (10, Scroll),
+ (30, Wand),
(10, Amulet),
(30, Potion PotionWater),
(20, Potion PotionHealing)
@@ -123,7 +123,7 @@ itemFrequency =
itemQuantity :: Int -> ItemType -> Rnd Int
itemQuantity n Gold = (2 * n) *~ d 8
-itemQuantity _ Dart = d 10
+itemQuantity _ Dart = 3 *~ d 3
itemQuantity _ _ = return 1
itemStrength :: Int -> ItemType -> Rnd ItemType
View
1  src/Turn.hs
@@ -242,6 +242,7 @@ stdKeybindings = Keybindings
(K.Char 'i', inventoryCommand),
(K.Char 'q', drinkCommand),
(K.Char 'f', fireCommand),
+ (K.Char 'a', applyCommand),
-- wait
-- (K.Char ' ', waitCommand),
Please sign in to comment.
Something went wrong with that request. Please try again.