|
@@ -12,41 +12,77 @@ def cli_greetUser( |
|
|
return c |
|
|
return c |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
# Ask user to select another item to have a pair of selected items |
|
|
|
|
|
|
|
|
# Select item |
|
|
|
|
|
# |
|
|
|
|
|
# Conditions: |
|
|
|
|
|
# 1. Id is digit, in bounds and not hidden |
|
|
@llm_by_value |
|
|
@llm_by_value |
|
|
def cli_shouldPromptSelection( |
|
|
|
|
|
|
|
|
def cli_selectItem( |
|
|
c: cli_Context |
|
|
c: cli_Context |
|
|
) -> cli_Context: |
|
|
) -> cli_Context: |
|
|
if ( |
|
|
|
|
|
c.recentField == "cMemory" and |
|
|
|
|
|
c.cMemory.recentField == "selectedItems" and |
|
|
|
|
|
len(c.cMemory.selectedItems) == 1 |
|
|
|
|
|
|
|
|
if not ( |
|
|
|
|
|
c.input.isdigit() |
|
|
): |
|
|
): |
|
|
c.outputPromptSelection = "Select the second item now:" |
|
|
|
|
|
c.recentField = "outputPromptSelection" |
|
|
|
|
|
|
|
|
c.recentField = "none" |
|
|
|
|
|
return c |
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
int(c.input) >= 1 and |
|
|
|
|
|
int(c.input) <= c.cMemory.playfieldSize * 2 and |
|
|
|
|
|
int(c.input) not in c.cMemory.hiddenItems |
|
|
|
|
|
): |
|
|
|
|
|
# User ids start with 1 while memory module has ids starting with 0 |
|
|
|
|
|
# Convert cli item id to memory item id |
|
|
|
|
|
c.cMemory.selectedId = int(c.input) - 1 |
|
|
|
|
|
c.cMemory = memory_selectItem(c.cMemory) |
|
|
|
|
|
c.recentField = "cMemory" |
|
|
return c |
|
|
return c |
|
|
#} |
|
|
#} |
|
|
c.recentField = "none" |
|
|
c.recentField = "none" |
|
|
return c |
|
|
return c |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
# Select item |
|
|
|
|
|
|
|
|
# Ask user to select another item to have a pair of selected items |
|
|
@llm_by_value |
|
|
@llm_by_value |
|
|
def cli_selectItem( |
|
|
|
|
|
|
|
|
def cli_shouldPromptSelection( |
|
|
c: cli_Context |
|
|
c: cli_Context |
|
|
) -> cli_Context: |
|
|
) -> cli_Context: |
|
|
if ( |
|
|
if ( |
|
|
c.input.isdigit() |
|
|
|
|
|
|
|
|
c.recentField == "cMemory" and |
|
|
|
|
|
c.cMemory.recentField == "selectedItems" and |
|
|
|
|
|
len(c.cMemory.selectedItems) == 1 |
|
|
): |
|
|
): |
|
|
id = int(c.input) |
|
|
|
|
|
c.cMemory = memory_selectItem(c.cMemory) |
|
|
|
|
|
c.recentField = "cMemory" |
|
|
|
|
|
|
|
|
c.outputPromptSelection = "Select the second item now:" |
|
|
|
|
|
c.recentField = "outputPromptSelection" |
|
|
return c |
|
|
return c |
|
|
#} |
|
|
#} |
|
|
c.recentField = "none" |
|
|
c.recentField = "none" |
|
|
return c |
|
|
return c |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
# Report selection of invalid item ids |
|
|
|
|
|
# |
|
|
|
|
|
# Conditions: |
|
|
|
|
|
# 1. Index out of bounds: less than minimum |
|
|
|
|
|
# 2. Index out of bounds: greater than maximum |
|
|
|
|
|
# 3. Item is already hidden |
|
|
|
|
|
#@llm_by_value |
|
|
|
|
|
#def cli_shouldReportInvalidItemSelection( |
|
|
|
|
|
# c: cli_Context |
|
|
|
|
|
#) -> cli_Context: |
|
|
|
|
|
# if ( |
|
|
|
|
|
# c.recentField == "cMemory" and |
|
|
|
|
|
# c.cMemory.recentField == "selectedItems" and |
|
|
|
|
|
# len(c.cMemory.selectedItems) == 1 |
|
|
|
|
|
# ): |
|
|
|
|
|
# c.outputPromptSelection = "Select the second item now:" |
|
|
|
|
|
# c.recentField = "outputPromptSelection" |
|
|
|
|
|
# return c |
|
|
|
|
|
# #} |
|
|
|
|
|
# c.recentField = "none" |
|
|
|
|
|
# return c |
|
|
|
|
|
##} |
|
|
|
|
|
|
|
|
# Show help (aka commands) |
|
|
# Show help (aka commands) |
|
|
@llm_by_value |
|
|
@llm_by_value |
|
|
def cli_showHelp( |
|
|
def cli_showHelp( |
|
|