gammatools/app/routes/table_views.py

20 lines
771 B
Python

from flask_restx import Resource, Namespace
from app.tables.mentattack import MentalAttackMatrix
from app.tables.physattack import AttackerWeaponClassMatrix, AttackerHitDiceMatrix
namespace = Namespace('rules', description='Gamma World Rules')
@namespace.route('/tables') # resolves to /rules/tables
class DumpMatrices(Resource):
def get(self):
awc_table = AttackerWeaponClassMatrix().get_matrix().to_json(orient='index')
ahd_table = AttackerHitDiceMatrix().get_matrix().to_json(orient='index')
mat_table = MentalAttackMatrix().get_matrix().to_json(orient='index')
return {
"Weapon Attack Table": awc_table,
"Non-Weapon Attack Table": ahd_table,
"Mental Attack Table": mat_table
}, 200