Skip to content

Commit

Permalink
Merge branch 'api_v2_backgrounds' into release/1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Nov 4, 2023
2 parents d313494 + 14cfb05 commit 7a80aac
Show file tree
Hide file tree
Showing 35 changed files with 7,653 additions and 103 deletions.
36 changes: 36 additions & 0 deletions api_v2/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,40 @@ class FeatAdmin(admin.ModelAdmin):
inlines = [
FeatBenefitInline,
]
list_display = ['key', 'category', 'name']


class TraitInline(admin.TabularInline):
model = Trait


class RaceAdmin(admin.ModelAdmin):
inlines = [
TraitInline,
]


class FeatBenefitInline(admin.TabularInline):
model = FeatBenefit
exclude = ('name',)


class FeatAdmin(admin.ModelAdmin):
inlines = [
FeatBenefitInline,
]


class BackgroundBenefitInline(admin.TabularInline):
model = BackgroundBenefit


class BackgroundAdmin(admin.ModelAdmin):
model = Background
inlines = [
BackgroundBenefitInline
]


admin.site.register(Weapon, admin_class=FromDocumentModelAdmin)
admin.site.register(Armor, admin_class=FromDocumentModelAdmin)
Expand All @@ -47,6 +81,8 @@ class FeatAdmin(admin.ModelAdmin):
admin.site.register(CreatureType)
admin.site.register(CreatureSet)

admin.site.register(Background, admin_class=BackgroundAdmin)

admin.site.register(Document)
admin.site.register(License)
admin.site.register(Publisher)
Expand Down
42 changes: 42 additions & 0 deletions api_v2/migrations/0009_auto_20230917_1018.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 3.2.20 on 2023-09-17 10:18

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0008_alter_featbenefit_desc'),
]

operations = [
migrations.CreateModel(
name='SuggestedCharacteristics',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('personality_trait_table', models.TextField(help_text='Table to roll for personality traits. Markdown.')),
('ideal_table', models.TextField(help_text='Table to roll for ideals. Markdown.')),
('bond_table', models.TextField(help_text='Table to roll for bonds. Markdown.')),
('flaw_table', models.TextField(help_text='Table to roll for flaws. Markdown.')),
],
),
migrations.AlterField(
model_name='featbenefit',
name='desc',
field=models.TextField(help_text='Description of the game content item. Markdown.'),
),
migrations.CreateModel(
name='Background',
fields=[
('name', models.CharField(help_text='Name of the item.', max_length=100)),
('desc', models.TextField(help_text='Description of the game content item. Markdown.')),
('key', models.CharField(help_text='Unique key for the Item.', max_length=100, primary_key=True, serialize=False)),
('characteristics', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api_v2.suggestedcharacteristics')),
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api_v2.document')),
],
options={
'verbose_name_plural': 'backgrounds',
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.20 on 2023-09-17 10:20

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0009_auto_20230917_1018'),
]

operations = [
migrations.RenameModel(
old_name='SuggestedCharacteristics',
new_name='Characteristics',
),
]
24 changes: 24 additions & 0 deletions api_v2/migrations/0011_auto_20230917_1023.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.20 on 2023-09-17 10:23

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0010_rename_suggestedcharacteristics_characteristics'),
]

operations = [
migrations.RemoveField(
model_name='background',
name='characteristics',
),
migrations.AddField(
model_name='characteristics',
name='background',
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='api_v2.background'),
preserve_default=False,
),
]
31 changes: 31 additions & 0 deletions api_v2/migrations/0012_auto_20230917_1030.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 3.2.20 on 2023-09-17 10:30

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0011_auto_20230917_1023'),
]

operations = [
migrations.AlterField(
model_name='characteristics',
name='background',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='api_v2.background'),
),
migrations.CreateModel(
name='BackgroundFeature',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Name of the item.', max_length=100)),
('desc', models.TextField(help_text='Description of the game content item. Markdown.')),
('background', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='api_v2.background')),
],
options={
'abstract': False,
},
),
]
27 changes: 27 additions & 0 deletions api_v2/migrations/0013_backgroundbenefit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.2.20 on 2023-09-17 10:47

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0012_auto_20230917_1030'),
]

operations = [
migrations.CreateModel(
name='BackgroundBenefit',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Name of the item.', max_length=100)),
('desc', models.TextField(help_text='Description of the game content item. Markdown.')),
('background', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api_v2.background')),
],
options={
'ordering': ['pk'],
'abstract': False,
},
),
]
18 changes: 18 additions & 0 deletions api_v2/migrations/0014_alter_featbenefit_desc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2023-10-03 14:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0013_backgroundbenefit'),
]

operations = [
migrations.AlterField(
model_name='featbenefit',
name='desc',
field=models.TextField(help_text='Text of the individual feat benefit.'),
),
]
28 changes: 28 additions & 0 deletions api_v2/migrations/0015_auto_20231003_2015.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.20 on 2023-10-03 20:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0014_alter_featbenefit_desc'),
]

