add: attribute game state to gamemodel
This commit is contained in:
parent
4f0b2250bd
commit
8ed9deab2d
@ -2,12 +2,19 @@ from django.db import models
|
|||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class GameModel(models.Model):
|
class GameModel(models.Model):
|
||||||
|
|
||||||
|
finished = models.BooleanField(default=False)
|
||||||
|
started = models.BooleanField(default=False)
|
||||||
|
winner_id = models.IntegerField()
|
||||||
|
|
||||||
def create(self, users_id: [int]):
|
def create(self, users_id: [int]):
|
||||||
self.save()
|
self.save()
|
||||||
for user_id in users_id:
|
for user_id in users_id:
|
||||||
GameMembersModel(game_id=self.pk, member_id=user_id).save()
|
GameMembersModel(game_id=self.pk, member_id=user_id).save()
|
||||||
return self.pk
|
return self.pk
|
||||||
|
|
||||||
|
def get_users(self):
|
||||||
|
return list(GameMembersModel.objects.filter(self.pk))
|
||||||
|
|
||||||
class GameMembersModel(models.Model):
|
class GameMembersModel(models.Model):
|
||||||
game_id = models.IntegerField()
|
game_id = models.IntegerField()
|
||||||
|
Loading…
Reference in New Issue
Block a user