Михаил Капелько 7 ay önce
ebeveyn
işleme
e3af3b8ab9
4 değiştirilmiş dosya ile 115 ekleme ve 6 silme
  1. +17
    -6
      v4/main.py
  2. +36
    -0
      v4/shell.py
  3. +8
    -0
      v4/shell_Context.py
  4. +54
    -0
      v4/shell_test.py

+ 17
- 6
v4/main.py Dosyayı Görüntüle

@@ -1,5 +1,6 @@
from memory_test import *
from memoryCLI import *
from shell import *
from shell_test import *
import sys

print(memory_test_generateConstPlayfield())
@@ -11,10 +12,20 @@ print(memory_test_shouldDeselectMismatchedItems_itemTwice())
print(memory_test_shouldDetectVictory())
print(memory_test_shouldHideMatchingItems())

c = memoryCLI_createContext()
c = memoryCLI_greetUser(c)
print(c.output)
print(shell_test_exit_e())
print(shell_test_exit_exit())
print(shell_test_exit_q())
print(shell_test_exit_quit())

c = shell_createContext()
c = shell_start(c)
if c.recentField == "output":
print(c.output)

for line in sys.stdin:
ln = line.rstrip()
print(f"you entered: '{ln}'")
c.input = line.rstrip()
c = shell_processInput(c)
if c.recentField == "output":
print(c.output)
elif c.recentField == "exit":
break

+ 36
- 0
v4/shell.py Dosyayı Görüntüle

@@ -0,0 +1,36 @@
from shell_Context import *
from llm import *

# Greet the user upon start
@llm_by_value
def shell_start(
c: shell_Context
) -> shell_Context:
c.output = "Shell.StartText"
c.recentField = "output"
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:
if (
c.input == "e" or
c.input == "exit" or
c.input == "q" or
c.input == "quit"
):
c.exit = True
c.recentField = "exit"
return c

c.output = "TODO Call all CLI functions, let them process game input"
c.recentField = "output"
return c
#}

+ 8
- 0
v4/shell_Context.py Dosyayı Görüntüle

@@ -0,0 +1,8 @@
class shell_Context:
def __init__(self):
self.exit = False
self.input = ""
self.output = ""

def shell_createContext():
return shell_Context()

+ 54
- 0
v4/shell_test.py Dosyayı Görüntüle

@@ -0,0 +1,54 @@
from shell import *
from shell_Context import *

def shell_test_exit_e(
) -> str:
c = shell_createContext()
c.input = "e"
c = shell_processInput(c)
if (
c.recentField == "exit"
):
return "OK: shell_exit_e"
#}
return "ERR: shell_exit_e"
#}

def shell_test_exit_exit(
) -> str:
c = shell_createContext()
c.input = "exit"
c = shell_processInput(c)
if (
c.recentField == "exit"
):
return "OK: shell_exit_exit"
#}
return "ERR: shell_exit_exit"
#}

def shell_test_exit_q(
) -> str:
c = shell_createContext()
c.input = "q"
c = shell_processInput(c)
if (
c.recentField == "exit"
):
return "OK: shell_exit_q"
#}
return "ERR: shell_exit_q"
#}

def shell_test_exit_quit(
) -> str:
c = shell_createContext()
c.input = "quit"
c = shell_processInput(c)
if (
c.recentField == "exit"
):
return "OK: shell_exit_quit"
#}
return "ERR: shell_exit_quit"
#}

Yükleniyor…
İptal
Kaydet