Cleanup
This commit is contained in:
+19
-24
@@ -50,22 +50,25 @@ rmInvItem ::
|
||||
Int ->
|
||||
World ->
|
||||
World
|
||||
rmInvItem cid invid w = case w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid . itUse . useAmount of
|
||||
Just x | x > 1 -> w & cWorld . lWorld . creatures . ix cid . crInv . ix invid . itUse . useAmount %~ subtract 1
|
||||
rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount of
|
||||
Just x | x > 1 -> w & pointcid . crInv . ix invid . itUse . useAmount %~ subtract 1
|
||||
_ ->
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix cid . crInv %~ f
|
||||
& cWorld . lWorld . creatures . ix cid . crInvSel %~ stopCrInvSelAction
|
||||
& cWorld . lWorld . creatures . ix cid . crInvSel . iselPos %~ g
|
||||
& cWorld . lWorld . creatures . ix cid . crLeftInvSel %~ g'
|
||||
& pointcid . crInv %~ f
|
||||
& pointcid . crInvSel %~ stopCrInvSelAction
|
||||
& pointcid . crInvSel . iselPos %~ g
|
||||
& pointcid . crLeftInvSel %~ g'
|
||||
& removeAnySlotEquipment
|
||||
& dounequipfunction
|
||||
& doanyitemeffect
|
||||
& cWorld . lWorld . creatures . ix cid . crInvEquipped %~ IM.delete invid
|
||||
& cWorld . lWorld . creatures . ix cid . crInvEquipped %~ IM.mapKeys g
|
||||
& pointcid . crInvEquipped %~ IM.delete invid
|
||||
& pointcid . crInvEquipped %~ IM.mapKeys g
|
||||
where
|
||||
-- TODO check whether this can be mapKeysMonotonic
|
||||
|
||||
getcid = cWorld . lWorld . creatures . ix cid
|
||||
pointcid = cWorld . lWorld . creatures . ix cid
|
||||
|
||||
stopCrInvSelAction (InvSel i a)
|
||||
| i == invid = InvSel i NoInvSelAction
|
||||
| otherwise = InvSel i a
|
||||
@@ -78,9 +81,9 @@ rmInvItem cid invid w = case w ^? cWorld . lWorld . creatures . ix cid . crInv .
|
||||
rmf <- itm ^? itEffect . ieOnDrop
|
||||
return $ doInvEffect rmf itm cr
|
||||
removeAnySlotEquipment = case w ^? cWorld . lWorld . creatures . ix cid . crInvEquipped . ix invid of
|
||||
Just epos -> cWorld . lWorld . creatures . ix cid . crEquipment . at epos .~ Nothing
|
||||
Just epos -> pointcid . crEquipment . at epos .~ Nothing
|
||||
Nothing -> id
|
||||
maxk = fmap fst $ IM.lookupMax $ w ^?! cWorld . lWorld . creatures . ix cid . crInv
|
||||
maxk = fmap fst $ IM.lookupMax $ cr ^?! crInv
|
||||
f inv =
|
||||
let (xs, ys) = IM.split invid inv
|
||||
in xs `IM.union` IM.mapKeys (subtract 1) ys
|
||||
@@ -143,13 +146,7 @@ selNumCol :: Int -> World -> Color
|
||||
selNumCol i w = fromMaybe white $ trimapAugmentInv _itInvColor invDimColor closeObjectCol w IM.!? i
|
||||
|
||||
invSelPos :: World -> Int
|
||||
invSelPos w = splitgap + (foldl' (+) 0 . fst $ IM.split invsel (augmentedInvSizes w))
|
||||
where
|
||||
invsel = yourInvSel w
|
||||
splitgap = 0
|
||||
-- splitgap
|
||||
-- | invsel < length (yourInv w) = 0
|
||||
-- | otherwise = 1
|
||||
invSelPos w = sum . fst $ IM.split (yourInvSel w) (augmentedInvSizes w)
|
||||
|
||||
updateTerminal :: World -> World
|
||||
updateTerminal = checkTermDist
|
||||
@@ -204,8 +201,6 @@ updateRBList w
|
||||
& setEquipActivation
|
||||
Nothing -> w & rbOptions .~ NoRightButtonOptions
|
||||
where
|
||||
-- | otherwise = w & rbOptions .~ NoRightButtonOptions
|
||||
|
||||
curinvid = crSel cr
|
||||
cr = you w
|
||||
|
||||
@@ -318,15 +313,15 @@ changeInvSel i w
|
||||
| n == 0 = w
|
||||
| yourInvSel w < n =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
& pointcrInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& pointcrInvSel . iselAction .~ NoInvSelAction
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ ((+ n) . (`mod` numCO) . subtract (i + n))
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
& pointcrInvSel . iselPos %~ ((+ n) . (`mod` numCO) . subtract (i + n))
|
||||
& pointcrInvSel . iselAction .~ NoInvSelAction
|
||||
where
|
||||
-- arguably this should jump the invpos into the inventory proper
|
||||
|
||||
pointcrInvSel = cWorld . lWorld . creatures . ix 0 . crInvSel
|
||||
n = length $ w ^?! cWorld . lWorld . creatures . ix 0 . crInv
|
||||
numCO = length $ w ^. cWorld . lWorld . closeObjects
|
||||
|
||||
|
||||
Reference in New Issue
Block a user