patternpythondjangoMinor
Modeling a Mage character from nWoD, using Django
Viewed 0 times
nwoddjangomodelingcharactermageusingfrom
Problem
Goal
Design a representation of a mage character from the World of Darkness RPG, as well their associated spells.
Here is a visual representation of the schema. You can see it more closely on LucidChart if you like.
You can also see my draft here and on YUML
I have already made an attempt at laying out the models, but my main concern is that I'm either:
a) over complicating the above design;
b) implementing what I want incorrectly;
c) both.
The contents of my
```
#Main
from django.db import models
from nwod_characters.util import IntegerRangeField
from .choices import ATTRIBUTE_CHOICES, SKILL_CHOICES
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
# Create your models here.
class NWODCharacter(models.Model):
class Meta:
abstract = True
SUB_RACE_CHOICES = ()
FACTION_CHOICES = ()
name = models.CharField(max_length=200)
player = models.ForeignKey('auth.User')
created_date = models.DateTimeField(auto_now_add=True, auto_now=False)
updated_date = models.DateTimeField(auto_now_add=False, auto_now=True)
published_date = models.DateTimeField(blank=True, null=True)
sub_race = models.CharField(choices=SUB_RACE_CHOICES, max_length=50)
faction = models.CharField(choices=FACTION_CHOICES, max_length=50, null=True)
class Characteristics(models.Model):
class Meta:
abstract = True
VIRTUE_CHOICES = (('prudence', 'Prudence'), ('justice', 'Justice'),
('temperance', 'Temperance'), ('fortitude', 'Fortitude'), ('faith', 'Faith'),
('hope', 'Hope'), ('charity', 'Charity'))
VICE_CHOICES = (('lust', 'Lust'), ('gluttony', 'Gluttony'), ('greed', 'Greed'),
('sloth', 'Sloth'), ('wrath', 'Wrath'), ('envy', 'Envy'), ('pride', 'Pride'))
power_level = IntegerRangeField(min_value=1, max_value=10)
energy_trait = IntegerRangeField(min_value=1, max_value=10)
virtue =
Design a representation of a mage character from the World of Darkness RPG, as well their associated spells.
Here is a visual representation of the schema. You can see it more closely on LucidChart if you like.
You can also see my draft here and on YUML
I have already made an attempt at laying out the models, but my main concern is that I'm either:
a) over complicating the above design;
b) implementing what I want incorrectly;
c) both.
The contents of my
models.py, and mages models.py are below:```
#Main
from django.db import models
from nwod_characters.util import IntegerRangeField
from .choices import ATTRIBUTE_CHOICES, SKILL_CHOICES
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
# Create your models here.
class NWODCharacter(models.Model):
class Meta:
abstract = True
SUB_RACE_CHOICES = ()
FACTION_CHOICES = ()
name = models.CharField(max_length=200)
player = models.ForeignKey('auth.User')
created_date = models.DateTimeField(auto_now_add=True, auto_now=False)
updated_date = models.DateTimeField(auto_now_add=False, auto_now=True)
published_date = models.DateTimeField(blank=True, null=True)
sub_race = models.CharField(choices=SUB_RACE_CHOICES, max_length=50)
faction = models.CharField(choices=FACTION_CHOICES, max_length=50, null=True)
class Characteristics(models.Model):
class Meta:
abstract = True
VIRTUE_CHOICES = (('prudence', 'Prudence'), ('justice', 'Justice'),
('temperance', 'Temperance'), ('fortitude', 'Fortitude'), ('faith', 'Faith'),
('hope', 'Hope'), ('charity', 'Charity'))
VICE_CHOICES = (('lust', 'Lust'), ('gluttony', 'Gluttony'), ('greed', 'Greed'),
('sloth', 'Sloth'), ('wrath', 'Wrath'), ('envy', 'Envy'), ('pride', 'Pride'))
power_level = IntegerRangeField(min_value=1, max_value=10)
energy_trait = IntegerRangeField(min_value=1, max_value=10)
virtue =
Solution
You migrated the
I don't really see how I can review the rest of the code, though. What you have here is largely a data model... and without seeing code that will use these objects or the domain knowledge what this data model represents, I can't tell you whether your data model is good.
... I wonder, though... do you really need to turn all your links into classes? Would a table structure really be so bad? You can have a class that manages that specific table... I imagine that you'd use some of the collections classes that your language provides.
SKILL_CHOICES and ATTRIBUTE_CHOICES out to a separate file. Why not do the same for VIRTUE_CHOICES, VICE_CHOICES, SUB_RACE_CHOICES, FACTION_CHOICES, ARCANUM_CHOICES, PRIORITY_CHOICES? How are the other choices special?I don't really see how I can review the rest of the code, though. What you have here is largely a data model... and without seeing code that will use these objects or the domain knowledge what this data model represents, I can't tell you whether your data model is good.
... I wonder, though... do you really need to turn all your links into classes? Would a table structure really be so bad? You can have a class that manages that specific table... I imagine that you'd use some of the collections classes that your language provides.
Context
StackExchange Code Review Q#78991, answer score: 2
Revisions (0)
No revisions yet.