From 236f7c775028c8ff46fcf79d21de28c385352b42 Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 22 Sep 2024 13:58:00 +0100 Subject: [PATCH] Commit before tweaking item id/locations --- ghcidOutput | 2 +- src/Dodge/Creature/Impulse/UseItem.hs | 10 ++++------ src/Dodge/Creature/YourControl.hs | 5 ++--- src/Dodge/Data/Item/Use.hs | 1 + src/Dodge/Inventory.hs | 10 ++++++++++ src/Dodge/Item/Ammo.hs | 4 ++-- src/Dodge/Item/Scope.hs | 4 ++-- src/Dodge/TestString.hs | 3 ++- tags | 8 ++++---- 9 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ghcidOutput b/ghcidOutput index e851a319a..b0f5d3a4b 100644 --- a/ghcidOutput +++ b/ghcidOutput @@ -1 +1 @@ -All good (618 modules, at 10:46:18) +All good (619 modules, at 13:53:46) diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index f658f08f6..fa9143999 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -5,6 +5,7 @@ module Dodge.Creature.Impulse.UseItem ( useItemHotkey, ) where +import Dodge.SelectUse import Dodge.Item.Grammar import Dodge.Data.ComposedItem import Dodge.Data.DoubleTree @@ -40,17 +41,14 @@ itemEffect cr it w = case it ^. ldtValue . itUse of EquipUse{} -> doequipmentchange (ConsumeUse eff) -> useC eff (_ldtValue it) cr w CraftUse{} -> w - AttachUse{} -> w + AttachUse{} -> selectUse it cr w AmmoMagUse{} -> w where itm = it ^. ldtValue - hammerTest f = case _crHammerPosition cr of - HammerUp -> f w -- & setuhamdown - _ -> w -- & setuhamdown --- setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown doequipmentchange = fromMaybe w $ do + guard (_crHammerPosition cr == HammerUp) invid <- itm ^? itLocation . ipInvID - return $ hammerTest $ toggleEquipmentAt invid cr + return $ toggleEquipmentAt invid cr w toggleEquipmentAt :: Int -> Creature -> World -> World toggleEquipmentAt invid cr w = case getEquipmentAllocation w of diff --git a/src/Dodge/Creature/YourControl.hs b/src/Dodge/Creature/YourControl.hs index f3ad2e597..28f58a34a 100644 --- a/src/Dodge/Creature/YourControl.hs +++ b/src/Dodge/Creature/YourControl.hs @@ -215,9 +215,8 @@ pressedMBEffectsTopInventory pkeys w DisplayInventory{_subInventory = NoSubInventory} -> True _ -> False isDown but = but `M.member` pkeys - theinput = w ^. input rotation = maybe 0 - (angleBetween (theinput ^. mousePos)) - (theinput ^. heldPos . at SDL.ButtonMiddle) + (angleBetween $ w ^. input . mousePos) + (w ^. input . heldPos . at SDL.ButtonMiddle) diff --git a/src/Dodge/Data/Item/Use.hs b/src/Dodge/Data/Item/Use.hs index bd5fb9a79..e6c11a34b 100644 --- a/src/Dodge/Data/Item/Use.hs +++ b/src/Dodge/Data/Item/Use.hs @@ -60,6 +60,7 @@ data ItemUse | CraftUse | -- {_useAmount :: ItAmount} AttachUse + {_atLinkedProjectile :: Maybe Int} | -- {_attachParams :: AttachParams} AmmoMagUse { _amagLoadStatus :: ReloadStatus diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index d9282b4af..0ff9428e1 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -62,6 +62,7 @@ rmInvItem cid invid w = w & updateselection & pointcid %~ updateRootItemID & worldEventFlags . at InventoryChange ?~ () + & updateCreatureItemLocations cid where pointcid = cWorld . lWorld . creatures . ix cid @@ -94,6 +95,15 @@ rmInvItem cid invid w = w | x > invid || Just x == maxk = max 0 $ x - 1 | otherwise = x +updateCreatureItemLocations :: Int -> World -> World +updateCreatureItemLocations crid w = fromMaybe w $ do + inv <- w ^? cWorld . lWorld . creatures . ix crid . crInv + return $ foldl' updateItemLocation w inv + +updateItemLocation :: World -> Item -> World +updateItemLocation w itm = w + & cWorld . lWorld . itemLocations . ix (itm ^. itID) .~ itm ^. itLocation + ---- | after this the item at the inventory position will no longer exist --rmInvItem :: -- -- | Creature id diff --git a/src/Dodge/Item/Ammo.hs b/src/Dodge/Item/Ammo.hs index 7018eb8b1..873c160e3 100644 --- a/src/Dodge/Item/Ammo.hs +++ b/src/Dodge/Item/Ammo.hs @@ -104,9 +104,9 @@ chemFuelPouch = bulletSynthesizer :: Item bulletSynthesizer = defaultHeldItem & itType . iyBase .~ ATTACH BULLETSYNTHESIZER - & itUse .~ AttachUse + & itUse .~ AttachUse Nothing rocketHomer :: Item rocketHomer = defaultHeldItem & itType . iyBase .~ ATTACH ROCKETHOMER - & itUse .~ AttachUse + & itUse .~ AttachUse Nothing diff --git a/src/Dodge/Item/Scope.hs b/src/Dodge/Item/Scope.hs index e4f82a998..8f16dae6c 100644 --- a/src/Dodge/Item/Scope.hs +++ b/src/Dodge/Item/Scope.hs @@ -19,10 +19,10 @@ targetingScope :: TargetType -> Item targetingScope tt = defaultHeldItem & itType . iyBase .~ ATTACH (TARGETATTACH tt) - & itUse .~ AttachUse + & itUse .~ AttachUse Nothing rocketRemoteScreen :: Item rocketRemoteScreen = defaultHeldItem & itType . iyBase .~ ATTACH ROCKETREMOTESCREEN - & itUse .~ AttachUse + & itUse .~ AttachUse Nothing diff --git a/src/Dodge/TestString.hs b/src/Dodge/TestString.hs index 1955e9c26..f789ca025 100644 --- a/src/Dodge/TestString.hs +++ b/src/Dodge/TestString.hs @@ -20,7 +20,8 @@ import Dodge.Data.Universe import qualified IntMapHelp as IM testStringInit :: Universe -> [String] -testStringInit _ = mempty +testStringInit u = map show $ + (IM.toList . IM.filter (\itloc -> itloc ^? ipCrID == Just 0) $ (u ^. uvWorld . cWorld . lWorld . itemLocations)) <> IM.toList ( fmap _itLocation (u ^?! uvWorld . cWorld . lWorld . creatures . ix 0 . crInv)) --testStringInit u = fromMaybe mempty $ do -- inv <- fmap invLDT $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crInv -- invitm <- inv ^? ix 1 diff --git a/tags b/tags index befba0f8d..2386cd01e 100644 --- a/tags +++ b/tags @@ -5885,7 +5885,7 @@ itemDetectorEffect src/Dodge/HeldUse.hs 200;" f itemDisplay src/Dodge/Item/Display.hs 33;" f itemDisplayPad src/Dodge/Item/Display.hs 45;" f itemEffect src/Dodge/Creature/Action/UseItem.hs 28;" f -itemEffect src/Dodge/Creature/Impulse/UseItem.hs 35;" f +itemEffect src/Dodge/Creature/Impulse/UseItem.hs 34;" f itemEquipPict src/Dodge/Item/Draw.hs 17;" f itemFromAmmoMag src/Dodge/Item.hs 29;" f itemFromAttachType src/Dodge/Item.hs 39;" f @@ -7496,7 +7496,7 @@ toV3 src/Geometry/Data.hs 38;" f toV4 src/Geometry/Data.hs 40;" f toggleCombineInv src/Dodge/DisplayInventory.hs 32;" f toggleCommand src/Dodge/Terminal.hs 194;" f -toggleEquipmentAt src/Dodge/Creature/Impulse/UseItem.hs 56;" f +toggleEquipmentAt src/Dodge/Creature/Impulse/UseItem.hs 55;" f toggleJust src/MaybeHelp.hs 41;" f toggleMap src/Dodge/Update/Input/InGame.hs 237;" f toggleMapKey src/Dodge/Config/KeyConfig.hs 25;" f @@ -7795,8 +7795,8 @@ useHeld src/Dodge/HeldUse.hs 306;" f useHotKey src/Dodge/Creature/YourControl.hs 49;" f useItem src/Dodge/Creature/Action/UseItem.hs 14;" f useItemHotkey src/Dodge/Creature/Impulse/UseItem.hs 128;" f -useItemLeftClick src/Dodge/Creature/Impulse/UseItem.hs 101;" f -useItemLeftClick' src/Dodge/Creature/Impulse/UseItem.hs 116;" f +useItemLeftClick src/Dodge/Creature/Impulse/UseItem.hs 100;" f +useItemLeftClick' src/Dodge/Creature/Impulse/UseItem.hs 115;" f useL src/Dodge/Luse.hs 13;" f useLeftItem src/Dodge/Creature/Action/UseItem.hs 38;" f useLnkRoomPos src/Dodge/PlacementSpot.hs 244;" f