Remove yourID -- you are simply at 0
This commit is contained in:
+10
-12
@@ -169,7 +169,7 @@ updateCloseObjects :: World -> World
|
||||
updateCloseObjects w =
|
||||
w
|
||||
& cWorld . lWorld . closeObjects .~ unionBy closeObjEq oldCloseFiltered currentClose
|
||||
& cWorld . lWorld . creatures . ix (_yourID (_lWorld (_cWorld w))) . crInvSel . iselPos %~ updateinvsel
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ updateinvsel
|
||||
where
|
||||
updateinvsel curinvsel
|
||||
| length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1
|
||||
@@ -319,16 +319,16 @@ changeInvSel i w
|
||||
| n == 0 = w
|
||||
| yourInvSel w < n =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselAction .~ NoInvSelAction
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselPos %~ ((+ n) . (`mod` numCO) . subtract (i + n))
|
||||
& cWorld . lWorld . creatures . ix (w ^. cWorld . lWorld . yourID) . crInvSel . iselAction .~ NoInvSelAction
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ ((+ n) . (`mod` numCO) . subtract (i + n))
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
where
|
||||
-- arguably this should jump the invpos into the inventory proper
|
||||
|
||||
n = length $ _crInv $ _creatures (_lWorld (_cWorld w)) IM.! _yourID (_lWorld (_cWorld w))
|
||||
n = length $ w ^?! cWorld . lWorld . creatures . ix 0 . crInv
|
||||
numCO = length $ w ^. cWorld . lWorld . closeObjects
|
||||
|
||||
changeSwapInvSel :: Int -> World -> World
|
||||
@@ -336,13 +336,12 @@ changeSwapInvSel k w
|
||||
| n == 0 = w
|
||||
| yourInvSel w < n =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix yid %~ updatecreature
|
||||
& cWorld . lWorld . creatures . ix 0 %~ updatecreature
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix yid . crInvSel . iselPos .~ ico'
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos .~ ico'
|
||||
& cWorld . lWorld . closeObjects %~ swapIndices (i - n) (ico' - n)
|
||||
where
|
||||
yid = w ^. cWorld . lWorld . yourID
|
||||
updatecreature =
|
||||
(crInv %~ IM.safeSwapKeys (i `mod` n) swapi)
|
||||
. (crLeftInvSel . _Just %~ updateLeftInvSel)
|
||||
@@ -369,10 +368,9 @@ changeAugInvSel i w
|
||||
| n == 0 = w
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix yid . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix yid . crInvSel . iselAction .~ NoInvSelAction
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
where
|
||||
yid = w ^. cWorld . lWorld . yourID
|
||||
n = length (yourInv w) + length (w ^. cWorld . lWorld . closeObjects)
|
||||
|
||||
bestCloseObjectIndex :: World -> Maybe Int
|
||||
|
||||
Reference in New Issue
Block a user