Fix bug in item loc when combining items, rethink centralizing item locs
This commit is contained in:
@@ -15,6 +15,8 @@ import Dodge.Item.Grammar
|
||||
import Data.Maybe
|
||||
import Control.Applicative
|
||||
|
||||
-- this assumes the creature inventory is well formed, specifically the
|
||||
-- location ids
|
||||
tryGetRootItemInvID :: Int -> Creature -> Maybe Int
|
||||
tryGetRootItemInvID i cr = do
|
||||
let adj = case invAdj' (_crInv cr) of
|
||||
@@ -39,7 +41,7 @@ crUpdateItemLocations crid lw = fromMaybe lw $ do
|
||||
crUpdateInvidLocations :: ManipulatedObject -> Int -> LWorld -> Int -> Item -> LWorld
|
||||
crUpdateInvidLocations mo crid lw invid itm = lw
|
||||
& creatures . ix crid . crInv . ix invid . itLocation .~ newloc
|
||||
& itemLocations . ix itid .~ newloc
|
||||
& itemLocations %~ IM.insert itid newloc
|
||||
where
|
||||
itid = itm ^. itID
|
||||
newloc = InInv crid invid (Just invid == mo ^? inInventory . imSelectedItem)
|
||||
|
||||
Reference in New Issue
Block a user