Commit before making hotkeys attach to item ids, not inv ids
This commit is contained in:
+16
-13
@@ -1,31 +1,34 @@
|
||||
module Dodge.Hotkey (
|
||||
assignHotkey,
|
||||
assignNewHotkey,
|
||||
-- assignNewHotkey,
|
||||
removeHotkey,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Data.List
|
||||
import qualified Data.Map.Strict as M
|
||||
--import Data.List
|
||||
--import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
import Control.Monad
|
||||
--import Control.Monad
|
||||
|
||||
assignNewHotkey :: Int -> LWorld -> LWorld
|
||||
assignNewHotkey invid w = assignHotkey invid (newHotkey w) w
|
||||
--assignNewHotkey :: Int -> LWorld -> LWorld
|
||||
--assignNewHotkey invid w = assignHotkey invid (newHotkey w) w
|
||||
--
|
||||
--newHotkey :: LWorld -> Hotkey
|
||||
--newHotkey lw = fromMaybe maxBound $
|
||||
-- find
|
||||
-- (not . (`M.member` (lw ^. hotkeys)))
|
||||
-- [minBound .. maxBound]
|
||||
|
||||
newHotkey :: LWorld -> Hotkey
|
||||
newHotkey lw = fromMaybe maxBound $
|
||||
find
|
||||
(not . (`M.member` (lw ^. hotkeys)))
|
||||
[minBound .. maxBound]
|
||||
-- it is not obvious to me whether hotkeys should belong to LWorld, CWorld or
|
||||
-- World
|
||||
|
||||
-- this will not remove the hotkey from its old slot, assumes there is a hotkey
|
||||
-- to swap with instead
|
||||
assignHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
||||
assignHotkey invid hk lw = fromMaybe lw $ do
|
||||
guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUseCondition
|
||||
== Just UseableAnytime
|
||||
-- guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUseCondition
|
||||
-- == Just UseableAnytime
|
||||
return $ (setHotkey invid hk . moveOldHotkey invid hk) lw
|
||||
|
||||
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
||||
|
||||
Reference in New Issue
Block a user