from pydantic import BaseModel, UUID4 from typing import List, Any from enum import Enum, auto import uuid class Card(BaseModel): text: str pick: int deck: str icon: str class Pack(BaseModel): icon: str official: bool name: str class RoundStart(BaseModel): czar: int card: Card class PubPlayer(BaseModel): name: str points: int = 0 class Player(PubPlayer): uuid: UUID4 # def __init__(self, name): # self.name = name # self.uuid = uuid.uuid4() class PubRoom(BaseModel): code: str czar: int = 0 players: List[PubPlayer] = [] # List of player's uuids started: bool = False played_cards: List[int] = [] packs: List[str] = [] class Answer(BaseModel): text: List[str] class AnswerReceived(Answer): uuid: str class AnswerSending(Answer): index: int class AnswerSendingButItHasAUUIDBecauseItIsImportantToCheckIfItWasSentByTheCzar(AnswerSending): uuid: str class Room(PubRoom): players: List[Player] = [] # List of player's uuids number: int admin_uuid: UUID4 = None answers: List[AnswerSending] = [] # def __init__(self, number): # super().__init__() # self.number = number # self.code = hashes.encode(number) class AutoName(Enum): # pylint: disable=no-self-argument def _generate_next_value_(name, start, count, last_values): return name class MessageType(AutoName): JOIN = auto() START = auto() ANSWER = auto() PICK = auto() ROOM = auto() class Message(BaseModel): msgtype: MessageType data: Any