Improve item location code
This commit is contained in:
@@ -23,7 +23,7 @@ doFloorEffect NoFloorEffect = const id
|
||||
|
||||
onOffEff :: ItInvEffect -> ItInvEffect -> Item -> Creature -> World -> World
|
||||
onOffEff f g it
|
||||
| _itIsRoot it = doInvEffect f it
|
||||
| it ^? itLocation . ilIsRoot == Just True = doInvEffect f it
|
||||
| otherwise = doInvEffect g it
|
||||
|
||||
--timeScrollEffect :: Item -> Creature -> World -> World
|
||||
@@ -37,14 +37,14 @@ setItemCharge :: Int -> Item -> Creature -> World -> World
|
||||
setItemCharge i itm cr w =
|
||||
w & ptrWpCharge %~ const i
|
||||
where
|
||||
invid = _ipInvID $ _itLocation itm
|
||||
invid = _ilInvID $ _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))
|
||||
where
|
||||
invid = _ipInvID $ _itLocation itm
|
||||
invid = _ilInvID $ _itLocation itm
|
||||
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
|
||||
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
|
||||
|
||||
@@ -54,7 +54,7 @@ chargeIfEquipped itm cr
|
||||
ptrWpCharge %~ (min maxcharge . (+ 1))
|
||||
| otherwise = ptrWpCharge .~ 0
|
||||
where
|
||||
invid = _ipInvID $ _itLocation itm
|
||||
invid = _ilInvID $ _itLocation itm
|
||||
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
|
||||
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
|
||||
|
||||
|
||||
Reference in New Issue
Block a user