Commit before attempting to add concurrency to loop
This commit is contained in:
@@ -1,27 +1,11 @@
|
||||
module Dodge.Item.Location where
|
||||
module Dodge.Item.Location (
|
||||
pointerToItemLocation,
|
||||
getItem,
|
||||
pointerToItem,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
setHeldItemLoc :: Creature -> World -> World
|
||||
setHeldItemLoc cr = fst . getHeldItemLoc cr
|
||||
|
||||
getHeldItemLoc :: Creature -> World -> (World, Int)
|
||||
getHeldItemLoc cr w = case maybeitid of
|
||||
Nothing ->
|
||||
( w & cWorld . creatures . ix cid . crInv . ix j . itID .~ newitid
|
||||
& cWorld . itemLocations %~ IM.insert newitid (InInv cid j)
|
||||
, itid
|
||||
)
|
||||
_ -> (w, itid)
|
||||
where
|
||||
cid = _crID cr
|
||||
j = crSel cr
|
||||
newitid = IM.newKey $ _itemLocations (_cWorld w)
|
||||
maybeitid = cr ^? crInv . ix j . itID
|
||||
itid = fromMaybe newitid maybeitid
|
||||
|
||||
getItem :: Int -> World -> Maybe Item
|
||||
getItem itid w = do
|
||||
|
||||
Reference in New Issue
Block a user