This commit is contained in:
2022-12-31 23:01:54 +00:00
parent 0dc9a09723
commit 8838d1120b
6 changed files with 54 additions and 71 deletions
+13 -8
View File
@@ -10,6 +10,7 @@ doInvEffect iie = case iie of
NoInvEffect -> const $ const id
ChargeIfEquipped -> chargeIfEquipped
ChargeIfInInventory -> chargeIfInInventory
SetCharge i -> setItemCharge i
EffectIfHeld f g -> onOffEff f g
CreateHeldLight -> createHeldLight
CreateShieldWall -> createShieldWall
@@ -31,27 +32,31 @@ onOffEff f g it
-- , _futureWorlds = []
-- }
setItemCharge :: Int -> Item -> Creature -> World -> World
setItemCharge i itm cr w =
w & ptrWpCharge %~ const i
where
invid = _ipInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
chargeIfInInventory :: Item -> Creature -> World -> World
chargeIfInInventory itm cr w =
w & ptrWpCharge %~ (min maxcharge . (+ 1))
chargeIfInInventory itm cr w =
w & ptrWpCharge %~ (min maxcharge . (+ 1))
where
invid = _ipInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
chargeIfEquipped :: Item -> Creature -> World -> World
chargeIfEquipped itm cr w
chargeIfEquipped itm cr
| Just invid == cr ^. crLeftInvSel . lisMPos =
w & ptrWpCharge %~ (min maxcharge . (+ 1))
| otherwise =
w & ptrWpCharge .~ 0
ptrWpCharge %~ (min maxcharge . (+ 1))
| otherwise = ptrWpCharge .~ 0
where
invid = _ipInvID $ _itLocation itm
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
--resetAttachmentEffect :: Item -> Creature -> World -> World
--resetAttachmentEffect itm cr w
-- | _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment