Commit before attempting to move some data into a "local" world type

This commit is contained in:
2021-11-28 01:32:42 +00:00
parent 3e64e33232
commit 24480bbe52
10 changed files with 47 additions and 21 deletions
+6 -1
View File
@@ -6,6 +6,7 @@ module Dodge.Creature.Action
, stripNoItems
, setMinInvSize
, dropUnselected
, dropExcept
, startReloadingWeapon
, blinkAction
, sizeSelf
@@ -215,13 +216,17 @@ organiseInvKeys cid w = w & creatures . ix cid %~
where
cr = _creatures w IM.! cid
pairs = IM.toList (_crInv cr)
newSelKey = fromJust $ findIndex ( (== _crInvSel cr) . fst) pairs
newSelKey = fromMaybe 0 $ findIndex ( (== _crInvSel cr) . fst) pairs
newInv = IM.fromAscList $ zip [0..] $ map snd pairs
dropUnselected :: Creature -> World -> World
dropUnselected cr w = foldr (dropItem cr) w . IM.keys
$ _crInvSel cr `IM.delete` _crInv cr
dropExcept :: Creature -> Int -> World -> World
dropExcept cr invid w = foldr (dropItem cr) w . IM.keys
$ invid `IM.delete` _crInv cr
dropItem :: Creature -> Int -> World -> World
dropItem cr invid = rmInvItem cid invid . copyInvItemToFloor cr invid . mayberemoveequip
where