Fix crash on empty inventory left click
This commit is contained in:
@@ -49,11 +49,11 @@ toggleEquipmentAt invid cr = cr & crInvEquipped . at invid %~ f
|
||||
useLeftItem :: Int -> World -> World
|
||||
useLeftItem cid w
|
||||
| _crInvLock cr = w
|
||||
| isJust (citem ^? itUse . cUse) = useItem cr w
|
||||
| itConsumable = useItem cr w
|
||||
| otherwise = fromMaybe w $ do
|
||||
invid <- _crLeftInvSel cr
|
||||
f <- cr ^? crInv . ix invid . itUse . lUse
|
||||
return $ f cr invid w
|
||||
where
|
||||
cr = _creatures w IM.! cid
|
||||
citem = _crInv cr IM.! _crInvSel cr
|
||||
itConsumable = isJust $ cr ^? crInv . ix (_crInvSel cr) . itUse . cUse
|
||||
|
||||
Reference in New Issue
Block a user