Example #1
0
def race_api(request, pk):
    try:
        race = Race.objects.get(pk=pk.title())
    except Race.DoesNotExist:
        return HttpResponse(status=403)

    if request.method == 'GET':
        serializer = RaceSerializer(race)
        return JsonResponse(serializer.data)

    elif request.method == 'PUT':
        data = JSONParser().parse(request)
        serializer = RaceSerializer(pk, data=data)
        if serializer.is_valid():
            serializer.save()
            return JsonResponse(serializer.data)
        return JsonResponse(serializer.errors, status=400)

    elif request.method == 'DELETE':
        race.delete()
        return HttpResponse(status=204)
Example #2
0
RaceTrait.objects.create(
    race_name=tiefling,
    trait_name='Darkvision',
    trait_effect='Thanks to your infernal heritage, you'
    'have superior vision in dark and dim conditions. You'
    'can see in dim light within 60 feet of you as if it were'
    'bright light, and in darkness as if it w ere dim light. You'
    'can\'t discern color in darkness, only shades o f gray.')

RaceTrait.objects.create(race_name=tiefling,
                         trait_name='Hellish Resilience',
                         trait_effect='You have resistance to fire damage')

RaceTrait.objects.create(
    race_name=tiefling,
    trait_name='Infernal Legacy',
    trait_effect='You know the thaumaturgy cantrip.'
    'Once you reach 3rd level, you can cast the hellish'
    'rebuke spell once per day as a 2nd-level spell. O nce you'
    'reach 5th level, you can also cast the darkness spell'
    'once per day. Charisma is your spellcasting ability for'
    'these spells')

Language.objects.create(race_name=tiefling, language='Common')

Language.objects.create(race_name=tiefling, language='Infernal')

tiefling_serializer = RaceSerializer(instance=tiefling)
tiefling_serializer.data
RaceTrait.objects.create(race_name=dragonborn,
                         trait_name='Breath Weapon',
                         trait_effect='You can use your action to exhale'
                                      'destructive energy. Your draconic ancestry determines'
                                      'the size, shape, and damage type of the exhalation.'
                                      'W hen you use your breath weapon, each creature in'
                                      'the area of the exhalation must make a saving throw,'
                                      'the type of which is determined by your draconic'
                                      'ancestry. The DC for this saving throw equals 8 +'
                                      'your Constitution m odifier + your proficiency bonus. A'
                                      'creature takes 2d6 damage on a failed save, and half'
                                      'as much damage on a successful one. The damage'
                                      'increases to 3d6 at 6th level, 4d6 at 11th level, and 5d6'
                                      'at 16th level.'
                                      'After you use your breath weapon, you can’t use it'
                                      'again until you com plete a short or long rest')

RaceTrait.objects.create(race_name=dragonborn,
                         trait_name='Damage Resistance',
                         trait_effect='You have resistance to the damage type'
                                      ' associated with your draconic ancestry')

Language.objects.create(race_name=dragonborn,
                        language='Common')

Language.objects.create(race_name=dragonborn,
                        language='Draconic')

dragonborn_serializer = RaceSerializer(instance=dragonborn)
dragonborn_serializer.data
Example #4
0
RaceTrait.objects.create(
    race_name=halfelf,
    trait_name='Skill Versatility',
    trait_effect='You gain proficiency in two skills of your choice')

RaceTrait.objects.create(
    race_name=halfelf,
    trait_name='Tool Proficiency',
    trait_effect='You gain proficiency with the'
    'artisan\'s tools of your choice: smith\'s tools, brewer\'s'
    'supplies, or m ason\'s tools')

RaceTrait.objects.create(
    race_name=halfelf,
    trait_name='Stonecunning',
    trait_effect='Whenever you make an Intelligence'
    '(History) check related to the origin of stonework, you'
    ' are considered proficient in the History skill and add'
    ' double your proficiency bonus to the check, instead of'
    ' your normal proficiency bonus')
Language.objects.create(race_name=halfelf, language='Common')

Language.objects.create(race_name=halfelf, language='Elvish')

Language.objects.create(race_name=halfelf,
                        language='One language of your choice')

halfelf_serializer = RaceSerializer(instance=halfelf)
halfelf_serializer.data
Example #5
0
                         ' throws against poison, and you have resistance'
                         ' against poison damage')

RaceTrait.objects.create(race_name=race,
                         trait_name='Dwarven Combat Training',
                         trait_effect='You have proficiency'
                         'with the battleaxe, handaxe, throwing hammer,'
                         'and warhammer.')

