From 63aa245cf34a09391f493934dd42541cecbb26aa Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Mon, 24 Jun 2024 00:47:38 +0100 Subject: [PATCH] add base animal characteristics to mutant chartype --- app.py | 29 +++++++++++++++++++++++++++++ models.py | 5 +++-- schemas.py | 3 ++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 50ff080..065b0fa 100644 --- a/app.py +++ b/app.py @@ -185,6 +185,8 @@ class GenerateCharacter(Resource): chartype = data.get('chartype') character_sheet = {} + if chartype == 'mutant': + character_sheet['animal-stock'] = (roll_mutant_animal()) ability_scores = roll_ability_scores(chartype) character_sheet['abilities'] = ability_scores character_sheet['hp'] = roll_hp(chartype, ability_scores['constitution']) @@ -373,6 +375,33 @@ def roll_mutations(conscore, intscore): 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): 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 diff --git a/models.py b/models.py index c6ef6dd..e6a0c93 100644 --- a/models.py +++ b/models.py @@ -2,8 +2,9 @@ from flask_restx import fields # Common fields chartype_field = fields.String( - required=False, default="human", - description='Character type. Allowed values: "human", "humanoid", "mutant", "cyborg", "android"') + required=False, + default="human", + description='Character type. Allowed values: "human", "humanoid", "mutant", "cyborg"') # Dice model dice_model = { diff --git a/schemas.py b/schemas.py index acbb21d..8b70ba5 100644 --- a/schemas.py +++ b/schemas.py @@ -2,7 +2,7 @@ from marshmallow import Schema, fields, validate chartype_field = fields.String( required=True, - validate=validate.OneOf(["human", "humanoid", "mutant", "cyborg", "android"]), + validate=validate.OneOf(["human", "humanoid", "mutant", "cyborg"]), description='The characters type of being' ) @@ -31,6 +31,7 @@ class AbilitySchema(Schema): class EncounterSchema(Schema): terrain = fields.String( required=True, + default="clear", validate=validate.OneOf(["clear", "mountains", "forest", "desert", "watery", "ruins", "deathlands"]), description='The terrain traversed at the time of the encounter roll' )