103 lines
2.8 KiB
Python
103 lines
2.8 KiB
Python
|
from django.db import models
|
||
|
from django.urls import reverse
|
||
|
from django.utils.translation import gettext as _
|
||
|
|
||
|
class Player(models.Model):
|
||
|
|
||
|
name = models.CharField(max_length=255)
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name = _("player")
|
||
|
verbose_name_plural = _("players")
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.name
|
||
|
|
||
|
def get_absolute_url(self):
|
||
|
return reverse("player_detail", kwargs={"pk": self.pk})
|
||
|
|
||
|
class Resource(models.Model):
|
||
|
|
||
|
name = models.CharField(max_length=255)
|
||
|
description = models.TextField()
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name = _("resource")
|
||
|
verbose_name_plural = _("resources")
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.name
|
||
|
|
||
|
def get_absolute_url(self):
|
||
|
return reverse("resource_detail", kwargs={"pk": self.pk})
|
||
|
|
||
|
|
||
|
class Adventure(models.Model):
|
||
|
|
||
|
name = models.CharField(max_length=255)
|
||
|
description = models.TextField()
|
||
|
|
||
|
master = models.ForeignKey("Player", verbose_name=_("master"), on_delete=models.SET_NULL, null=True, blank=True)
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name = _("Adventure")
|
||
|
verbose_name_plural = _("Adventures")
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.name
|
||
|
|
||
|
def get_absolute_url(self):
|
||
|
return reverse("adventure_detail", kwargs={"pk": self.pk})
|
||
|
|
||
|
|
||
|
class Character(models.Model):
|
||
|
name = models.CharField(max_length=255)
|
||
|
description = models.TextField()
|
||
|
|
||
|
player = models.ForeignKey("Player", verbose_name=_("player"), on_delete=models.SET_NULL, null=True, blank=True)
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name = _("character")
|
||
|
verbose_name_plural = _("characters")
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.name
|
||
|
|
||
|
def get_absolute_url(self):
|
||
|
return reverse("character_detail", kwargs={"pk": self.pk})
|
||
|
|
||
|
class PlaySession(models.Model):
|
||
|
|
||
|
date = models.DateField()
|
||
|
adventure = models.ForeignKey("Adventure", verbose_name=_("adventure"), on_delete=models.CASCADE)
|
||
|
characters = models.ManyToManyField("Character", verbose_name=_("characters"))
|
||
|
|
||
|
summary = models.TextField()
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name = _("playsession")
|
||
|
verbose_name_plural = _("playsessions")
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.name
|
||
|
|
||
|
def get_absolute_url(self):
|
||
|
return reverse("playsession_detail", kwargs={"pk": self.pk})
|
||
|
|
||
|
|
||
|
class ResourceEarned(models.Model):
|
||
|
|
||
|
resource = models.ForeignKey("Resource", verbose_name=_("resource"), on_delete=models.CASCADE)
|
||
|
character = models.ForeignKey("Character", verbose_name=_("character"), on_delete=models.CASCADE, null=True, blank=True)
|
||
|
amount = models.IntegerField()
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name = _("resourceearned")
|
||
|
verbose_name_plural = _("resourceearneds")
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.name
|
||
|
|
||
|
def get_absolute_url(self):
|
||
|
return reverse("resourceearned_detail", kwargs={"pk": self.pk})
|