RaceTrait.objects.create(
    race_name=race,
    trait_name='Tool Proficiency',
    trait_effect='You gain proficiency with the'
    'artisan\'s tools of your choice: smith\'s tools, brewer\'s'
    'supplies, or m ason\'s tools')

RaceTrait.objects.create(
    race_name=race,
    trait_name='Stonecunning',
    trait_effect='Whenever you make an Intelligence'
    '(History) check related to the origin of stonework, you'
    ' are considered proficient in the History skill and add'
    ' double your proficiency bonus to the check, instead of'
    ' your normal proficiency bonus')
Language.objects.create(race_name=race, language='Common')

Language.objects.create(race_name=race, language='Dwarvish')

dwarf_race_serializer = RaceSerializer(instance=race)
dwarf_race_serializer.data
Example #6
0
from rest_framework.parsers import JSONParser

halfling = Race.objects.create(race_name='Halfling',
                               dexterity_modifier=2,
                               speed=25)

RaceTrait.objects.create(race_name=halfling,
                         trait_name='Lucky',
                         trait_effect='When you roll a 1 on an attack roll, ability'
                                      'check, or saving throw, you can reroll the die and must'
                                      'use the new roll.')

RaceTrait.objects.create(race_name=halfling,
                         trait_name='Brave',
                         trait_effect='You have advantage on saving throws against being'
                                      'frightened')

RaceTrait.objects.create(race_name=halfling,
                         trait_name='Halfling Nimbleness',
                         trait_effect='You can move through the'
                                        'space of any creature that is of a size larger than yours')

Language.objects.create(race_name=halfling,
                        language='Common')

Language.objects.create(race_name=halfling,
                        language='Halfling')

halfling_serializer = RaceSerializer(instance=halfling)
halfling_serializer.data
Example #7
0
from character_builder.models import Race, RaceTrait, Language
from character_builder.serializers import RaceSerializer, RaceTraitSerializer
from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser

gnome = Race.objects.create(race_name='Gnome',
                            intelligence_modifier=2,
                            speed=25)

RaceTrait.objects.create(
    race_name=gnome,
    trait_name='Dark Vision',
    trait_effect='Accustom ed to life underground, you have'
    'superior vision in dark and dim conditions. You can'
    'see in dim light within 60 feet of you as if it w ere bright'
    'light, and in darkness as if it were dim light. You can\'t'
    'discern color in darkness, only shades of gray.')

RaceTrait.objects.create(
    race_name=gnome,
    trait_name='Gnome Cunning',
    trait_effect='You have advantage on all Intelligence, Wisdom,'
    ' and Charisma saving throws against magic.')

Language.objects.create(race_name=gnome, language='Common')

Language.objects.create(race_name=gnome, language='Gnomish')

gnome_serializer = RaceSerializer(instance=gnome)
gnome_serializer.data
Example #8
0
    'light, and in darkness as if it w ere dim light. You can\'t'
    'discern color in darkness, only shades o f gray')

RaceTrait.objects.create(race_name=halforc,
                         trait_name='Menacing',
                         trait_effect='You gain proficiency in the'
                         'Intimidation skill.')

RaceTrait.objects.create(
    race_name=halforc,
    trait_name='Relentless Endurance',
    trait_effect='W hen you are reduced to'
    '0 hit points but not killed outright, you can drop to 1 hit'
    'point instead. You can’t use this feature again until you'
    'finish a long rest.')

RaceTrait.objects.create(
    race_name=halforc,
    trait_name='Savage Attacks',
    trait_effect='W hen you score a critical hit with'
    'a melee weapon attack, you can roll one of the w eapon\'s'
    'damage dice one additional time and add it to the extra'
    'damage of the critical hit.')

Language.objects.create(race_name=halforc, language='Common')

Language.objects.create(race_name=halforc, language='Orc')

halforc_serializer = RaceSerializer(instance=halforc)
halforc_serializer.data
Example #9
0
from character_builder.models import Race, RaceTrait, Language
from character_builder.serializers import RaceSerializer, RaceTraitSerializer
from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser

human = Race.objects.create(race_name='Human',
                            strength_modifier=1,
                            dexterity_modifier=1,
                            constitution_modifier=1,
                            wisdom_modifier=1,
                            intelligence_modifier=1,
                            charisma_modifier=1,
                            speed=30)

Language.objects.create(race_name=human, language='Common')

Language.objects.create(race_name=human,
                        language='One extra language of your choice')

human_serializer = RaceSerializer(instance=human)
human_serializer.data