From 58427da0c4a78abff1a129e7643cb941293f464b Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 25 May 2022 23:20:14 +0100 Subject: [PATCH] Make unequip event occur on equipped item drop --- src/Dodge/Inventory.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 4fddaf894..5a338ef54 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -56,10 +56,16 @@ rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itCons & creatures . ix cid . crInvSel %~ g & creatures . ix cid . crLeftInvSel %~ g' & removeAnySlotEquipment + & dounequipfunction & creatures . ix cid . crInvEquipped %~ IM.delete invid & creatures . ix cid . crInvEquipped %~ IM.mapKeys g -- TODO check whether this can be mapKeysMonotonic where + cr = _creatures w IM.! cid + itm = _crInv cr IM.! invid + dounequipfunction = fromMaybe id $ do + rmf <- itm ^? itUse . eqOnRemove + return $ rmf itm cr removeAnySlotEquipment = case w ^? creatures . ix cid . crInvEquipped . ix invid of Just epos -> creatures . ix cid . crEquipment . at epos .~ Nothing Nothing -> id