extends Control

var move_button = preload("res://ui/battle_ui/battle_move_button.tscn")

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	self.visible = false
	for i in range(4):
		var button = move_button.instantiate()
		%BattleMovesMenu.add_child(button)

func update() -> void:
	var player = Utils.get_player()
	var player_fighter = SaveManager.current_save.party[0] as MonsterData
	
	%PartyFighterLevel.text = "Lv. %s" % str(player_fighter.level)
	%PartyFighterName.text = player_fighter.nickname if not player_fighter.nickname.is_empty() else player_fighter.name
	%PartyFighterHealthbar.max_value = player_fighter.health
	%PartyFighterHealthbar.value = player_fighter.current_health
	
	%EnemyMonsterLevel.text = "Lv. %s" % player.enemy.data.level
	%EnemyMonsterName.text = player.enemy.data.name
	%EnemyMonsterHealthbar.max_value = player.enemy.data.health
	%EnemyMonsterHealthbar.value = player.enemy.data.current_health

func _on_battle_button_pressed() -> void:
	print("attacking enemy")
	Utils.get_player().attack_enemy()


func set_message(msg: String) -> void:
	%Message.text = msg
