module Dodge.AssignHotkey (assignHotkey) where import Control.Lens import Data.Maybe import Dodge.Data.Equipment.Misc import Dodge.Data.World import NewInt assignHotkey :: NewInt ItmInt -> Hotkey -> LWorld -> LWorld assignHotkey i hk lw = lw & handleoldposition & hotkeys . at hk ?~ i & imHotkeys . at i ?~ hk where handleoldposition = fromMaybe id $ do oldi <- lw ^? hotkeys . ix hk return $ imHotkeys . at oldi .~ Nothing