20 lines
651 B
Python
20 lines
651 B
Python
from flask import request
|
|
from flask_restx import Resource, Namespace
|
|
|
|
from app.tables.monsters import Monsters
|
|
|
|
namespace = Namespace('rules', description='Gamma World Rules')
|
|
|
|
|
|
@namespace.route('/creature') # resolves to: /gameplay/encounter
|
|
class RollEncounter(Resource):
|
|
@namespace.doc(params={'creature': 'The terrain type for the encounter'})
|
|
def get(self):
|
|
creature = request.args.get('creature', default=None, type=str)
|
|
|
|
if creature is None:
|
|
return {'error': 'Provide the name of a Gamma World creature to search for'}, 400
|
|
|
|
monsters = Monsters()
|
|
return monsters.get_monster(creature), 200
|