Commit before implementing positional inventory

This commit is contained in:
2023-05-18 09:52:46 +01:00
parent 7df81559d9
commit 2f0bb5115b
12 changed files with 132 additions and 78 deletions
+12 -2
View File
@@ -79,6 +79,7 @@ import Geometry
import LensHelp
import RandomHelp
import Sound.Data
import qualified IntMapHelp as IM
type ChainEffect =
(Item -> Creature -> World -> World) ->
@@ -361,9 +362,18 @@ useAmmoUpTo amAmount eff item cr =
useAmmoAmount :: Int -> ChainEffect
useAmmoAmount amAmount eff item cr =
eff item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ amAmount)
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv %~ useAmmoAmount' itref amAmount) -- . _InternalSource . iaLoaded -~ amAmount)
where
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
itref = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
useAmmoAmount' :: Int -> Int -> IM.IntMap Item -> IM.IntMap Item
useAmmoAmount' itref x inv = case inv ^? ix itref . itUse . heldConsumption . laSource of
Just InternalSource{}
-> inv & ix itref . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ x
Just (ExternalSource (Just eqid))
-> inv & ix eqid . itUse . equipEffect . eeUse . euseAmmoAmount -~ x
_ -> inv
-- . crInv . ix itRef . itUse . heldConsumption . laSource
{- |
Applies a world effect after an item use cooldown check.