Use NewIntMap InvInt for crInv
This commit is contained in:
@@ -13,6 +13,7 @@ module Dodge.Creature.Action (
|
||||
youDropItem,
|
||||
) where
|
||||
|
||||
import NewInt
|
||||
import Dodge.Creature.MoveType
|
||||
import Dodge.Creature.Radius
|
||||
import Dodge.Item.BackgroundEffect
|
||||
@@ -166,14 +167,15 @@ performAction cr w ac = case ac of
|
||||
dropExcept :: Creature -> Int -> World -> World
|
||||
dropExcept cr invid w =
|
||||
foldr (dropItem cr) w . IM.keys $
|
||||
invid `IM.delete` _crInv cr
|
||||
-- invid `IM.delete` _crInv cr
|
||||
invid `IM.delete` (_unNIntMap $ _crInv cr)
|
||||
|
||||
-- why not a cid (Int)?
|
||||
dropItem :: Creature -> Int -> World -> World
|
||||
dropItem cr invid w' =
|
||||
doanyitemdropeffect
|
||||
. maybeshiftseldown
|
||||
. rmInvItem (_crID cr) invid
|
||||
. rmInvItem (_crID cr) (NInt invid)
|
||||
. copyItemToFloor (_crPos cr) itm -- . mayberemoveequip
|
||||
. soundStart (CrSound (_crID cr)) (_crPos cr) whiteNoiseFadeOutS Nothing
|
||||
$ w'
|
||||
@@ -183,7 +185,7 @@ dropItem cr invid w' =
|
||||
-- return $ doInvEffect rmf itm cr
|
||||
doanyitemdropeffect = itEffectOnDrop itm cr
|
||||
itm = fromMaybe (error "dropItem cannot find item") $ do
|
||||
itid <- cr ^? crInv . ix invid
|
||||
itid <- cr ^? crInv . ix (NInt invid)
|
||||
w' ^? cWorld . lWorld . items . ix itid
|
||||
maybeshiftseldown w = fromMaybe w $ do
|
||||
3 <- w ^? hud . hudElement . diSelection . _Just . _1
|
||||
@@ -193,8 +195,8 @@ dropItem cr invid w' =
|
||||
youDropItem :: World -> World
|
||||
youDropItem w = fromMaybe w $ do
|
||||
curpos <-
|
||||
cr ^? crManipulation . manObject . imSelectedItem
|
||||
<|> fmap fst (IM.lookupMax (cr ^. crInv))
|
||||
cr ^? crManipulation . manObject . imSelectedItem . unNInt
|
||||
<|> fmap fst (IM.lookupMax (cr ^. crInv . unNIntMap))
|
||||
--guard $ not $ _crInvLock cr
|
||||
guard $ not $ w ^. cWorld . lWorld . lInvLock
|
||||
return $ case cr ^. crStance . posture of
|
||||
|
||||
Reference in New Issue
Block a user