Make examine inventory controlled by item, perhaps still buggy

This commit is contained in:
2025-01-01 21:14:38 +00:00
parent 86aba6d115
commit 5b978d9f1c
25 changed files with 523 additions and 502 deletions
+13 -13
View File
@@ -1,6 +1,6 @@
--{-# LANGUAGE TupleSections #-}
module Dodge.Inventory (
rmInvItem,
rmInvItem,
destroyInvItem,
updateCloseObjects,
changeSwapSel,
@@ -14,9 +14,8 @@ module Dodge.Inventory (
swapItemWith,
) where
import qualified Data.IntSet as IS
import Dodge.Inventory.Swap
import Data.Function
import qualified Data.IntSet as IS
import Data.Maybe
import Dodge.Base
import Dodge.Data.SelectionList
@@ -25,7 +24,7 @@ import Dodge.Euse
import Dodge.Inventory.CheckSlots
import Dodge.Inventory.Location
import Dodge.Inventory.RBList
import Dodge.ItEffect
import Dodge.Inventory.Swap
import Dodge.SelectionSections
import Geometry
import qualified IntMapHelp as IM
@@ -43,8 +42,9 @@ destroyInvItem ::
Int ->
World ->
World
destroyInvItem cid invid w = rmInvItem cid invid w & removeitloc
& removeithotkey
destroyInvItem cid invid w =
rmInvItem cid invid w & removeitloc
& removeithotkey
where
removeitloc = fromMaybe id $ do
itid <- w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid . itID . unNInt
@@ -54,7 +54,7 @@ destroyInvItem cid invid w = rmInvItem cid invid w & removeitloc
hk <- w ^? cWorld . lWorld . imHotkeys . unNIntMap . ix itid
return $
(cWorld . lWorld . imHotkeys . unNIntMap . at itid .~ Nothing)
. ( cWorld . lWorld . hotkeys . at hk .~ Nothing)
. (cWorld . lWorld . hotkeys . at hk .~ Nothing)
-- | after this the item at the inventory position will no longer exist
rmInvItem ::
@@ -66,7 +66,6 @@ rmInvItem ::
World
rmInvItem cid invid w =
w
& doanyitemeffect
& dounequipfunction --the ordering of these is
& pointcid . crInv %~ f -- important
& removeAnySlotEquipment
@@ -90,12 +89,13 @@ rmInvItem cid invid w =
dounequipfunction = fromMaybe id $ do
rmf <- itm ^? itUse . uequipEffect . eeOnRemove
return $ doItmCrWdWd rmf itm cr
doanyitemeffect = fromMaybe id $ do
rmf <- itm ^? itEffect . ieOnDrop
return $ doInvEffect rmf itm cr
removeAnySlotEquipment = fromMaybe id $ do
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
. itLocation . ilEquipSite . _Just
epos <-
w
^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
. itLocation
. ilEquipSite
. _Just
return $ pointcid . crEquipment . at epos .~ Nothing
maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
f inv =