Allow for stacking of items and combining sensibly

This commit is contained in:
2021-12-03 17:18:06 +00:00
parent b2a9192fe4
commit b41e3e3637
24 changed files with 166 additions and 159 deletions
+3 -13
View File
@@ -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