massive additions made thru somewhat new apps.epic.models, .urls, .views; new html page & partial in apps/gameboard; new apps.epic FT & ITs (all green); New Game applet now actually leads to game room feat. token-drop gatekeeper mechanism intended for 6 gamers
This commit is contained in:
@@ -1,3 +1,69 @@
|
||||
from django.db import models
|
||||
import uuid
|
||||
|
||||
# Create your models here.
|
||||
from django.db import models
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Room(models.Model):
|
||||
GATHERING = "GATHERING"
|
||||
OPEN = "OPEN"
|
||||
RENEWAL_DUE = "RENEWAL_DUE"
|
||||
GATE_STATUS_CHOICES = [
|
||||
(GATHERING, "Gathering"),
|
||||
(OPEN, "Open"),
|
||||
(RENEWAL_DUE, "Renewal Due"),
|
||||
]
|
||||
|
||||
PRIVATE = "PRIVATE"
|
||||
PUBLIC = "PUBLIC"
|
||||
INVITE_ONLY = "INVITE ONLY"
|
||||
VISIBILITY_CHOICES = [
|
||||
(PRIVATE, "Private"),
|
||||
(PUBLIC, "Public"),
|
||||
(INVITE_ONLY, "Invite Only"),
|
||||
]
|
||||
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
name = models.CharField(max_length=200)
|
||||
owner = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="owned_rooms"
|
||||
)
|
||||
visibility = models.CharField(max_length=20, choices=VISIBILITY_CHOICES, default=PRIVATE)
|
||||
gate_status = models.CharField(max_length=20, choices=GATE_STATUS_CHOICES, default=GATHERING)
|
||||
renewal_period = models.DurationField(null=True, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
board_state = models.JSONField(default=dict)
|
||||
seed_count = models.IntegerField(default=12)
|
||||
|
||||
class GateSlot(models.Model):
|
||||
EMPTY = "EMPTY"
|
||||
RESERVED = "RESERVED"
|
||||
FILLED = "FILLED"
|
||||
STATUS_CHOICES = [
|
||||
(EMPTY, "Empty"),
|
||||
(RESERVED, "Reserved"),
|
||||
(FILLED, "Filled"),
|
||||
]
|
||||
|
||||
room = models.ForeignKey(Room, on_delete=models.CASCADE, related_name="gate_slots")
|
||||
slot_number = models.IntegerField()
|
||||
gamer = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL, null=True, blank=True,
|
||||
on_delete=models.SET_NULL, related_name="gate_slots"
|
||||
)
|
||||
funded_by = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL, null=True, blank=True,
|
||||
on_delete=models.SET_NULL, related_name="funded_slots"
|
||||
)
|
||||
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default=EMPTY)
|
||||
reserved_at = models.DateTimeField(null=True, blank=True)
|
||||
filled_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
|
||||
@receiver(post_save, sender=Room)
|
||||
def create_gate_slots(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
for i in range(1, 7):
|
||||
GateSlot.objects.create(room=instance, slot_number=i)
|
||||
|
||||
Reference in New Issue
Block a user