ft_transcendence/games/models.py

21 lines
572 B
Python
Raw Normal View History

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)
winner_id = models.IntegerField(default=-1)
2023-12-12 06:06:13 -05:00
def create(self, users_id: [int]):
self.save()
for user_id in users_id:
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()