Flatten values in creature manipulation data types
This commit is contained in:
@@ -38,9 +38,9 @@ tryGetRootItemInvID i cr = do
|
||||
|
||||
updateRootItemID :: Creature -> Creature
|
||||
updateRootItemID cr = fromMaybe cr $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
j <- tryGetRootItemInvID i cr
|
||||
return $ cr & crManipulation . manObject . inInventory . imRootItem .~ j
|
||||
return $ cr & crManipulation . manObject . imRootItem .~ j
|
||||
|
||||
-- the following assumes that the crManipulation is correct
|
||||
crUpdateItemLocations :: Int -> LWorld -> LWorld
|
||||
@@ -58,9 +58,9 @@ crUpdateInvidLocations mo crid lw invid itm = lw
|
||||
newloc = InInv
|
||||
{ _ilCrID = crid
|
||||
, _ilInvID = invid
|
||||
, _ilIsRoot = Just invid == mo ^? inInventory . imSelectedItem
|
||||
, _ilIsSelected = Just invid == mo ^? inInventory . imRootItem
|
||||
, _ilIsAttached = invid `IS.member` (mo ^. inInventory . imAttachedItems)
|
||||
, _ilIsRoot = Just invid == mo ^? imSelectedItem
|
||||
, _ilIsSelected = Just invid == mo ^? imRootItem
|
||||
, _ilIsAttached = invid `IS.member` (mo ^. imAttachedItems)
|
||||
}
|
||||
|
||||
-- this should be looked at, as it is sometimes used in functions that need not
|
||||
@@ -75,15 +75,15 @@ setInvPosFromSS w =
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
|
||||
case i of
|
||||
(-1) -> Just $ InInventory SortInventory
|
||||
(-1) -> Just SortInventory
|
||||
0 -> do
|
||||
(rootid,aset) <- tryGetRootAttachedFromInvID j (you w ^. crInv)
|
||||
return $ InInventory $ SelectedItem
|
||||
return SelectedItem
|
||||
{ _imSelectedItem = j
|
||||
, _imRootItem = rootid
|
||||
, _imAttachedItems = aset
|
||||
}
|
||||
1 -> Just SelNothing
|
||||
2 -> Just $ InNearby SortNearby
|
||||
3 -> Just $ InNearby $ SelCloseObject j
|
||||
2 -> Just SortNearby
|
||||
3 -> Just $ SelCloseObject j
|
||||
_ -> error "selection out of bounds"
|
||||
|
||||
Reference in New Issue
Block a user