add base animal characteristics to mutant chartype

This commit is contained in:
Greg Gauthier 2024-06-24 00:47:38 +01:00
parent 42302862bf
commit 63aa245cf3
3 changed files with 34 additions and 3 deletions

29
app.py
View File

@ -185,6 +185,8 @@ class GenerateCharacter(Resource):
chartype = data.get('chartype') chartype = data.get('chartype')
character_sheet = {} character_sheet = {}
if chartype == 'mutant':
character_sheet['animal-stock'] = (roll_mutant_animal())
ability_scores = roll_ability_scores(chartype) ability_scores = roll_ability_scores(chartype)
character_sheet['abilities'] = ability_scores character_sheet['abilities'] = ability_scores
character_sheet['hp'] = roll_hp(chartype, ability_scores['constitution']) character_sheet['hp'] = roll_hp(chartype, ability_scores['constitution'])
@ -373,6 +375,33 @@ def roll_mutations(conscore, intscore):
return mutations_table return mutations_table
def roll_mutant_animal():
creature = dict()
animal_stock = ['badger', 'racoon', 'hound', 'wolf', 'big-cat', 'fox',
'spider', 'lizard', 'ant', 'hornet', 'hawk', 'ostrich', 'emu', 'crocodile',
'snake', 'rabbit', 'rat', 'bear', 'elephant', 'platypus', 'bull', 'horse', 'goat', 'bat',
'silverfish', 'cockroach', 'turtle', 'gibbon', 'penguin', 'orangutan', 'chimpanzee',
'housefly', 'lobster', 'crab', 'prawn', 'pig', 'chicken', 'duck', 'parrot', 'mouse',
'heron', 'weasel', 'squirrel', 'pigeon', 'crow', 'house-cat', 'shark', 'dolphin', 'narwhal',
'buffalo']
posture = ['upright', 'prone', 'mixed']
creature['stock'] = random.choice(animal_stock)
creature['posture'] = random.choice(posture)
if creature['posture'] == 'upright' or creature['posture'] == 'mixed':
creature['arms'] = random.choice(list(range(2, 4, 2))) # if you're upright 4 is the limit
creature['legs'] = random.choice(list(range(2, 6, 2))) # same with legs
if creature['posture'] == 'prone':
creature['legs'] = random.choice(list(range(4, 8, 2))) # if you're prone, you only get legs
return creature
def split_number(n): def split_number(n):
first_split = n // 2 # this will split the number in two equal parts, if it is even first_split = n // 2 # this will split the number in two equal parts, if it is even
second_split = n % 2 + first_split # this will add one to one part if the number is odd second_split = n % 2 + first_split # this will add one to one part if the number is odd

View File

@ -2,8 +2,9 @@ from flask_restx import fields
# Common fields # Common fields
chartype_field = fields.String( chartype_field = fields.String(
required=False, default="human", required=False,
description='Character type. Allowed values: "human", "humanoid", "mutant", "cyborg", "android"') default="human",
description='Character type. Allowed values: "human", "humanoid", "mutant", "cyborg"')
# Dice model # Dice model
dice_model = { dice_model = {

View File

@ -2,7 +2,7 @@ from marshmallow import Schema, fields, validate
chartype_field = fields.String( chartype_field = fields.String(
required=True, required=True,
validate=validate.OneOf(["human", "humanoid", "mutant", "cyborg", "android"]), validate=validate.OneOf(["human", "humanoid", "mutant", "cyborg"]),
description='The characters type of being' description='The characters type of being'
) )
@ -31,6 +31,7 @@ class AbilitySchema(Schema):
class EncounterSchema(Schema): class EncounterSchema(Schema):
terrain = fields.String( terrain = fields.String(
required=True, required=True,
default="clear",
validate=validate.OneOf(["clear", "mountains", "forest", "desert", "watery", "ruins", "deathlands"]), validate=validate.OneOf(["clear", "mountains", "forest", "desert", "watery", "ruins", "deathlands"]),
description='The terrain traversed at the time of the encounter roll' description='The terrain traversed at the time of the encounter roll'
) )