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
|
||||
|
||||
Reference in New Issue
Block a user