minor refactoring of models/schemas

This commit is contained in:
Greg Gauthier 2024-06-24 09:35:29 +01:00
parent 932f2bdda6
commit ccfe1fe19f
2 changed files with 21 additions and 20 deletions

View File

@ -4,17 +4,20 @@ from flask_restx import fields
chartype_field = fields.String(
required=True,
default="human",
description='Character type. Allowed values: "human", "humanoid", "mutant", "cyborg"')
description='Character type. Allowed values: "human", "humanoid", "mutant", "cyborg"'
)
# Mutations Model
mutation_model = {
'conscore': fields.Integer(
conscore_field = fields.Integer(
required=True,
default=3,
default=10,
min=3,
max=18,
description='The characters constitution score'
),
)
# Mutations Model
mutation_model = {
'conscore': conscore_field,
'intscore': fields.Integer(
required=True,
default=3,
@ -36,13 +39,13 @@ ability_model = {
'ability': fields.String(
required=False,
default="all",
description='The ability to roll. Not required. Defaults "generic"'),
description='The ability to roll. Not required. Defaults to "all".'),
}
# Hp model
hp_model = {
'chartype': chartype_field,
'conscore': fields.Integer(required=True, description='Conscore')
'conscore': conscore_field
}
ma_model = {

View File

@ -6,28 +6,26 @@ chartype_field = fields.String(
description='The characters type of being'
)
conscore_field = fields.Integer(
required=True,
default=10,
validate=validate.Range(min=3, max=18),
description='The constitution score of the character'
)
class MutationSchema(Schema):
conscore = fields.Integer(
required=True,
validate=validate.Range(min=3, max=18),
description='The characters constitution score'
)
conscore = conscore_field
intscore = fields.Integer(
required=True,
validate=validate.Range(min=3, max=21),
validate=validate.Range(min=3, max=18),
description='The characters intelligence score'
)
class HPSchema(Schema):
chartype = chartype_field
conscore = fields.Integer(
required=True,
default=10,
validate=validate.Range(min=3, max=24),
description='The constitution score of the character'
)
conscore = conscore_field
class DiceSchema(Schema):