Add file
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
module Dodge.Item.Location where
|
||||
import Dodge.Data
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
|
||||
setHeldItemPos :: Creature -> World -> World
|
||||
setHeldItemPos cr = fst . getHeldItemPos cr
|
||||
|
||||
getHeldItemPos :: Creature -> World -> (World,Int)
|
||||
getHeldItemPos cr w = case maybeitid of
|
||||
Nothing ->
|
||||
( w & creatures . ix cid . crInv . ix j . itID ?~ newitid
|
||||
& itemPositions %~ IM.insert newitid (InInv cid j)
|
||||
, itid)
|
||||
_ -> (w, itid)
|
||||
where
|
||||
cid = _crID cr
|
||||
j = _crInvSel cr
|
||||
newitid = IM.newKey $ _itemPositions w
|
||||
maybeitid = cr ^? crInv . ix j . itID . _Just
|
||||
itid = fromMaybe newitid maybeitid
|
||||
Reference in New Issue
Block a user