Fix item location bug

This commit is contained in:
2026-05-16 12:21:19 +01:00
parent db2ce72076
commit 4bcea5e772
10 changed files with 159 additions and 148 deletions
+3 -1
View File
@@ -14,7 +14,9 @@ import Dodge.HeldUse
import Dodge.Inventory
import Dodge.Item.Grammar
import Dodge.Item.Location
--import qualified IntMapHelp as IM
--note :: a -> Maybe b -> Either a b
--note x = maybe (Left x) Right
useItem :: Int -> Int -> World -> Maybe World
useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
+1 -1
View File
@@ -32,7 +32,7 @@ data HUD = HUD
, _diSelection :: Maybe Selection
, _diInvFilter :: Maybe String
, _diCloseFilter :: Maybe String
, _closeItems :: [NewInt ItmInt]
, _closeItems :: [NewInt ItmInt] -- add bool showing whether in ssSet?
, _closeButtons :: [Int]
, _manObject :: ManipulatedObject
}
+1 -1
View File
@@ -35,7 +35,7 @@ data ItemLocation
, _ilEquipSite :: Maybe EquipSite
}
| OnTurret {_ilTuID :: Int}
| OnFloor {_ilCloseSel :: Bool} -- {_ilFlID :: NewInt FloorInt}
| OnFloor
| InVoid
deriving (Eq, Show, Ord, Read) --Generic, Flat)
+1
View File
@@ -43,6 +43,7 @@ data World = World
, _wSoundFilter :: SoundFilter
, _input :: Input
, _testFloat :: Float
, _testString :: String
, _rbState :: RightButtonState
, _hud :: HUD
, _worldEventFlags :: Set WorldEventFlag
+1
View File
@@ -43,6 +43,7 @@ defaultWorld =
, _playingSounds = M.empty
, _randGen = mkStdGen 2
, _testFloat = 0
, _testString = ""
, _rbState = NoRightButtonState
, _hud = defaultHUD
, _worldEventFlags = mempty
+1 -1
View File
@@ -15,7 +15,7 @@ copyItemToFloor :: Point2 -> Item -> World -> World
copyItemToFloor p it w =
w'
& cWorld . lWorld . floorItems . at (it ^. itID . unNInt) ?~ FlIt q r
& cWorld . lWorld . items . at (it ^. itID . unNInt) ?~ (it & itLocation .~ OnFloor False)
& cWorld . lWorld . items . at (it ^. itID . unNInt) ?~ (it & itLocation .~ OnFloor)
& hud . closeItems .:~ _itID it -- puts item at top of close items
& cWorld . highlightItems . at (it ^. itID . unNInt) ?~ 20
where
+1 -1
View File
@@ -273,7 +273,7 @@ invSetSelection sel w =
& worldEventFlags . at InventoryChange ?~ ()
-- & crUpdateItemLocations
& setInvPosFromSS -- is this necessary here?
-- & crUpdateItemLocations
& crUpdateItemLocations
invSetSelectionPos :: Int -> Int -> World -> World
invSetSelectionPos i j = invSetSelection (Sel i j)
+1 -1
View File
@@ -111,7 +111,7 @@ placeSpotID rid ps pt w = case pt of
in ( i
, w
& gwWorld . cWorld . lWorld . floorItems . at i ?~ FlIt p rot
& gwWorld . cWorld . lWorld . items . at i ?~ (itm & itID .~ NInt i & itLocation .~ OnFloor False)
& gwWorld . cWorld . lWorld . items . at i ?~ (itm & itID .~ NInt i & itLocation .~ OnFloor)
)
PutCrit cr -> plNewUpID (gwWorld . cWorld . lWorld . creatures) crID (mvCr p rot cr) w
PutForeground fs ->
+7 -3
View File
@@ -58,10 +58,14 @@ crs :: Universe -> [Creature]
crs u = u ^.. uvWorld . cWorld . lWorld . creatures . each
testStringInit :: Universe -> [String]
testStringInit u = [u ^. uvWorld . input . mouseContext . to show
testStringInit u =
[ u ^. uvWorld . testString
, u ^. uvWorld . input . mouseContext . to show
, u ^. uvWorld . hud . diSelection . to show
] <> u ^.. uvWorld . hud . diSections . each . ssSet . to show
-- u ^. uvWorld . hud . manObject . to prettyShort
, u ^. uvWorld . cWorld . lWorld . lInvLock . to show
]
<> u ^. uvWorld . hud . manObject . to prettyShort
<> u ^.. uvWorld . hud . diSections . each . ssSet . to show
--testStringInit u = u ^. uvWorld . cWorld . lWorld . creatures . ix 5 . crActionPlan . to prettyShort
--[show . getSum $ foldMap (Sum . crslime) (crs u)]
-- u ^.. tocrs . each . crType . slimeSplitTimer . to show