gammatools/app/routes/ability_check.py

21 lines
768 B
Python
Raw Normal View History

from flask import request
from flask_restx import Resource, Namespace
from app.functions.roll_ability_check import roll_ability_check
namespace = Namespace('gameplay', description='Gamma World Rules')
@namespace.route('/ability/check') # resolves to: /gameplay/ability/check
class AbilityCheck(Resource):
@namespace.doc(params={'score': 'The ability score', 'multiplier': 'Score multiplier for the attempt.'})
def get(self):
score = request.args.get('score', type=int)
multiplier = request.args.get('multiplier', type=float)
if not score or not multiplier:
return {'error': 'Both score and multiplier parameters are required.'}, 400
outcome = roll_ability_check(score, multiplier)
return outcome, 200