31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
from flask import request
|
|
from flask_restx import Resource, Namespace, reqparse
|
|
|
|
from app.functions.roll_mental_attack import roll_mental_attack
|
|
|
|
namespace = Namespace('gameplay', description='Gamma World Rules')
|
|
|
|
# doc(params={'ams': 'Attacker Mental Strength',
|
|
# 'dms': 'Defender Mental Strength',
|
|
# 'modifier': 'Roll Modifier'})
|
|
|
|
parser = reqparse.RequestParser()
|
|
parser.add_argument('ams', type=int, required=True, help='Attacker Mental Strength (1 - 18)')
|
|
parser.add_argument('dms', type=int, required=True, help='Defender Mental Strength (1 - 18)')
|
|
parser.add_argument('modifier', type=int, required=True, help='Roll Modifier')
|
|
|
|
|
|
@namespace.route('/attack/mental') # resolves to: /gameplay/attack/mental
|
|
class MentalAttack(Resource):
|
|
@namespace.expect(parser)
|
|
def get(self):
|
|
ams = request.args.get('ams', type=int)
|
|
dms = request.args.get('dms', type=int)
|
|
modifier = request.args.get('modifier', type=int)
|
|
if ams < 1 or ams > 18:
|
|
return {'message': 'Attacker Mental Strength must be between 1 and 18'}, 400
|
|
if dms < 1 or dms > 18:
|
|
return {'message': 'Defender Mental Strength must be between 1 and 18'}, 400
|
|
|
|
return roll_mental_attack(ams, dms, modifier), 200
|