Add newtype to floor item ids
This commit is contained in:
@@ -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) =
|
||||
|
||||
@@ -226,7 +226,7 @@ useEquipment cr i = useE (_eeUse (_equipEffect $ _itUse itm)) itm cr
|
||||
|
||||
-- a map updating all inventory items
|
||||
updateInv :: Creature -> World -> World
|
||||
updateInv cr = cWorld . lWorld . creatures . ix (_crID cr) . crInv %~ IM.mapWithKey (itemUpdate cr)
|
||||
updateInv cr = cWorld . lWorld . creatures . ix (_crID cr) . crInv %~ IM.map itemUpdate
|
||||
|
||||
-- a loop going over equipped items
|
||||
equipmentEffects :: Creature -> World -> World
|
||||
@@ -259,14 +259,14 @@ itemInvSideEffect _ _
|
||||
-- where
|
||||
-- attachoff = it ^?! itDimension . dimAttachPos
|
||||
|
||||
itemUpdate :: Creature -> Int -> Item -> Item
|
||||
itemUpdate cr i =
|
||||
itemUpdate :: Item -> Item
|
||||
itemUpdate =
|
||||
updateAutoRecharge
|
||||
. (itUse %~ useUpdate)
|
||||
. (itLocation .~ InInv (_crID cr) i itmisselected itmisroot)
|
||||
where
|
||||
itmisroot = Just i == (cr ^? crManipulation . manObject . inInventory . imRootItem)
|
||||
itmisselected = Just i == (cr ^? crManipulation . manObject . inInventory . imSelectedItem)
|
||||
-- . (itLocation .~ InInv (_crID cr) i itmisselected itmisroot)
|
||||
-- where
|
||||
-- itmisroot = Just i == (cr ^? crManipulation . manObject . inInventory . imRootItem)
|
||||
-- itmisselected = Just i == (cr ^? crManipulation . manObject . inInventory . imSelectedItem)
|
||||
|
||||
updateAutoRecharge :: Item -> Item
|
||||
updateAutoRecharge it = case it ^? itUse . leftConsumption of
|
||||
|
||||
Reference in New Issue
Block a user