from django.db import models
from django.contrib.auth.models import User


class Room(models.Model):
    name = models.CharField(max_length=30)
    nb_users = models.IntegerField(default=0)
    started = models.BooleanField(default=False)

    def __str__(self):
        return self.name


class Player(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    room = models.ForeignKey(Room, on_delete=models.CASCADE)
    ready = models.BooleanField(default=False)

    def __str__(self):
        return self.user.username
