Add newtype to floor item ids
This commit is contained in:
@@ -6,6 +6,7 @@ module Dodge.Item.Location (
|
||||
pointerYourRootItem,
|
||||
) where
|
||||
|
||||
import NewInt
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
@@ -14,7 +15,7 @@ getItem :: Int -> World -> Maybe Item
|
||||
getItem itid w = do
|
||||
itpos <- w ^? cWorld . lWorld . itemLocations . ix itid
|
||||
case itpos of
|
||||
OnFloor flitid -> w ^? cWorld . lWorld . floorItems . ix flitid . flIt
|
||||
OnFloor flitid -> w ^? cWorld . lWorld . floorItems . unNIntMap . ix (_unNInt flitid) . flIt
|
||||
InInv {_ilCrID = cid, _ilInvID = invid}
|
||||
-> w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||
OnTurret mcid -> w ^? cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuWeapon
|
||||
@@ -28,7 +29,7 @@ pointerToItemLocation ::
|
||||
f World
|
||||
pointerToItemLocation InInv {_ilCrID = cid, _ilInvID = invid}
|
||||
= cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||
pointerToItemLocation (OnFloor flid) = cWorld . lWorld . floorItems . ix flid . flIt
|
||||
pointerToItemLocation (OnFloor flid) = cWorld . lWorld . floorItems . unNIntMap . ix (_unNInt flid) . flIt
|
||||
pointerToItemLocation _ = const pure
|
||||
|
||||
pointerYourSelectedItem :: Applicative a => (Item -> a Item) -> World -> a World
|
||||
|
||||
@@ -3,6 +3,7 @@ module Dodge.Item.Location.Initialize
|
||||
, initItemLocations
|
||||
)
|
||||
where
|
||||
import NewInt
|
||||
import Dodge.Data.LWorld
|
||||
import Control.Lens
|
||||
import qualified IntMapHelp as IM
|
||||
@@ -17,9 +18,9 @@ initCrsItemLocations w = w' & creatures .~ newcreatures
|
||||
(w', newcreatures) = mapAccumR initCrItemLocations w (w ^. creatures)
|
||||
|
||||
initFlItemsLocations :: LWorld -> LWorld
|
||||
initFlItemsLocations w = w' & floorItems .~ newfloorItems
|
||||
initFlItemsLocations w = w' & floorItems .~ NIntMap newfloorItems
|
||||
where
|
||||
(w', newfloorItems) = mapAccumR initFlItemLocation w (w ^. floorItems)
|
||||
(w', newfloorItems) = mapAccumR initFlItemLocation w (w ^. floorItems . unNIntMap)
|
||||
|
||||
initTusItemLocations :: LWorld -> LWorld
|
||||
initTusItemLocations w = w' & machines .~ newmachines
|
||||
|
||||
Reference in New Issue
Block a user