Implemented choices successfully
This commit is contained in:
+5
-2
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user