36 lines
1.0 KiB
Haskell
36 lines
1.0 KiB
Haskell
module Dodge.Item.Consumable where
|
|
import Dodge.Data
|
|
--import Dodge.Picture.Layer
|
|
import Dodge.Default
|
|
import Dodge.SoundLogic
|
|
import Dodge.Inventory
|
|
import Shape
|
|
--import ShapePicture
|
|
import Dodge.Item.Draw
|
|
import Picture
|
|
|
|
import Data.Maybe
|
|
import Control.Lens
|
|
import qualified Data.IntMap.Strict as IM
|
|
|
|
medkit :: Int -> Item
|
|
medkit i = defaultConsumable
|
|
{ _itName = "MEDKIT" ++ show i
|
|
, _itUse = LeftUse
|
|
{_lUse = \cr invid w -> fromMaybe w (heal 25 (_crID cr) $ rmInvItem (_crID cr) invid w)
|
|
,_useDelay = NoDelay
|
|
,_useHammer = HasHammer HammerUp
|
|
}
|
|
, _itEquipPict = pictureItem $ (,) emptySH $ color blue $ circleSolid 3
|
|
, _itID = Nothing
|
|
}
|
|
|
|
heal25 :: Int -> World -> Maybe World
|
|
heal25 = heal 25
|
|
heal :: Int -> Int -> World -> Maybe World
|
|
heal hp n w | _crHP (_creatures w IM.! n) >= 10000 = Nothing
|
|
| otherwise = Just $ soundStart (CrSound $ _crID cr) (_crPos cr) healS Nothing w
|
|
& creatures . ix n . crHP %~ min 10000 . (+ hp)
|
|
where
|
|
cr = _creatures w IM.! n
|