Allow for separate equipment positions on body

This commit is contained in:
2022-05-21 14:41:49 +01:00
parent 398ed6d982
commit 8ad332aced
8 changed files with 69 additions and 10 deletions
+4 -3
View File
@@ -51,8 +51,9 @@ rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itCons
_ -> w & creatures . ix cid . crInv %~ f
& creatures . ix cid . crInvSel %~ g
& creatures . ix cid . crLeftInvSel . _Just %~ g
& creatures . ix cid . crInvEquipped %~ IS.delete invid
& creatures . ix cid . crInvEquipped %~ IS.map g
& creatures . ix cid . crInvEquipped %~ IM.delete invid
& creatures . ix cid . crInvEquipped %~ IM.mapKeys g
-- TODO check whether this can be mapKeysMonotonic
where
maxk = fmap fst $ IM.lookupMax $ _crInv $ _creatures w IM.! cid
f inv = let (xs,ys) = IM.split invid inv
@@ -186,7 +187,7 @@ changeSwapInvSel k w
updatecreature = ( crInv %~ IM.swapKeys (i `mod` n) swapi )
. (crLeftInvSel . _Just %~ updateLeftInvSel)
. (crInvSel %~ (`mod` n) . subtract k)
. (crInvEquipped %~ swapIntSetKeys i swapi)
. (crInvEquipped %~ IM.swapKeys i swapi)
swapi = (i - k) `mod` n
updateLeftInvSel li | i == li = swapi
| swapi == li = i