This commit is contained in:
2021-12-01 11:11:24 +00:00
parent b9e4a80a46
commit d75ea2b252
5 changed files with 10 additions and 13 deletions
+3 -3
View File
@@ -76,7 +76,7 @@ augmentedInvSizes = bimapAugmentInv _itInvSize closeObjectSize
bimapAugmentInv :: (Item -> a) -> (Either FloorItem Button -> a) -> World -> IM.IntMap a
bimapAugmentInv f g w = IM.union
(fmap f $ yourInv w)
(f <$> yourInv w)
(IM.fromAscList $ zip [length (yourInv w) ..] $ map g $ _closeObjects w)
invSelSize :: Int -> World -> Int
@@ -108,7 +108,7 @@ updateCloseObjects w = w & closeObjects .~ unionBy closeObjEq oldCloseFiltered c
& creatures . ix (_yourID w) . crInvSel %~ updateinvsel
where
updateinvsel curinvsel
| length (augmentedInvSizes w) <= curinvsel = length (augmentedInvSizes w) - 1
| length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1
| otherwise = curinvsel
filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasLOS ypos (closeObjPos obj) w
ypos = _crPos $ you w
@@ -173,7 +173,7 @@ bestCloseObjectIndex w = findIndex f $ _closeObjects w
selectedCloseObject :: World -> Maybe (Int,Either FloorItem Button)
selectedCloseObject w
| invsel >= length inv = Just $ selectNthCloseObject w (invsel - length inv)
| otherwise = fmap (selectNthCloseObject w) $ bestCloseObjectIndex w
| otherwise = selectNthCloseObject w <$> bestCloseObjectIndex w
where
invsel = _crInvSel cr
cr = you w