Further simplify right button options

This commit is contained in:
2023-05-15 11:39:43 +01:00
parent 0e450f7bc7
commit c4ec84c0f9
3 changed files with 12 additions and 11 deletions
+4 -4
View File
@@ -1,6 +1,7 @@
module Dodge.Inventory.RBList (
updateRBList,
getEquipmentAllocation,
equipSiteToPositions,
) where
import Control.Lens
@@ -16,7 +17,7 @@ updateRBList w
| not (SDL.ButtonRight `M.member` (w ^. input . mouseButtons)) =
w & rbOptions .~ NoRightButtonOptions
| otherwise = case w ^. rbOptions of
EquipOptions{} -> w & rbOptions . opAllocateEquipment .~ (getEquipmentAllocation w)
EquipOptions{} -> w
_ -> fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
esite <- cr ^? crInv . ix i . itUse . equipEffect . eeSite
@@ -26,17 +27,16 @@ updateRBList w
.~ EquipOptions
{ _opEquip = equipSiteToPositions esite
, _opSel = chooseEquipmentPosition cr (equipSiteToPositions esite)
, _opAllocateEquipment = DoNotMoveEquipment
}
& rbOptions . opAllocateEquipment .~ (getEquipmentAllocation w)
where
cr = you w
getEquipmentAllocation :: World -> EquipmentAllocation
getEquipmentAllocation w = fromMaybe DoNotMoveEquipment $ do
curpos <- you w ^? crManipulation . manObject . inInventory . ispItem
esite <- you w ^? crInv . ix curpos . itUse . equipEffect . eeSite
i <- w ^? rbOptions . opSel
es <- w ^? rbOptions . opEquip . ix i
es <- equipSiteToPositions esite ^? ix i
return $ case you w ^? crInvEquipped . ix curpos of
Just epos
| es == epos -> RemoveEquipment{_allocOldPos = epos}