Remove left click/hotkey item data types

This commit is contained in:
2024-12-19 21:55:18 +00:00
parent 910c683eac
commit 3da9490dd4
34 changed files with 708 additions and 883 deletions
+7 -15
View File
@@ -14,14 +14,11 @@ import Control.Monad
assignNewHotkey :: Int -> LWorld -> LWorld
assignNewHotkey invid w = assignHotkey invid (newHotkey w) w
--newHotkey :: Creature -> Hotkey
--newHotkey cr = fromMaybe maxBound $ find (not . (`M.member` usedhks)) [minBound .. maxBound]
-- where
-- usedhks = cr ^?! crHotkeys
newHotkey :: LWorld -> Hotkey
newHotkey lw = fromMaybe maxBound $ find (not . (`M.member` usedhks)) [minBound .. maxBound]
where
usedhks = lw ^. hotkeys
newHotkey lw = fromMaybe maxBound $
find
(not . (`M.member` (lw ^. hotkeys)))
[minBound .. maxBound]
-- this will not remove the hotkey from its old slot, assumes there is a hotkey
-- to swap with instead
@@ -29,16 +26,11 @@ newHotkey lw = fromMaybe maxBound $ find (not . (`M.member` usedhks)) [minBound
assignHotkey :: Int -> Hotkey -> LWorld -> LWorld
assignHotkey invid hk lw = fromMaybe lw $ do
--guard (invid `IM.member` (cr ^. crInvEquipped))
guard $ isJust $ lw ^? creatures . ix 0 . crInv . ix invid . itLocation . ilEquipPosition . _Just
_ <- lw ^? creatures . ix 0 . crInv . ix invid . itUse . leftUse
guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUse . useCondition
== Just UseableAnytime
-- _ <- lw ^? creatures . ix 0 . crInv . ix invid . itUse . leftUse
return $ (setHotkey invid hk . moveOldHotkey invid hk) lw
--moveOldHotkey :: Int -> Hotkey -> Creature -> Creature
--moveOldHotkey invid hk w = fromMaybe w $ do
-- oldhk <- w ^? crInvHotkeys . ix invid
-- oldid <- w ^? crHotkeys . ix hk
-- return $ w & setHotkey oldid oldhk
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
moveOldHotkey invid hk w = fromMaybe w $ do
oldhk <- w ^? imHotkeys . ix invid