Research portable Memory game | Исследовать портируемую игру Память
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

6 miesięcy temu
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. from cli import *
  2. from llm import *
  3. from shell_Context import *
  4. # Greet the user upon start
  5. @llm_by_value
  6. def shell_launch(
  7. c: shell_Context
  8. ) -> shell_Context:
  9. c.cCLI = cli_greetUser(c.cCLI)
  10. c.cCLI.input = "help"
  11. c.cCLI = cli_showHelp(c.cCLI)
  12. c.output = c.cCLI.outputGreeting + "\n" + c.cCLI.outputHelp
  13. return c
  14. #}
  15. # Switch among CLI functions based on input
  16. #
  17. # Conditions:
  18. # 1. User requested to quit the game
  19. # 2. User plays the game
  20. @llm_by_value
  21. def shell_processInput(
  22. c: shell_Context
  23. ) -> shell_Context:
  24. # Exit
  25. if (
  26. c.input == "e" or
  27. c.input == "exit" or
  28. c.input == "q" or
  29. c.input == "quit"
  30. ):
  31. c.exit = True
  32. return c
  33. #}
  34. c.cCLI.input = c.input
  35. c.output = ""
  36. # Help (aka commands)
  37. c.cCLI = cli_showHelp(c.cCLI)
  38. if (
  39. c.cCLI.recentField == "outputHelp"
  40. ):
  41. c.output += c.cCLI.outputHelp
  42. #}
  43. c.cCLI = cli_selectItem(c.cCLI)
  44. # Game actions.
  45. if (
  46. c.cCLI.recentField == "cMemory"
  47. ):
  48. # Prompt second item.
  49. cli = cli_shouldPromptSelection(c.cCLI)
  50. if (
  51. cli.recentField == "outputPromptSelection"
  52. ):
  53. c.output += cli.outputPromptSelection
  54. #}
  55. # Check matching items.
  56. cli = c.cCLI
  57. memory = memory_shouldHideMatchingItems(cli.cMemory)
  58. cli.recentField = "cMemory"
  59. # Report matched items.
  60. cli = cli_shouldReportMatchedItems(cli)
  61. if (
  62. cli.recentField == "outputMatchedItems"
  63. ):
  64. c.output += cli.outputMatchedItems
  65. c.cCLI.cMemory = memory
  66. #}
  67. # Check mismatching items.
  68. memory = memory_shouldDeselectMismatchedItems(c.cCLI.cMemory)
  69. c.cCLI.recentField = "cMemory"
  70. # Report mismatched items.
  71. cli = cli_shouldReportMismatchedItems(c.cCLI)
  72. if (
  73. cli.recentField == "outputMismatchedItems"
  74. ):
  75. c.output += cli.outputMismatchedItems
  76. c.cCLI.cMemory = memory
  77. #}
  78. #}
  79. return c
  80. #}