from __future__ import annotations

from channels.generic.websocket import WebsocketConsumer
from .ASpectator import ASpectator

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from games.objects.AGame import AGame

class APlayer(ASpectator):
    
    def __init__(self, user_id: int, socket: WebsocketConsumer, game: AGame):
        super().__init__(user_id, socket, game)
        
    def is_connected(self) -> bool:
        return self.socket != None
    
    def send_error(self, error_message: str, error_data = {}):
        
        data: dict = {
            "error_message": error_message
        }
        
        data.update(error_data)
        
        self.send("error", data)