From a9599e6b3a81ce889c1bb517d5850f12e934d449 Mon Sep 17 00:00:00 2001 From: Github Action Date: Fri, 29 Nov 2024 09:47:04 -0500 Subject: [PATCH] pick adventurer name --- app/app.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index d2fc7c3..c330680 100644 --- a/app/app.py +++ b/app/app.py @@ -6,6 +6,7 @@ import json import logging import time +import random from . import adventure_game from . import adventure_cache @@ -22,6 +23,9 @@ def home(): games = [] +main_adv = adventure_game.AdventureGame("main") +adventure_cache.cache.set("main", main_adv) + @app.route('/api/adventure', methods=['POST']) def adventure(): body = request.json @@ -38,7 +42,8 @@ def adventure(): adventure_cache.cache.set(user, adventure) print("Adventure " + adventure.id + " " + body.get('command', '')) - response = adventure.command(body.get('command', '')) + # response = adventure.command(body.get('command', '')) + response = main_adv.command(body.get('command', '')) # Update cache; adventure has changed adventure_cache.cache.set(user, adventure) @@ -48,6 +53,21 @@ def adventure(): return { "response": response }, 200 +@app.route('/api/adventurer', methods=['GET']) +def adventurer_name(): + givens = ['Godrick', 'Gawain', 'Percival', 'Lancelot', 'Tristan', 'Mordred', 'Bedivere', 'Galahad', 'Merlin', 'Arthur', + 'Elaine', 'Isolde', 'Enid', 'Lynette', 'Guinevere', 'Morgana', 'Nimue', 'Viviane', 'Ragnell'] + familial = ['son of', 'daughter of', 'house', 'clan', 'tribe', 'advisor to', 'squire to', 'knight of', 'page to', 'bard to'] + surnames = ['the Brave', 'the Wise', 'the Fool', 'the Terrible', 'the Maladorous', 'the Unwashed', + 'the Chaste', 'the Pure', 'the Unyielding', 'the Unbreakable', 'the Unbowed', 'the Unbent', + 'the Pious', 'the Faithful', 'the Valiant', 'the True', + 'the Unworthy', 'the Unfortunate', 'the Mirthsome'] + + return { + "name": random.choice(givens) + " " + random.choice(surnames) + " (" + random.choice(familial) + " " + random.choice(givens) + ")" + } + + @app.route('/api/cache', methods=['GET']) def cache_status(): return adventure_cache.cache.status(), 200