Fix bugs in equipment allocation using hotkeys

The behaviour is still not perfect, should be able to cycle through all
options by pressing one key. There is unnecessary memory of past state
going on here
This commit is contained in:
2025-01-01 14:48:17 +00:00
parent 7dd379d4bc
commit dae0e0591c
10 changed files with 289 additions and 313 deletions
+5 -5
View File
@@ -42,15 +42,15 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
where
hasnoequipment ep = isNothing $ cr ^? crEquipment . ix ep
getEquipmentAllocation :: World -> EquipmentAllocation
getEquipmentAllocation w = fromMaybe DoNotMoveEquipment $ do
curpos <- you w ^? crManipulation . manObject . imSelectedItem
esite <- you w ^? crInv . ix curpos . itUse . uequipEffect . eeType
getEquipmentAllocation :: Int -> World -> EquipmentAllocation
getEquipmentAllocation invid w = fromMaybe DoNotMoveEquipment $ do
-- curpos <- you w ^? crManipulation . manObject . imSelectedItem
esite <- you w ^? crInv . ix invid . itUse . uequipEffect . eeType
i <-
w ^? rbOptions . opSel
<|> Just (chooseEquipPosition (you w) (eqSiteToPositions esite))
es <- eqSiteToPositions esite ^? ix i
return $ case you w ^? crInv . ix curpos . itLocation . ilEquipSite . _Just of
return $ case you w ^? crInv . ix invid . itLocation . ilEquipSite . _Just of
Just epos
| es == epos -> RemoveEquipment{_allocOldPos = epos}
Just epos