2024-07-01 00:56:11 +00:00
|
|
|
from flask import request
|
2024-07-01 10:26:54 +00:00
|
|
|
from flask_restx import Resource, Namespace, reqparse
|
2024-07-01 00:56:11 +00:00
|
|
|
|
|
|
|
from app.functions.roll_mental_attack import roll_mental_attack
|
|
|
|
|
|
|
|
namespace = Namespace('gameplay', description='Gamma World Rules')
|
|
|
|
|
2024-07-01 10:26:54 +00:00
|
|
|
# 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')
|
|
|
|
|
2024-07-01 00:56:11 +00:00
|
|
|
|
|
|
|
@namespace.route('/attack/mental') # resolves to: /gameplay/attack/mental
|
|
|
|
class MentalAttack(Resource):
|
2024-07-01 10:26:54 +00:00
|
|
|
@namespace.expect(parser)
|
2024-07-01 00:56:11 +00:00
|
|
|
def get(self):
|
|
|
|
ams = request.args.get('ams', type=int)
|
|
|
|
dms = request.args.get('dms', type=int)
|
|
|
|
modifier = request.args.get('modifier', type=int)
|
2024-07-01 10:26:54 +00:00
|
|
|
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
|
|
|
|
|
2024-07-01 00:56:11 +00:00
|
|
|
return roll_mental_attack(ams, dms, modifier), 200
|