Add newtype to floor item ids

This commit is contained in:
2024-09-23 22:42:09 +01:00
parent 43b365185d
commit 265da89791
20 changed files with 193 additions and 158 deletions
+4 -14
View File
@@ -12,7 +12,6 @@ module Dodge.Creature.Action (
blinkActionFail,
unsafeBlinkAction,
sizeSelf,
copyInvItemToFloor,
youDropItem,
pickUpItem,
-- pickUpItemID,
@@ -170,19 +169,16 @@ setMinInvSize n cr = cWorld . lWorld . creatures . ix (_crID cr) . crInvCapacity
-- newSelKey = fromMaybe 0 $ findIndex ((== crSel cr) . fst) pairs
-- newInv = IM.fromAscList $ zip [0 ..] $ map snd pairs
--dropUnselected :: Creature -> World -> World
--dropUnselected cr w =
-- foldr (dropItem cr) w . IM.keys $
-- crSel 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 (_crID cr) invid . copyInvItemToFloor cr invid -- . mayberemoveequip
dropItem cr invid = rmInvItem (_crID cr) invid .
copyItemToFloor (_crPos cr) itm -- . mayberemoveequip
where
itm = fromMaybe (error "dropItem cannot find item") $ cr ^? crInv . ix invid
-- the following should be done in rmInvItem
-- mayberemoveequip = case _crLeftInvSel cr of
-- Just i | i == invid -> creatures . ix cid . crLeftInvSel .~ Nothing
@@ -205,12 +201,6 @@ youDropItem w = fromMaybe w $ do
it <- yourSelectedItem w
return $ it ^. itCurseStatus /= Uncursed
-- | Copy an inventory item to the floor.
copyInvItemToFloor :: Creature -> Int -> World -> World
copyInvItemToFloor cr i =
copyItemToFloor (_crPos cr) $
_crInv cr IM.! i
sizeSelf :: Float -> Creature -> World -> Maybe World
sizeSelf x cr w
| not (crOnWall cr1 w) =