From d496c4c5234ea26e8eab86af2b858ae5db80b8f8 Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 28 Oct 2022 21:26:14 +0100 Subject: [PATCH] Remove yourID -- you are simply at 0 --- src/Dodge/Base/You.hs | 3 +-- src/Dodge/Creature/Impulse/UseItem.hs | 2 +- src/Dodge/Data/LWorld.hs | 1 - src/Dodge/Default/World.hs | 1 - src/Dodge/Inventory.hs | 22 ++++++++++------------ src/Dodge/Inventory/Add.hs | 2 +- src/Dodge/Update/Scroll.hs | 4 ++-- src/Dodge/Update/UsingInput.hs | 7 +++---- 8 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/Dodge/Base/You.hs b/src/Dodge/Base/You.hs index 69a7fb67f..c8421b147 100644 --- a/src/Dodge/Base/You.hs +++ b/src/Dodge/Base/You.hs @@ -5,8 +5,7 @@ import qualified IntMapHelp as IM import Control.Lens you :: World -> Creature ---you w = _creatures (_cWorld w) IM.! _yourID (_cWorld w) -you w = w ^?! cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) +you w = w ^?! cWorld . lWorld . creatures . ix 0 yourItem :: World -> Maybe Item yourItem w = _crInv (you w) IM.!? crSel (you w) diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index eb52d1d6c..5321fc450 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -51,7 +51,7 @@ itemEffect cr it w = case it ^. itUse of tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World tryReload cr it w f - | _crID cr == (w ^. cWorld . lWorld . yourID) && itNeedsLoading it && _mouseButtons w M.!? SDL.ButtonLeft == Just False = + | _crID cr == 0 && itNeedsLoading it && _mouseButtons w M.!? SDL.ButtonLeft == Just False = crToggleReloading cr | otherwise = (runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown))) diff --git a/src/Dodge/Data/LWorld.hs b/src/Dodge/Data/LWorld.hs index 8c540e3a2..40f1bf989 100644 --- a/src/Dodge/Data/LWorld.hs +++ b/src/Dodge/Data/LWorld.hs @@ -141,7 +141,6 @@ data LWorld = LWorld , _floorItems :: IM.IntMap FloorItem , _floorTiles :: [(Point3, Point3)] , _modifications :: IM.IntMap Modification - , _yourID :: Int , _worldEvents :: [WdWd] , _delayedEvents :: [(Int, WdWd)] , _pressPlates :: IM.IntMap PressPlate diff --git a/src/Dodge/Default/World.hs b/src/Dodge/Default/World.hs index 73a01c4fd..fd65fda4d 100644 --- a/src/Dodge/Default/World.hs +++ b/src/Dodge/Default/World.hs @@ -111,7 +111,6 @@ defaultLWorld = , _wlZoning = IM.empty --Zoning IM.empty wlZoneSize zoneOfWall , _floorItems = IM.empty , _floorTiles = [] - , _yourID = 0 , _worldEvents = [] , _delayedEvents = [] , _pressPlates = IM.empty diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 0daca7326..394b3176e 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -169,7 +169,7 @@ updateCloseObjects :: World -> World updateCloseObjects w = w & cWorld . lWorld . closeObjects .~ unionBy closeObjEq oldCloseFiltered currentClose - & cWorld . lWorld . creatures . ix (_yourID (_lWorld (_cWorld w))) . crInvSel . iselPos %~ updateinvsel + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ updateinvsel where updateinvsel curinvsel | length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1 @@ -319,16 +319,16 @@ changeInvSel i w | n == 0 = w | yourInvSel w < n = w - & cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselPos %~ (`mod` n) . subtract i - & cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselAction .~ NoInvSelAction + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction | otherwise = w - & cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselPos %~ ((+ n) . (`mod` numCO) . subtract (i + n)) - & cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselAction .~ NoInvSelAction + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ ((+ n) . (`mod` numCO) . subtract (i + n)) + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction where -- arguably this should jump the invpos into the inventory proper - n = length $ _crInv $ _creatures (_lWorld (_cWorld w)) IM.! _yourID (_lWorld (_cWorld w)) + n = length $ w ^?! cWorld . lWorld . creatures . ix 0 . crInv numCO = length $ w ^. cWorld . lWorld . closeObjects changeSwapInvSel :: Int -> World -> World @@ -336,13 +336,12 @@ changeSwapInvSel k w | n == 0 = w | yourInvSel w < n = w - & cWorld . lWorld . creatures . ix yid %~ updatecreature + & cWorld . lWorld . creatures . ix 0 %~ updatecreature | otherwise = w - & cWorld . lWorld . creatures . ix yid . crInvSel . iselPos .~ ico' + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos .~ ico' & cWorld . lWorld . closeObjects %~ swapIndices (i - n) (ico' - n) where - yid = w ^. cWorld . lWorld . yourID updatecreature = (crInv %~ IM.safeSwapKeys (i `mod` n) swapi) . (crLeftInvSel . _Just %~ updateLeftInvSel) @@ -369,10 +368,9 @@ changeAugInvSel i w | n == 0 = w | otherwise = w - & cWorld . lWorld . creatures . ix yid . crInvSel . iselPos %~ (`mod` n) . subtract i - & cWorld . lWorld . creatures . ix yid . crInvSel . iselAction .~ NoInvSelAction + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i + & cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction where - yid = w ^. cWorld . lWorld . yourID n = length (yourInv w) + length (w ^. cWorld . lWorld . closeObjects) bestCloseObjectIndex :: World -> Maybe Int diff --git a/src/Dodge/Inventory/Add.hs b/src/Dodge/Inventory/Add.hs index e7dd82cc6..1c0205a32 100644 --- a/src/Dodge/Inventory/Add.hs +++ b/src/Dodge/Inventory/Add.hs @@ -51,5 +51,5 @@ tryPutItemInInv cid flit w = case maybeInvSlot of -- Just j -> w' & itemPositions . ix j .~ InInv cid invid createPutItem :: Item -> World -> (Maybe Int, World) createPutItem it w = - uncurry (putItemInInvID (_yourID (_lWorld (_cWorld w)))) $ + uncurry (putItemInInvID 0) $ copyItemToFloorID (_crPos $ you w) (applyModules it) w diff --git a/src/Dodge/Update/Scroll.hs b/src/Dodge/Update/Scroll.hs index 8d1f069e2..da61e0f21 100644 --- a/src/Dodge/Update/Scroll.hs +++ b/src/Dodge/Update/Scroll.hs @@ -26,7 +26,7 @@ updateWheelEvent yi w = case w ^. cWorld . lWorld . hud . hudElement of DisplayInventory NoSubInventory -- functions that modify the inventory should be centralised so that -- this lock can be sensibly applied, perhaps - | w ^?! cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvLock -> w + | w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w | rbDown -> case (yourItem w ^? _Just . itUse . heldScroll, _rbOptions w) of (_, EquipOptions{}) -> scrollRBOption y w (Nothing, _) -> closeObjScrollDir y w @@ -93,7 +93,7 @@ changeTweakParam mi i w = fromMaybe w $ do params <- yourItem w ^? _Just . itTweaks . tweakParams . ix paramid let x = (_tweakVal params + i) `mod` _tweakMax params return $ - w & cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInv . ix (crSel (you w)) + w & cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel (you w)) %~ ( (itTweaks . tweakParams . ix paramid . tweakVal .~ x) . doTweak (_tweakType params) x ) diff --git a/src/Dodge/Update/UsingInput.hs b/src/Dodge/Update/UsingInput.hs index 0732c4819..ebdcab1a2 100644 --- a/src/Dodge/Update/UsingInput.hs +++ b/src/Dodge/Update/UsingInput.hs @@ -55,7 +55,7 @@ pressedMBEffectsNoInventory pkeys w useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown | justPressedDown ButtonLeft && inTopInv && w ^?! hammers . ix DoubleMouseHam == HammerUp = - useLeftItem (w ^. cWorld . lWorld . yourID) w + useLeftItem 0 w | isDown ButtonLeft && inTopInv = w & hammers . ix DoubleMouseHam .~ HammerDown | isDown ButtonRight && inTopInv = w @@ -81,10 +81,9 @@ doCombine i w = case combineItemListYou w ^? ix i of -- set (hud . hudElement) (DisplayInventory NoSubInventory) selectinv --enterCombineInv . createPutItem it - $ foldr (rmInvItem yid) w (sort is) + $ foldr (rmInvItem 0) w (sort is) where - yid = w ^. cWorld . lWorld . yourID - selectinv (Just i', w') = w' & cWorld . lWorld . creatures . ix yid . crInvSel .~ InvSel i' NoInvSelAction + selectinv (Just i', w') = w' & cWorld . lWorld . creatures . ix 0 . crInvSel .~ InvSel i' NoInvSelAction selectinv (Nothing, w') = w' updatePressedButtonsCarte :: M.Map MouseButton Bool -> World -> World