Improve combine menu visuals

This commit is contained in:
2022-05-24 15:25:05 +01:00
parent 7f55ba117f
commit 7c472c4ca4
4 changed files with 37 additions and 68 deletions
+6 -41
View File
@@ -22,14 +22,12 @@ itemEffect :: Creature -> Item -> World -> World
itemEffect cr it w = case it ^? itUse of
Just RightUse {_rUse = eff,_useMods = usemods}
-> hammerTest $ foldr ($) eff usemods it cr
Just LeftUse {} -> setuhamdown $ lhammer $ (toggleEquipmentAt (_rbOptions w) (_crInvSel cr)
. activateEquipmentAt (_rbOptions w))
Just EquipUse{} -> setuhamdown $ lhammer $ (toggleEquipmentAt (_rbOptions w) (_crInvSel cr)
. activateEquipmentAt (_rbOptions w))
Just LeftUse {} -> doequipmentchange
Just EquipUse{} -> doequipmentchange
-- ConsumeUse will cause problems if the item is not selected
Just (ConsumeUse eff) -> setuhamdown $ hammerTest $ eff it cr . rmInvItem (_crID cr) (_crInvSel cr)
Just NoUse -> setuhamdown w
Nothing -> setuhamdown w
Just NoUse -> setuhamdown w
Nothing -> setuhamdown w
where
hammerTest f = case _crHammerPosition cr of
HammerUp -> f w
@@ -38,6 +36,8 @@ itemEffect cr it w = case it ^? itUse of
HammerUp -> creatures . ix (_crID cr) %~ f'
_ -> id
setuhamdown = creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
doequipmentchange = setuhamdown $ lhammer (toggleEquipmentAt (_rbOptions w) (_crInvSel cr)
. activateEquipmentAt (_rbOptions w))
activateEquipmentAt :: RightButtonOptions -> Creature -> Creature
activateEquipmentAt rbo = case (rbo ^? opActivateEquipment . activateEquipment, rbo ^? opActivateEquipment . deactivateEquipment) of
@@ -68,41 +68,6 @@ toggleEquipmentAt rbops invid cr = case rbops ^? opAllocateEquipment of
-> cr & crEquipment . at oldp .~ Nothing
& crInvEquipped . at invid .~ Nothing
Nothing -> error "tried to toggle equipment whilst not prepared"
-- case cr ^? crInvEquipped . ix invid of
-- Just epos -> cr & crInvEquipped . at invid .~ Nothing
-- & crEquipment . at epos .~ Nothing
-- Nothing -> equipUsingSite invid itm cr
-- | First check if the item is already equiped, then do nothing
equipUsingSiteCheck :: Int -> Item -> Creature -> Creature
equipUsingSiteCheck invid itm cr
| isJust (cr ^? crInvEquipped . ix invid) = cr
| otherwise = equipUsingSite invid itm cr
equipUsingSite :: Int -> Item -> Creature -> Creature
equipUsingSite invid itm cr = cr
& crInvEquipped . at invid ?~ epos
& crEquipment . at epos ?~ invid
& removeOtherEquipment
where
epos = eqSiteToPos cr (_eqSite $ _itUse itm)
removeOtherEquipment = case cr ^? crEquipment . ix epos of
Nothing -> id
Just oid -> (crInvEquipped . at oid .~ Nothing) . removeIfLUse oid
removeIfLUse oid
| _crLeftInvSel cr == Just oid = crLeftInvSel .~ Nothing
| otherwise = id
eqSiteToPos :: Creature -> EquipSite -> EquipPosition
eqSiteToPos cr es = case es of
GoesOnHead -> OnHead
GoesOnChest -> OnChest
GoesOnBack -> OnBack
GoesOnLegs -> OnLegs
GoesOnSpecial -> OnSpecial
GoesOnWrist -> case cr ^? crEquipment . ix OnLeftWrist of
Nothing -> OnLeftWrist
_ -> OnRightWrist
useLeftItem :: Int -> World -> World
useLeftItem cid w