Allow for stacking of items and combining sensibly
This commit is contained in:
@@ -17,6 +17,7 @@ module Dodge.Creature.Action
|
||||
, pickUpItemID
|
||||
)
|
||||
where
|
||||
import Dodge.Inventory.Add
|
||||
import Dodge.Path
|
||||
import Dodge.Default
|
||||
import Dodge.WallCreatureCollisions
|
||||
@@ -252,16 +253,5 @@ pickUpItemID cid flid w = pickUpItem cid (_floorItems w IM.! flid) w
|
||||
|
||||
{- | Pick up a specific item. -}
|
||||
pickUpItem :: Int -> FloorItem -> World -> World
|
||||
pickUpItem cid flit w = case maybeInvSlot of
|
||||
Nothing -> w
|
||||
Just i -> w
|
||||
& soundStart (CrSound cid) (_flItPos flit) pickUpS Nothing
|
||||
& updateItLocation i
|
||||
& floorItems %~ IM.delete (_flItID flit)
|
||||
& creatures . ix cid . crInv %~ IM.insertWith (const $ itAmount +~ 1) i it
|
||||
where
|
||||
it = _flIt flit
|
||||
maybeInvSlot = checkInvSlotsYou it w
|
||||
updateItLocation invid w' = case _itID it of
|
||||
Nothing -> w'
|
||||
Just j -> w' & itemPositions . ix j .~ InInv 0 invid
|
||||
pickUpItem cid flit w = maybe w (soundStart (CrSound cid) (_flItPos flit) pickUpS Nothing)
|
||||
$ tryPutItemInInv cid flit w
|
||||
|
||||
Reference in New Issue
Block a user