Use Item as argument in lUse rather than Int

This commit is contained in:
2022-05-23 13:32:29 +01:00
parent 361dba88a0
commit a870457f2a
6 changed files with 25 additions and 22 deletions
+7 -6
View File
@@ -27,7 +27,7 @@ rewindGun = defaultGun
, _wpCharge = 0
}
, _itEffect = ItRewindEffect rewindEffect []
, _itUse = defaultlUse {_lUse = \cr invid -> useRewindGun (_crInv cr IM.! invid) cr}
, _itUse = defaultlUse {_lUse = \itm cr -> useRewindGun itm cr}
}
rewindEffect :: Item -> Creature -> World -> World
rewindEffect itm cr w
@@ -77,12 +77,13 @@ shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5
-- be careful changing this around; potential problems include updating the
-- creature but using the old crInvSel value
useShrinkGun :: Creature -> Int -> World -> World
useShrinkGun cr invid w = if _itBool $ _itAttachment it
-- 22.05.23 this has been changed from using invids to items
useShrinkGun :: Item -> Creature -> World -> World
useShrinkGun it cr w = if _itBool $ _itAttachment it
then tryResize 0.5 $ stripNoItems cr . f False UndroppableIdentified . dropExcept cr invid
else tryResize 1 $ f True Uncursed . setMinInvSize defaultInvSize cr
where
it = _crInv cr IM.! invid
invid = fromJust $ _itInvPos it
tryResize x g = maybe w g $ sizeSelf x cr w
f isInUse cstatus = creatures . ix (_crID cr) . crInv . ix invid %~
( (itAttachment . itBool .~ isInUse) . (itCurseStatus .~ cstatus) )
@@ -107,8 +108,8 @@ blinkGun = defaultGun
aSelf :: Creature -> World -> World
aSelf = blinkAction
aSelfL :: Creature -> Int -> World -> World
aSelfL cr _ = blinkAction cr
aSelfL :: Item -> Creature -> World -> World
aSelfL _ cr = blinkAction cr
effectGun :: String -> (Creature -> World -> World) -> Item
effectGun name eff = defaultGun