import os
import pygame

class BoardField(pygame.sprite.Sprite):
    __fieldID:str
    __name:str
    __side:str
    __type:str
    __pos:pygame.Vector2
    __size:tuple
    __color:tuple = (255,255,255)
    __holdsCard = None
    image:pygame.image
    rect:pygame.rect

    def __init__(self, name:str, side:str, type:str, pos:pygame.Vector2, imagePath:str, fid:str):
        pygame.sprite.Sprite.__init__(self)
        self.__name = name
        self.__side = side
        self.__type = type
        self.__pos = pos
        self.__holdsCard = None
        self.__fieldID = fid

        # Überprüfen des Dateipfads
        if not os.path.exists(imagePath):
            print("Der Dateipfad zur Bilddatei ist ungültig oder die Datei existiert nicht.")
        else:
            # Wenn der Pfad gültig ist, versuchen Sie, das Bild zu laden
            self.image = pygame.image.load(imagePath).convert_alpha()
        
        self.rect = self.image.get_rect()
        self.rect.center = self.__pos

    def getName(self) -> str:
        return self.__name

    def getSide(self) -> str:
        return self.__side

    def getType(self) -> str:
        return self.__type

    def getPos(self) -> pygame.Vector2:
        return self.__pos

    def getSize(self) -> tuple:
        return self.__size

    def getColor(self) -> tuple:
        return self.__color

    def getRect(self) -> pygame.Rect:
        return self.rect

    def getImage(self) -> pygame.image:
        return self.image
    
    def getHoldingCard(self):
        return self.__holdsCard

    def setName(self, name:str) -> str:
        self.__name = name
        return self.__name

    def setType(self,type:str) -> str:
        self.__type = type
        return self.__type

    def setPos(self, pos:pygame.Vector2) -> pygame.Vector2:
        self.pos = pos
        return self.__pos

    def setSize(self, size:tuple) -> tuple:
        self.__size = size
        return self.__size

    def setColor(self, color:tuple) -> tuple:
        self.__color = color
        return self.__color
    
    def setCardHolding(self, card):
        self.__holdsCard = card

    def getFieldID(self) -> str:
        return self.__fieldID