2023-12-12 06:06:13 -05:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
# Create your models here.
|
|
|
|
class GameModel(models.Model):
|
2023-12-20 13:11:56 -05:00
|
|
|
|
|
|
|
finished = models.BooleanField(default=False)
|
|
|
|
started = models.BooleanField(default=False)
|
2023-12-20 15:11:37 -05:00
|
|
|
winner_id = models.IntegerField(null=True, blank=True)
|
2023-12-12 06:06:13 -05:00
|
|
|
|
|
|
|
def create(self, users_id: [int]):
|
|
|
|
self.save()
|
|
|
|
for user_id in users_id:
|
2023-12-18 17:18:39 -05:00
|
|
|
GameMembersModel(game_id=self.pk, member_id=user_id).save()
|
2023-12-12 06:06:13 -05:00
|
|
|
return self.pk
|
2023-12-20 13:11:56 -05:00
|
|
|
|
|
|
|
def get_users(self):
|
|
|
|
return list(GameMembersModel.objects.filter(self.pk))
|
2023-12-12 06:06:13 -05:00
|
|
|
|
|
|
|
class GameMembersModel(models.Model):
|
|
|
|
game_id = models.IntegerField()
|
|
|
|
member_id = models.IntegerField()
|