Allow for different item drops on creature death
This commit is contained in:
+16
-4
@@ -49,10 +49,13 @@ numInventorySlots = 9
|
||||
itNotFull :: Item -> Bool
|
||||
itNotFull it = _itMaxStack it > _itAmount it
|
||||
|
||||
rmInvItem :: Int -> World -> World
|
||||
rmInvItem n w =
|
||||
let i = _crInvSel (_creatures w IM.! n)
|
||||
item = _crInv (_creatures w IM.! n) IM.! i
|
||||
rmInvItem
|
||||
:: Int -- ^ Creature id
|
||||
-> Int -- ^ Inventory position
|
||||
-> World
|
||||
-> World
|
||||
rmInvItem n i w =
|
||||
let item = _crInv (_creatures w IM.! n) IM.! i
|
||||
itRef = creatures . ix n . crInv . ix i
|
||||
in case item of
|
||||
Consumable {_itAmount = 1} -> set itRef NoItem w
|
||||
@@ -65,6 +68,15 @@ rmInvItem n w =
|
||||
Throwable {_itAmount = x} -> over (itRef . itAmount) (\y-> y-1) w
|
||||
_ -> set itRef NoItem w
|
||||
|
||||
{-
|
||||
Delete a creature's selected item, the item will no longer exist.
|
||||
-}
|
||||
rmSelectedInvItem
|
||||
:: Int -- ^ Creature id
|
||||
-> World
|
||||
-> World
|
||||
rmSelectedInvItem cid w = rmInvItem cid (_crInvSel (_creatures w IM.! cid)) w
|
||||
|
||||
-- for now, left are floor items, right are buttons
|
||||
closestActiveObject :: World -> Maybe (Either FloorItem Button)
|
||||
closestActiveObject w = listToMaybe $ sortBy (compare `on` dist ypos . pos) $ actObjs
|
||||
|
||||
Reference in New Issue
Block a user