operations = [
migrations.AddField(
model_name='backgroundbenefit',
name='type',
field=models.CharField(blank=True, choices=[('ability_score_increase', 'Ability Score Increase'), ('skill_proficiency', 'Skill Proficiency'), ('tool_proficiency', 'Tool Proficiency'), ('language', 'Language'), ('equipment', 'Equipment'), ('feature', 'Feature'), ('connection', 'Connection'), ('memento', 'Memento')], help_text='Benefit type.', max_length=200, null=True),
),
migrations.AddField(
model_name='featbenefit',
name='type',
field=models.CharField(blank=True, choices=[('ability_score_increase', 'Ability Score Increase'), ('skill_proficiency', 'Skill Proficiency'), ('tool_proficiency', 'Tool Proficiency'), ('language', 'Language'), ('equipment', 'Equipment'), ('feature', 'Feature'), ('connection', 'Connection'), ('memento', 'Memento')], help_text='Benefit type.', max_length=200, null=True),
),
migrations.AddField(
model_name='trait',
name='type',
field=models.CharField(blank=True, choices=[('ability_score_increase', 'Ability Score Increase'), ('skill_proficiency', 'Skill Proficiency'), ('tool_proficiency', 'Tool Proficiency'), ('language', 'Language'), ('equipment', 'Equipment'), ('feature', 'Feature'), ('connection', 'Connection'), ('memento', 'Memento')], help_text='Benefit type.', max_length=200, null=True),
),
]
28 changes: 28 additions & 0 deletions api_v2/migrations/0016_auto_20231004_1102.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.20 on 2023-10-04 11:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0015_auto_20231003_2015'),
]

operations = [
migrations.RemoveField(
model_name='characteristics',
name='background',
),
migrations.AlterField(
model_name='featbenefit',
name='desc',
field=models.TextField(help_text='Description of the game content item. Markdown.'),
),
migrations.DeleteModel(
name='BackgroundFeature',
),
migrations.DeleteModel(
name='Characteristics',
),
]
28 changes: 28 additions & 0 deletions api_v2/migrations/0017_auto_20231006_1953.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.20 on 2023-10-06 19:53

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0016_auto_20231004_1102'),
]

operations = [
migrations.AlterField(
model_name='backgroundbenefit',
name='type',
field=models.CharField(blank=True, choices=[('ability_score_increase', 'Ability Score Increase'), ('skill_proficiency', 'Skill Proficiency'), ('tool_proficiency', 'Tool Proficiency'), ('language', 'Language'), ('equipment', 'Equipment'), ('feature', 'Feature'), ('suggested_characteristics', 'Suggested Characteristics'), ('adventures_and_advancement', 'Adventures and Advancement'), ('connection_and_memento', 'Connection and Memento')], help_text='Benefit type.', max_length=200, null=True),
),
migrations.AlterField(
model_name='featbenefit',
name='type',
field=models.CharField(blank=True, choices=[('ability_score_increase', 'Ability Score Increase'), ('skill_proficiency', 'Skill Proficiency'), ('tool_proficiency', 'Tool Proficiency'), ('language', 'Language'), ('equipment', 'Equipment'), ('feature', 'Feature'), ('suggested_characteristics', 'Suggested Characteristics'), ('adventures_and_advancement', 'Adventures and Advancement'), ('connection_and_memento', 'Connection and Memento')], help_text='Benefit type.', max_length=200, null=True),
),
migrations.AlterField(
model_name='trait',
name='type',
field=models.CharField(blank=True, choices=[('ability_score_increase', 'Ability Score Increase'), ('skill_proficiency', 'Skill Proficiency'), ('tool_proficiency', 'Tool Proficiency'), ('language', 'Language'), ('equipment', 'Equipment'), ('feature', 'Feature'), ('suggested_characteristics', 'Suggested Characteristics'), ('adventures_and_advancement', 'Adventures and Advancement'), ('connection_and_memento', 'Connection and Memento')], help_text='Benefit type.', max_length=200, null=True),
),
]
4 changes: 4 additions & 0 deletions api_v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@

from .race import Trait
from .race import Race

from .feat import FeatBenefit
from .feat import Feat

from .background import BackgroundBenefit
from .background import Background

from .creature import Creature
from .creature import CreatureAction
from .creature import CreatureAttack
Expand Down
33 changes: 32 additions & 1 deletion api_v2/models/abstracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


class HasName(models.Model):
"""This is the definition of a name."""

name = models.CharField(
max_length=100,
Expand All @@ -19,14 +20,18 @@ class Meta:


class HasDescription(models.Model):
"""This is the definition of a description."""

desc = models.TextField(
help_text='Description of the game content item. Markdown.')

class Meta:
abstract = True


class HasPrerequisite(models.Model):
"""This is the definition of a prerequisite."""

prerequisite = models.CharField(
max_length=200,
blank=True,
Expand Down Expand Up @@ -101,6 +106,32 @@ class Meta:
ordering = ['pk']

class Benefit(HasName, HasDescription):
"""
This is the definition of a Benefit abstract base class.
A benefit class will be reimplemented from Feat, Race, Background, etc.
Basically it describes any sort of modification to a character in 5e.
"""

BENEFIT_TYPES = [
("ability_score_increase", "Ability Score Increase"),
("skill_proficiency", "Skill Proficiency"),
("tool_proficiency", "Tool Proficiency"),
("language", "Language"),
("equipment", "Equipment"),
("feature", "Feature"), # Used in Backgrounds
("suggested_characteristics", "Suggested Characteristics"), # Used in Backgrounds
("adventures_and_advancement", "Adventures and Advancement"), # Used in A5e Backgrounds
("connection_and_memento", "Connection and Memento")] # Used in A5e Backgrounds


type = models.CharField(
max_length=200,
blank=True,
null=True,
choices=BENEFIT_TYPES,
help_text='Benefit type.')

class Meta:
abstract = True
ordering = ['pk']
Loading

0 comments on commit 7a80aac

Please sign in to comment.