Fix inventory swapping equipment bug
This commit is contained in:
@@ -210,12 +210,13 @@ 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
|
||||
dropItem cr invid = rmInvItem cid invid . copyInvItemToFloor cr invid -- . mayberemoveequip
|
||||
where
|
||||
cid = _crID cr
|
||||
mayberemoveequip = case _crLeftInvSel cr of
|
||||
Just i | i == invid -> creatures . ix cid . crLeftInvSel .~ Nothing
|
||||
_ -> id
|
||||
-- the following should be done in rmInvItem
|
||||
-- mayberemoveequip = case _crLeftInvSel cr of
|
||||
-- Just i | i == invid -> creatures . ix cid . crLeftInvSel .~ Nothing
|
||||
-- _ -> id
|
||||
|
||||
youDropItem :: World -> World
|
||||
youDropItem w
|
||||
@@ -239,7 +240,6 @@ copyInvItemToFloor cr i = copyItemToFloor (_crPos cr)
|
||||
& itIsHeld .~ False
|
||||
)
|
||||
|
||||
|
||||
sizeSelf :: Float -> Creature -> World -> Maybe World
|
||||
sizeSelf x cr w
|
||||
-- | _crPos cr1 == _crPos cr2 = Just $ w
|
||||
|
||||
@@ -28,7 +28,7 @@ crMvAbsolute p' cr = advanceStepCounter (magV p) cr
|
||||
strengthFactor :: Int -> Float
|
||||
strengthFactor i
|
||||
| i > 9 = 1
|
||||
| i < 1 = 0.1
|
||||
| i < 1 = 0
|
||||
| otherwise = 0.1 * fromIntegral i
|
||||
|
||||
crMvForward
|
||||
|
||||
@@ -71,11 +71,13 @@ eqSiteToPos cr es = case es of
|
||||
useLeftItem :: Int -> World -> World
|
||||
useLeftItem cid w
|
||||
| _crInvLock cr = w
|
||||
| itConsumable = useItem cr w
|
||||
| itmShouldBeUsed = useItem cr w
|
||||
| otherwise = fromMaybe w $ do
|
||||
invid <- _crLeftInvSel cr
|
||||
f <- cr ^? crInv . ix invid . itUse . lUse
|
||||
return $ f cr invid w
|
||||
where
|
||||
cr = _creatures w IM.! cid
|
||||
itConsumable = isJust $ cr ^? crInv . ix (_crInvSel cr) . itUse . cUse
|
||||
itmShouldBeUsed = isJust (cr ^? crInv . ix (_crInvSel cr) . itUse . cUse)
|
||||
|| isJust (cr ^? crInv . ix (_crInvSel cr) . itUse . eqUse)
|
||||
-- TODO determine itmShouldBeUsed with reference to config options
|
||||
|
||||
@@ -16,7 +16,7 @@ strFromEquipment = sum . fmap equipmentStrValue . crCurrentEquipment
|
||||
|
||||
equipmentStrValue :: Item -> Int
|
||||
equipmentStrValue itm = case _itType itm of
|
||||
FRONTARMOUR -> negate 1
|
||||
FRONTARMOUR -> negate 3
|
||||
POWERLEGS -> 3
|
||||
_ -> 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user