Allow fast drop and pickup, fix right button options bug

This commit is contained in:
2023-01-13 16:32:42 +00:00
parent 5f871264d4
commit 6f1162f7b9
4 changed files with 24 additions and 20 deletions
+7 -10
View File
@@ -144,7 +144,6 @@ performAction cr w ac = case ac of
(imps, _) -> (imps, Just $ DoReplicatePartial startac (t -1) startac)
NoAction -> ([], Nothing)
setMinInvSize :: Int -> Creature -> World -> World
setMinInvSize n cr = cWorld . lWorld . creatures . ix (_crID cr) . crInvCapacity .~ n
@@ -162,7 +161,7 @@ organiseInvKeys cid w =
. (crInvSel . iselAction .~ NoInvSelAction)
)
where
cr = w ^?! cWorld . lWorld . creatures . ix cid-- _creatures (_cWorld w) IM.! cid
cr = w ^?! cWorld . lWorld . creatures . ix cid -- _creatures (_cWorld w) IM.! cid
pairs = IM.toList (_crInv cr)
newSelKey = fromMaybe 0 $ findIndex ((== crSel cr) . fst) pairs
newInv = IM.fromAscList $ zip [0 ..] $ map snd pairs
@@ -187,21 +186,19 @@ dropItem cr invid = rmInvItem cid invid . copyInvItemToFloor cr invid -- . maybe
-- Just i | i == invid -> creatures . ix cid . crLeftInvSel .~ Nothing
-- _ -> id
-- | Get your creature to drop the item under the cursor.
youDropItem :: World -> World
youDropItem w
| _crInvLock (you w) = w
| otherwise = youDropItem' w
-- | Get your creature to drop the item under the cursor.
youDropItem' :: World -> World
youDropItem' w = case yourItem w ^? _Just . itCurseStatus of
Just Uncursed ->
| _crInvLock (you w) || cursed = w
| otherwise =
w
& dropItem cr (crSel cr)
& soundStart (CrSound (_crID cr)) (_crPos cr) whiteNoiseFadeOutS Nothing
_ -> w
where
cr = you w
cursed = fromMaybe True $ do
it <- yourItem w
return $ it ^. itCurseStatus /= Uncursed
-- | Copy an inventory item to the floor.
copyInvItemToFloor :: Creature -> Int -> World -> World