Skip to content

Commit

Permalink
pick adventurer name
Browse files Browse the repository at this point in the history
  • Loading branch information
Github Action authored and Github Action committed Nov 29, 2024
1 parent 51fdeee commit a9599e6
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import logging
import time
import random

from . import adventure_game
from . import adventure_cache
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit a9599e6

Please sign in to comment.