26 lines
721 B
Haskell
26 lines
721 B
Haskell
module Dodge.Item.Consumable where
|
|
|
|
import Control.Lens
|
|
import Dodge.Data.World
|
|
import Dodge.Default
|
|
import Dodge.SoundLogic
|
|
|
|
medkit :: Int -> Item
|
|
medkit i =
|
|
defaultConsumable
|
|
& itUse . cUse .~ CHeal i
|
|
& itType .~ CONSUMABLE (MEDKIT i)
|
|
|
|
heal25 :: Int -> World -> Maybe World
|
|
heal25 = heal 25
|
|
|
|
heal :: Int -> Int -> World -> Maybe World
|
|
heal hp n w
|
|
| (w ^?! cWorld . lWorld . creatures . ix n . crHP) >= 10000 = Nothing
|
|
| otherwise =
|
|
Just $
|
|
soundStart (CrSound $ _crID cr) (_crPos cr) healS Nothing w
|
|
& cWorld . lWorld . creatures . ix n . crHP %~ min 10000 . (+ hp)
|
|
where
|
|
cr = w ^?! cWorld . lWorld . creatures . ix n --_creatures (_cWorld w) IM.! n
|