You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

9 years ago
  1. {-# OPTIONS -Wall #-}
  2. module PowerPhrases where
  3. import Data.Maybe(mapMaybe)
  4. import Datatypes.Game (Command(..))
  5. listToCommand :: String -> [Command]
  6. listToCommand str = mapMaybe charToCommand str
  7. charToCommand :: Char -> Maybe Command
  8. charToCommand 'p' = Just MoveW
  9. charToCommand '\'' = Just MoveW
  10. charToCommand '!' = Just MoveW
  11. charToCommand '.' = Just MoveW
  12. charToCommand '0' = Just MoveW
  13. charToCommand '3' = Just MoveW
  14. charToCommand 'b' = Just MoveE
  15. charToCommand 'c' = Just MoveE
  16. charToCommand 'e' = Just MoveE
  17. charToCommand 'f' = Just MoveE
  18. charToCommand 'y' = Just MoveE
  19. charToCommand '2' = Just MoveE
  20. charToCommand 'a' = Just MoveSW
  21. charToCommand 'g' = Just MoveSW
  22. charToCommand 'h' = Just MoveSW
  23. charToCommand 'i' = Just MoveSW
  24. charToCommand 'j' = Just MoveSW
  25. charToCommand '4' = Just MoveSW
  26. charToCommand 'l' = Just MoveSE
  27. charToCommand 'm' = Just MoveSE
  28. charToCommand 'n' = Just MoveSE
  29. charToCommand 'o' = Just MoveSE
  30. charToCommand ' ' = Just MoveSE
  31. charToCommand '5' = Just MoveSE
  32. charToCommand 'd' = Just RotateClockwise
  33. charToCommand 'q' = Just RotateClockwise
  34. charToCommand 'r' = Just RotateClockwise
  35. charToCommand 'v' = Just RotateClockwise
  36. charToCommand 'z' = Just RotateClockwise
  37. charToCommand '1' = Just RotateClockwise
  38. charToCommand 'k' = Just RotateCounterclockwise
  39. charToCommand 's' = Just RotateCounterclockwise
  40. charToCommand 't' = Just RotateCounterclockwise
  41. charToCommand 'u' = Just RotateCounterclockwise
  42. charToCommand 'w' = Just RotateCounterclockwise
  43. charToCommand 'x' = Just RotateCounterclockwise
  44. charToCommand _ = Nothing