import pygame
import os
import json
from lib.game.heroes.hero import Hero


main_hero_config = None
main_hero_config_dir = "lib/config/heroes/main_hero_config.json"
file_exists = os.path.isfile(main_hero_config_dir)
if file_exists:
    with open(main_hero_config_dir) as json_file:
        main_hero_config = json.load(json_file)
BASE_SPEED = main_hero_config['baseSpeed'] if main_hero_config is not None else 300


class MainHero(Hero):

    def __init__(self):
        self.__character = pygame.image.load('config/assets/main_hero.png')
        self.__move_speed = BASE_SPEED
        self.__position_x = 5000  # Value only for testing purposes, will be generated by server
        self.__position_y = 5000  # Value only for testing purposes, will be generated by server

    def get_character(self):
        return self.__character

    def get_move_speed(self):
        return self.__move_speed

    def update_position(self, horizontal_speed, vertical_speed):
        self.__position_x += horizontal_speed
        self.__position_y += vertical_speed

