Research portable Memory game | Исследовать портируемую игру Память
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

134 строки
3.0KB

  1. from memory_Context import *
  2. from llm import *
  3. # Greet the user
  4. @llm_by_value
  5. def cli_greetUser(
  6. c: memory_Context
  7. ) -> memory_Context:
  8. if (
  9. c.recentField == "didLaunch" and
  10. c.didLaunch == True
  11. ):
  12. c.outputGreeting = "OGS Memory Command Line Interface"
  13. c.recentField = "outputGreeting"
  14. return c
  15. #}
  16. c.recentField = "none"
  17. return c
  18. #}
  19. ## Select item
  20. ##
  21. ## Conditions:
  22. ## 1. Id is digit, in bounds and not hidden
  23. #@llm_by_value
  24. #def cli_selectItem(
  25. # c: cli_Context
  26. #) -> cli_Context:
  27. # if (
  28. # c.input.isdigit()
  29. # ):
  30. # # User ids start with 1 while memory module has ids starting with 0
  31. # # Convert cli item id to memory item id
  32. # c.cMemory.selectedId = int(c.input) - 1
  33. # c.cMemory = memory_selectItem(c.cMemory)
  34. # c.recentField = "cMemory"
  35. # return c
  36. # #}
  37. # c.recentField = "none"
  38. # return c
  39. ##}
  40. #
  41. ## Ask user to select another item to have a pair of selected items
  42. #@llm_by_value
  43. #def cli_shouldPromptSelection(
  44. # c: cli_Context
  45. #) -> cli_Context:
  46. # if (
  47. # c.recentField == "cMemory" and
  48. # c.cMemory.recentField == "selectedItems" and
  49. # len(c.cMemory.selectedItems) == 1
  50. # ):
  51. # c.outputPromptSelection = "Select the second item now:"
  52. # c.recentField = "outputPromptSelection"
  53. # return c
  54. # #}
  55. # c.recentField = "none"
  56. # return c
  57. ##}
  58. #
  59. ## Report matched items
  60. #@llm_by_value
  61. #def cli_shouldReportMatchedItems(
  62. # c: cli_Context
  63. #) -> cli_Context:
  64. # if (
  65. # c.recentField == "cMemory" and
  66. # c.cMemory.recentField == "hiddenItems"
  67. # ):
  68. # c.outputMatchedItems = "Items matched! Go on:"
  69. # c.recentField = "outputMatchedItems"
  70. # return c
  71. # #}
  72. # c.recentField = "none"
  73. # return c
  74. ##}
  75. #
  76. ## Report mismatched items
  77. #@llm_by_value
  78. #def cli_shouldReportMismatchedItems(
  79. # c: cli_Context
  80. #) -> cli_Context:
  81. # if (
  82. # c.recentField == "cMemory" and
  83. # c.cMemory.recentField == "mismatchedItems"
  84. # ):
  85. # c.outputMatchedItems = "Wrong! Try again:"
  86. # c.recentField = "outputMismatchedItems"
  87. # return c
  88. # #}
  89. # c.recentField = "none"
  90. # return c
  91. ##}
  92. #
  93. ## Report selection of invalid item ids
  94. ##
  95. ## Conditions:
  96. ## 1. Index out of bounds: less than minimum
  97. ## 2. Index out of bounds: greater than maximum
  98. ## 3. Item is already hidden
  99. ##@llm_by_value
  100. ##def cli_shouldReportInvalidItemSelection(
  101. ## c: cli_Context
  102. ##) -> cli_Context:
  103. ## if (
  104. ## c.recentField == "cMemory" and
  105. ## c.cMemory.recentField == "selectedItems" and
  106. ## len(c.cMemory.selectedItems) == 1
  107. ## ):
  108. ## c.outputPromptSelection = "Select the second item now:"
  109. ## c.recentField = "outputPromptSelection"
  110. ## return c
  111. ## #}
  112. ## c.recentField = "none"
  113. ## return c
  114. ###}
  115. #
  116. ## Show help (aka commands)
  117. #@llm_by_value
  118. #def cli_showHelp(
  119. # c: cli_Context
  120. #) -> cli_Context:
  121. # if (
  122. # c.input == "h" or
  123. # c.input == "help"
  124. # ):
  125. # c.outputHelp = "Commands:\n\te, exit, q, quit\n\t\tExit\n\th, help\n\t\tList commands\n\t1, 2, 3, ...\n\t\tSelect item\nEnter your choice:"
  126. # c.recentField = "outputHelp"
  127. # return c
  128. # #}
  129. # c.recentField = "none"
  130. # return c
  131. ##}