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"
|
||||
|
||||
@@ -20,7 +20,7 @@ updateRBList w
|
||||
| otherwise = case w ^. rbOptions of
|
||||
EquipOptions{} -> w
|
||||
_ -> fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
esite <- cr ^? crInv . ix i . itUse . equipEffect . eeSite
|
||||
return $
|
||||
w
|
||||
@@ -35,7 +35,7 @@ updateRBList w
|
||||
-- find a free equipment slot
|
||||
chooseEquipmentPosition :: Creature -> [EquipPosition] -> Int
|
||||
chooseEquipmentPosition cr eps = fromMaybe (chooseFreeSite cr eps) $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
ep <- cr ^? crInvEquipped . ix i
|
||||
elemIndex ep eps
|
||||
|
||||
@@ -46,7 +46,7 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
|
||||
|
||||
getEquipmentAllocation :: World -> EquipmentAllocation
|
||||
getEquipmentAllocation w = fromMaybe DoNotMoveEquipment $ do
|
||||
curpos <- you w ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
curpos <- you w ^? crManipulation . manObject . imSelectedItem
|
||||
esite <- you w ^? crInv . ix curpos . itUse . equipEffect . eeSite
|
||||
i <- w ^? rbOptions . opSel
|
||||
<|> Just (chooseEquipmentPosition (you w) (equipSiteToPositions esite))
|
||||
|
||||
Reference in New Issue
Block a user