From 6c1862b2a13067e99430b80951812e06d1f73906 Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 2 Jan 2023 11:33:33 +0000 Subject: [PATCH] Fix inventory bug --- src/Dodge/Inventory.hs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 77ecebc80..788a5705a 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -25,19 +25,19 @@ module Dodge.Inventory ( invDimColor, ) where -import Dodge.Reloading import Color -import Dodge.Inventory.Color import qualified Data.Map.Strict as M import Data.Maybe import Dodge.Base -import Dodge.Data.World import Dodge.Data.Config +import Dodge.Data.World import Dodge.Euse import Dodge.Inventory.CheckSlots import Dodge.Inventory.CloseObject +import Dodge.Inventory.Color import Dodge.Inventory.ItemSpace import Dodge.ItEffect +import Dodge.Reloading import Geometry import qualified IntMapHelp as IM import LensHelp @@ -104,9 +104,9 @@ augmentedInvSizes = trimapAugmentInv itSlotsTaken 1 closeObjectSize trimapAugmentInv :: (Item -> a) -> a -> (Either FloorItem Button -> a) -> World -> IM.IntMap a trimapAugmentInv f x g w = IM.insert n x $ - IM.union - (f <$> yourInv w) - (IM.fromAscList $ zip [n + 1 ..] $ map g $ w ^. hud . closeObjects) + IM.union + (f <$> yourInv w) + (IM.fromAscList $ zip [n + 1 ..] $ map g $ w ^. hud . closeObjects) where n = length $ yourInv w @@ -166,8 +166,7 @@ updateCloseObjects w = & cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ updateinvsel where updateinvsel curinvsel - -- | length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1 - | length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) + | length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1 | otherwise = curinvsel filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasButtonLOS ypos (closeObjPos obj) w ypos = _crPos $ you w @@ -332,7 +331,7 @@ changeSwapInvSel k w | yourInvSel w > n = w & cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos .~ ico' - & hud . closeObjects %~ swapIndices (i - (n+1)) (ico' - (n+1)) + & hud . closeObjects %~ swapIndices (i - (n + 1)) (ico' - (n + 1)) | otherwise = w where updatecreature = @@ -357,12 +356,10 @@ changeSwapInvSel k w numCO = length $ w ^. hud . closeObjects changeAugInvSel :: Int -> World -> World -changeAugInvSel i w - | n == 0 = w - | otherwise = - w - & cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i - & cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction +changeAugInvSel i w = + w + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction where n = length (yourInv w) + length (w ^. hud . closeObjects) + 1