Simplify right button options
This commit is contained in:
@@ -5,6 +5,7 @@ module Dodge.Creature.Impulse.UseItem (
|
||||
useItemHotkey,
|
||||
) where
|
||||
|
||||
import Dodge.Inventory.RBList
|
||||
import Dodge.Hotkey
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
@@ -51,7 +52,7 @@ itemEffect cr it w = case it ^. itUse of
|
||||
doequipmentchange =
|
||||
setuhamdown $
|
||||
hammerTest
|
||||
( toggleEquipmentAt (_rbOptions w) itRef cr
|
||||
( toggleEquipmentAt itRef cr
|
||||
)
|
||||
|
||||
tryReload :: Creature -> Item -> Input -> (World -> World) -> World -> World
|
||||
@@ -69,27 +70,27 @@ itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic)
|
||||
where
|
||||
ic = _heldConsumption (_itUse it)
|
||||
|
||||
toggleEquipmentAt :: RightButtonOptions -> Int -> Creature -> World -> World
|
||||
toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
|
||||
Just DoNotMoveEquipment -> w
|
||||
Just PutOnEquipment{_allocNewPos = newp} ->
|
||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||
DoNotMoveEquipment -> w
|
||||
PutOnEquipment{_allocNewPos = newp} ->
|
||||
w
|
||||
& crpoint . crEquipment . at newp ?~ invid
|
||||
& crpoint . crInvEquipped . at invid ?~ newp
|
||||
& onequip itm cr
|
||||
& crpoint %~ assignNewHotkey invid
|
||||
Just MoveEquipment{_allocNewPos = newp, _allocOldPos = oldp} ->
|
||||
MoveEquipment{_allocNewPos = newp, _allocOldPos = oldp} ->
|
||||
w
|
||||
& crpoint . crEquipment . at newp ?~ invid
|
||||
& crpoint . crEquipment . at oldp .~ Nothing
|
||||
& crpoint . crInvEquipped . at invid ?~ newp
|
||||
Just SwapEquipment{_allocNewPos = newp, _allocOldPos = oldp, _allocSwapID = sid} ->
|
||||
SwapEquipment{_allocNewPos = newp, _allocOldPos = oldp, _allocSwapID = sid} ->
|
||||
w
|
||||
& crpoint . crEquipment . at newp ?~ invid
|
||||
& crpoint . crEquipment . at oldp ?~ sid
|
||||
& crpoint . crInvEquipped . at invid ?~ newp
|
||||
& crpoint . crInvEquipped . at sid ?~ oldp
|
||||
Just ReplaceEquipment{_allocNewPos = newp, _allocRemoveID = rid} ->
|
||||
ReplaceEquipment{_allocNewPos = newp, _allocRemoveID = rid} ->
|
||||
w
|
||||
& crpoint . crEquipment . at newp ?~ invid
|
||||
& crpoint . crInvEquipped . at invid ?~ newp
|
||||
@@ -98,13 +99,12 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
|
||||
& onequip itm cr
|
||||
& crpoint %~ removeHotkey rid
|
||||
& crpoint %~ assignNewHotkey invid
|
||||
Just RemoveEquipment{_allocOldPos = oldp} ->
|
||||
RemoveEquipment{_allocOldPos = oldp} ->
|
||||
w
|
||||
& crpoint . crEquipment . at oldp .~ Nothing
|
||||
& crpoint . crInvEquipped . at invid .~ Nothing
|
||||
& onremove itm cr
|
||||
& crpoint %~ removeHotkey invid
|
||||
Nothing -> error "tried to toggle equipment when not prepared"
|
||||
where
|
||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
itmat i = _crInv cr IM.! i
|
||||
|
||||
Reference in New Issue
Block a user