Implement combining of items
This commit is contained in:
@@ -14,6 +14,7 @@ module Dodge.Creature.Action
|
||||
, copyInvItemToFloor
|
||||
, youDropItem
|
||||
, pickUpItem
|
||||
, pickUpItemID
|
||||
)
|
||||
where
|
||||
import Dodge.Path
|
||||
@@ -221,21 +222,6 @@ youDropItem w = case yourItem w ^? _Just . itCurseStatus of
|
||||
copyInvItemToFloor :: Creature -> Int -> World -> World
|
||||
copyInvItemToFloor cr i = copyItemToFloor (_crPos cr) (_crInv cr IM.! i)
|
||||
|
||||
{- | 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
|
||||
|
||||
sizeSelf :: Float -> Creature -> World -> Maybe World
|
||||
sizeSelf x cr w
|
||||
@@ -259,3 +245,23 @@ sizeSelf x cr w
|
||||
raddist = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR)
|
||||
cid = _crID cr
|
||||
cpos = _crPos cr
|
||||
|
||||
pickUpItemID :: Int -> Int -> World -> World
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user