Fix bug on dropping item when reloading

This commit is contained in:
2022-06-22 19:22:17 +01:00
parent 4d1b5d3ca8
commit c34468aa49
6 changed files with 48 additions and 49 deletions
+4
View File
@@ -55,6 +55,7 @@ rmInvItem :: Int -- ^ Creature id
rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itConsumption . icAmount of
Just x | x > 1 -> w & creatures . ix cid . crInv . ix invid . itConsumption . icAmount %~ subtract 1
_ -> w & creatures . ix cid . crInv %~ f
& creatures . ix cid . crInvSel %~ stopCrInvSelAction
& creatures . ix cid . crInvSel . iselPos %~ g
& creatures . ix cid . crLeftInvSel %~ g'
& removeAnySlotEquipment
@@ -64,6 +65,9 @@ rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itCons
& creatures . ix cid . crInvEquipped %~ IM.mapKeys g
-- TODO check whether this can be mapKeysMonotonic
where
stopCrInvSelAction (InvSel i a)
| i == invid = InvSel i NoInvSelAction
| otherwise = InvSel i a
cr = _creatures w IM.! cid
itm = _crInv cr IM.! invid
dounequipfunction = fromMaybe id $ do