Remove _crInvEquipped

This commit is contained in:
2024-12-19 12:44:34 +00:00
parent 80b03e6544
commit 11b5ef74c5
8 changed files with 21 additions and 17 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+7 -7
View File
@@ -50,7 +50,7 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
PutOnEquipment{_allocNewPos = newp} ->
w
& crpoint . crEquipment . at newp ?~ invid
& crpoint . crInvEquipped . at invid ?~ newp
-- & crpoint . crInvEquipped . at invid ?~ newp
& crpoint . crInv . ix invid . itLocation . ilEquipPosition ?~ newp
& onequip itm cr
& crpoint %~ assignNewHotkey invid
@@ -58,22 +58,22 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
w
& crpoint . crEquipment . at newp ?~ invid
& crpoint . crEquipment . at oldp .~ Nothing
& crpoint . crInvEquipped . at invid ?~ newp
-- & crpoint . crInvEquipped . at invid ?~ newp
& crpoint . crInv . ix invid . itLocation . ilEquipPosition ?~ newp
SwapEquipment{_allocNewPos = newp, _allocOldPos = oldp, _allocSwapID = sid} ->
w
& crpoint . crEquipment . at newp ?~ invid
& crpoint . crEquipment . at oldp ?~ sid
& crpoint . crInvEquipped . at invid ?~ newp
-- & crpoint . crInvEquipped . at invid ?~ newp
& crpoint . crInv . ix invid . itLocation . ilEquipPosition ?~ newp
& crpoint . crInvEquipped . at sid ?~ oldp
-- & crpoint . crInvEquipped . at sid ?~ oldp
& crpoint . crInv . ix sid . itLocation . ilEquipPosition ?~ oldp
ReplaceEquipment{_allocNewPos = newp, _allocRemoveID = rid} ->
w
& crpoint . crEquipment . at newp ?~ invid
& crpoint . crInvEquipped . at invid ?~ newp
-- & crpoint . crInvEquipped . at invid ?~ newp
& crpoint . crInv . ix invid . itLocation . ilEquipPosition ?~ newp
& crpoint . crInvEquipped . at rid .~ Nothing
-- & crpoint . crInvEquipped . at rid .~ Nothing
& crpoint . crInv . ix rid . itLocation . ilEquipPosition .~ Nothing
& onremove (itmat rid) cr
& onequip itm cr
@@ -82,7 +82,7 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
RemoveEquipment{_allocOldPos = oldp} ->
w
& crpoint . crEquipment . at oldp .~ Nothing
& crpoint . crInvEquipped . at invid .~ Nothing
-- & crpoint . crInvEquipped . at invid .~ Nothing
& crpoint . crInv . ix invid . itLocation . ilEquipPosition .~ Nothing
& onremove itm cr
& crpoint %~ removeHotkey invid
+1 -1
View File
@@ -54,7 +54,7 @@ data Creature = Creature
, _crManipulation :: Manipulation
, _crInvCapacity :: Int
, _crInvLock :: Bool
, _crInvEquipped :: IM.IntMap EquipPosition
-- , _crInvEquipped :: IM.IntMap EquipPosition
, _crEquipment :: M.Map EquipPosition Int
, _crInvHotkeys :: IM.IntMap Hotkey
, _crHotkeys :: M.Map Hotkey Int
+1 -1
View File
@@ -34,7 +34,7 @@ defaultCreature =
, _crCorpse = MakeDefaultCorpse
, _crMaterial = Flesh
, _crPastDamage = 0
, _crInvEquipped = mempty
-- , _crInvEquipped = mempty
, _crEquipment = M.empty
, _crInvHotkeys = mempty
, _crHotkeys = M.empty
-1
View File
@@ -7,7 +7,6 @@ module Dodge.Hotkey (
import Control.Lens
import Data.List
import qualified Data.Map.Strict as M
import qualified IntMapHelp as IM
import Data.Maybe
import Dodge.Data.World
import Control.Monad
+5 -3
View File
@@ -66,8 +66,8 @@ rmInvItem cid invid w =
& pointcid . crInv %~ f -- important
& removeAnySlotEquipment
& pointcid . crEquipment . each %~ g
& pointcid . crInvEquipped %~ IM.delete invid
& pointcid . crInvEquipped %~ IM.mapKeys g
-- & pointcid . crInvEquipped %~ IM.delete invid
-- & pointcid . crInvEquipped %~ IM.mapKeys g
& removeanyactivation
& pointcid . crHotkeys . each %~ g
& pointcid . crInvHotkeys %~ IM.delete invid
@@ -95,7 +95,9 @@ rmInvItem cid invid w =
rmf <- itm ^? itEffect . ieOnDrop
return $ doInvEffect rmf itm cr
removeAnySlotEquipment = fromMaybe id $ do
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvEquipped . ix invid
--epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvEquipped . ix invid
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
. itLocation . ilEquipPosition . _Just
return $ pointcid . crEquipment . at epos .~ Nothing
removeanyactivation = fromMaybe id $ do
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvHotkeys . ix invid
+3 -1
View File
@@ -72,7 +72,9 @@ crUpdateInvidLocations mo crid lw invid itm =
, _ilIsRoot = Just invid == mo ^? imRootSelectedItem
, _ilIsSelected = Just invid == mo ^? imSelectedItem
, _ilIsAttached = invid `IS.member` (mo ^. imAttachedItems)
, _ilEquipPosition = lw ^? creatures . ix crid . crInvEquipped . ix invid
--, _ilEquipPosition = lw ^? creatures . ix crid . crInvEquipped . ix invid
, _ilEquipPosition = lw ^? creatures . ix crid . crInv . ix invid
. itLocation . ilEquipPosition . _Just
}
-- this should be looked at, as it is sometimes used in functions that need not
+3 -2
View File
@@ -54,14 +54,15 @@ swapInvItems f i w = fromMaybe w $ do
updatecreature k =
(crInv %~ IM.safeSwapKeys i k)
. (crManipulation . manObject . imSelectedItem .~ k)
. (crInvEquipped %~ IM.safeSwapKeys i k)
-- . (crInvEquipped %~ IM.safeSwapKeys i k)
. swapSite i k
. swapSite k i
. (crInvHotkeys %~ IM.safeSwapKeys i k)
. swapSite' i k
. swapSite' k i
cr = you w
swapSite a b = case cr ^? crInvEquipped . ix a of
--swapSite a b = case cr ^? crInvEquipped . ix a of
swapSite a b = case cr ^? crInv . ix a . itLocation . ilEquipPosition . _Just of
Just epos -> crEquipment . ix epos .~ b
Nothing -> id
swapSite' a b = case cr ^? crInvHotkeys . ix a of