import pygame
fps = 60

class Character():
    def __init__(self, name, ms, sprite) -> None:
        self.name = name
        self.speed = ms
        with open(f'art/images/{sprite}') as i:
            self.sprite = pygame.image.load(i)
        self.x = 524
        self.y = 524
        self.hidden = False

        self.rect = pygame.Rect(self.x, self.y, self.sprite.get_width(), self.sprite.get_height())
    
    def draw(self, screen):
        if self.hidden:
            return
        self.rect.x, self.rect.y = self.x, self.y
        screen.blit(self.sprite, self.rect)


class NPC(Character):
    pass


class Fighter(Character):
    def __init__(self, name, ms, sprite, health, damage, level, asp, atr) -> None:
        super().__init__(name, ms, sprite)
        self.health = health
        self.damage = damage
        self.level = level
        self.attack_speed = asp
        self.attack_range = atr

class MainCharacter(Fighter):
    def __init__(self, name, ms, sprite, health, damage, level, asp, atr, weapon=None, shield=None) -> None:
        super().__init__(name, ms, sprite, health, damage, level, asp, atr)
        self.attack_spell = weapon
        self.shield_spell = shield
        self.talking = False

    def update(self, keys):
        if keys[pygame.K_w]:
            self.y -= self.speed / fps
        if keys[pygame.K_a]:
            self.x -= self.speed / fps
        if keys[pygame.K_s]:
            self.y += self.speed / fps
        if keys[pygame.K_d]:
            self.x += self.speed / fps

class Mobs(Fighter):
    def __init__(self, name, ms, sprite, health, damage, level, asp, atr, drops) -> None:
        super().__init__(name, ms, sprite, health, damage, level, asp, atr)
        self.drops = drops * (self.level / 2)
