|
@@ -1,91 +0,0 @@ |
|
|
from cli import * |
|
|
|
|
|
from llm import * |
|
|
|
|
|
from shell_Context import * |
|
|
|
|
|
|
|
|
|
|
|
# Greet the user upon start |
|
|
|
|
|
@llm_by_value |
|
|
|
|
|
def shell_launch( |
|
|
|
|
|
c: shell_Context |
|
|
|
|
|
) -> shell_Context: |
|
|
|
|
|
c.cCLI = cli_greetUser(c.cCLI) |
|
|
|
|
|
c.cCLI.input = "help" |
|
|
|
|
|
c.cCLI = cli_showHelp(c.cCLI) |
|
|
|
|
|
|
|
|
|
|
|
c.output = c.cCLI.outputGreeting + "\n" + c.cCLI.outputHelp |
|
|
|
|
|
return c |
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
# Switch among CLI functions based on input |
|
|
|
|
|
# |
|
|
|
|
|
# Conditions: |
|
|
|
|
|
# 1. User requested to quit the game |
|
|
|
|
|
# 2. User plays the game |
|
|
|
|
|
@llm_by_value |
|
|
|
|
|
def shell_processInput( |
|
|
|
|
|
c: shell_Context |
|
|
|
|
|
) -> shell_Context: |
|
|
|
|
|
# Exit |
|
|
|
|
|
if ( |
|
|
|
|
|
c.input == "e" or |
|
|
|
|
|
c.input == "exit" or |
|
|
|
|
|
c.input == "q" or |
|
|
|
|
|
c.input == "quit" |
|
|
|
|
|
): |
|
|
|
|
|
c.exit = True |
|
|
|
|
|
return c |
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
c.cCLI.input = c.input |
|
|
|
|
|
c.output = "" |
|
|
|
|
|
|
|
|
|
|
|
# Help (aka commands) |
|
|
|
|
|
c.cCLI = cli_showHelp(c.cCLI) |
|
|
|
|
|
if ( |
|
|
|
|
|
c.cCLI.recentField == "outputHelp" |
|
|
|
|
|
): |
|
|
|
|
|
c.output += c.cCLI.outputHelp |
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
c.cCLI = cli_selectItem(c.cCLI) |
|
|
|
|
|
|
|
|
|
|
|
# Game actions. |
|
|
|
|
|
if ( |
|
|
|
|
|
c.cCLI.recentField == "cMemory" |
|
|
|
|
|
): |
|
|
|
|
|
# Prompt second item. |
|
|
|
|
|
cli = cli_shouldPromptSelection(c.cCLI) |
|
|
|
|
|
if ( |
|
|
|
|
|
cli.recentField == "outputPromptSelection" |
|
|
|
|
|
): |
|
|
|
|
|
c.output += cli.outputPromptSelection |
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
# Check matching items. |
|
|
|
|
|
cli = c.cCLI |
|
|
|
|
|
memory = memory_shouldHideMatchingItems(cli.cMemory) |
|
|
|
|
|
cli.recentField = "cMemory" |
|
|
|
|
|
# Report matched items. |
|
|
|
|
|
cli = cli_shouldReportMatchedItems(cli) |
|
|
|
|
|
if ( |
|
|
|
|
|
cli.recentField == "outputMatchedItems" |
|
|
|
|
|
): |
|
|
|
|
|
c.output += cli.outputMatchedItems |
|
|
|
|
|
c.cCLI.cMemory = memory |
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
# Check mismatching items. |
|
|
|
|
|
memory = memory_shouldDeselectMismatchedItems(c.cCLI.cMemory) |
|
|
|
|
|
c.cCLI.recentField = "cMemory" |
|
|
|
|
|
# Report mismatched items. |
|
|
|
|
|
cli = cli_shouldReportMismatchedItems(c.cCLI) |
|
|
|
|
|
if ( |
|
|
|
|
|
cli.recentField == "outputMismatchedItems" |
|
|
|
|
|
): |
|
|
|
|
|
c.output += cli.outputMismatchedItems |
|
|
|
|
|
c.cCLI.cMemory = memory |
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
return c |
|
|
|
|
|
#} |
|
|
|