from django.db import models

# Create your models here.
class GameModel(models.Model):

	finished = models.BooleanField(default = False)
	started = models.BooleanField(default = False)
	winner_id = models.IntegerField(default = -1)
	
	def create(self, players_id: [int]):
		self.save()
		for player_id in players_id:
			GameMembersModel(game_id = self.pk, player_id = player_id).save()
		return self.pk

	def start(self):
		self.started = True
	
	def get_players_id(self):
		return [game_player.player_id for game_player in GameMembersModel.objects.filter(game_id = self.pk)]

class GameMembersModel(models.Model):
	game_id = models.IntegerField()
	player_id = models.IntegerField()