Implemented choices successfully

This commit is contained in:
2026-05-10 23:19:42 +01:00
parent 7e5874ffbb
commit fbd315ed7b
5 changed files with 85 additions and 79 deletions
+5 -2
View File
@@ -1,4 +1,5 @@
import requests
import os
# Loop and get new api
def main():
@@ -6,14 +7,17 @@ def main():
while True:
try:
response = api_get()
print(response)
match response["action_type"]:
case "output":
character = get_character(response["character"])
output(character, response["content"])
case "choice":
user_choice = choice(response["choices"])
continue
case "end":
exit()
print("Exitting successfully")
os._exit(0)
except:
print("Server not up or cannot be reached")
input() # Enter to go to next loop (testing)
@@ -44,7 +48,6 @@ def get_character(character):
def api_get():
api_url = "http://localhost:20264/happening/"
response = requests.get(api_url).json()
print(response)
return response
main()