AI refactor
This commit is contained in:
@@ -34,10 +34,7 @@ see 'handlePressedKeyInGame'.
|
||||
handleKeyboardEvent :: KeyboardEventData -> World -> Maybe World
|
||||
handleKeyboardEvent kev w = case keyboardEventKeyMotion kev of
|
||||
Released -> Just $ w & keys %~ S.delete kcode
|
||||
Pressed -> handlePressedKey
|
||||
(keyboardEventRepeat kev)
|
||||
kcode
|
||||
(w & keys %~ S.insert kcode)
|
||||
Pressed -> handlePressedKey (keyboardEventRepeat kev) kcode (w & keys %~ S.insert kcode)
|
||||
where
|
||||
kcode = (keysymScancode . keyboardEventKeysym) kev
|
||||
|
||||
@@ -57,12 +54,11 @@ handlePressedKeyInGame scode w
|
||||
handlePressedKeyInGame _ w = Just w
|
||||
|
||||
handlePressedKey :: Bool -> Scancode -> World -> Maybe World
|
||||
handlePressedKey True _ w = Just w
|
||||
handlePressedKey True _ w = Just w
|
||||
handlePressedKey _ scode w
|
||||
| null (_menuLayers w)
|
||||
= handlePressedKeyInGame scode w
|
||||
| otherwise = handlePressedKeyInMenu (head $ _menuLayers w) scode w
|
||||
handlePressedKey _ _ w = Just w
|
||||
| null (_menuLayers w) = handlePressedKeyInGame scode w
|
||||
| otherwise = handlePressedKeyInMenu (head $ _menuLayers w) scode w
|
||||
handlePressedKey _ _ w = Just w
|
||||
|
||||
debugKey :: Scancode -> World -> Maybe World
|
||||
debugKey scancode w
|
||||
@@ -78,7 +74,7 @@ spaceAction w = if _carteDisplay w
|
||||
w & carteCenter .~ theLoc
|
||||
else
|
||||
case listToMaybe $ _closeActiveObjects w of
|
||||
Just (Left flit) -> pickUpItem flit w
|
||||
Just (Left flit) -> pickUpItem 0 flit w
|
||||
Just (Right but) -> updateTopCloseObject (_btID but) $ _btEvent but but w
|
||||
Nothing -> w
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user