Work on inventory management
This commit is contained in:
@@ -23,7 +23,7 @@ import qualified SDL
|
||||
useItem :: Creature -> World -> World
|
||||
useItem cr' w = fromMaybe (f w) $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||
itRef <- cr ^? crInvSel . isel . ispItem
|
||||
itRef <- cr ^? crManipulation . isel . ispItem
|
||||
it <- cr ^? crInv . ix itRef
|
||||
return $ itemEffect cr it w
|
||||
where
|
||||
@@ -39,7 +39,7 @@ itemEffect cr it w = case it ^. itUse of
|
||||
(ConsumeUse eff _) -> setuhamdown $ hammerTest $ useC eff it cr . rmInvItem (_crID cr) itRef
|
||||
CraftUse{} -> setuhamdown w
|
||||
where
|
||||
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
|
||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
||||
hammerTest f = case _crHammerPosition cr of
|
||||
HammerUp -> f w
|
||||
_ -> w & setuhamdown
|
||||
@@ -109,7 +109,7 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
|
||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
itmat i = _crInv cr IM.! i
|
||||
itm = itmat itRef
|
||||
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
|
||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
||||
onequip itm' = useE ((_eeOnEquip . _equipEffect . _itUse) itm') itm'
|
||||
onremove itm' = useE ((_eeOnRemove . _equipEffect . _itUse) itm') itm'
|
||||
|
||||
@@ -117,7 +117,7 @@ useLeftItem :: Int -> World -> World
|
||||
useLeftItem cid w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||
guard . not $ _crInvLock cr
|
||||
let mitRef = cr ^? crInvSel . isel . ispItem
|
||||
let mitRef = cr ^? crManipulation . isel . ispItem
|
||||
itmIsConsumable = isJust $ do
|
||||
itRef <- mitRef
|
||||
cr ^? crInv . ix itRef . itUse . cUse
|
||||
|
||||
Reference in New Issue
Block a user