using Godot;
using System;

public partial class upgrade_menu : CenterContainer
{
    private Button _healthUpgrade;
    private Button _speedUpgrade;
    private Button _damageUpgrade;
    
    private Label _healthStat;
    private Label _speedStat;
    private Label _damageStat;

    private int _healthInt;
    private int _speedInt;
    private int _damageInt;
    
    [Export]
    public player PlayerNode;
    
    public override void _Ready()
    {
        _healthUpgrade = GetNode<Button>("VBox/HBox/Health/HealthUpgrade");
        _speedUpgrade = GetNode<Button>("VBox/HBox/Speed/SpeedUpgrade");
        _damageUpgrade = GetNode<Button>("VBox/HBox/Damage/DamageUpgrade");
        
        _healthStat = GetNode<Label>("VBox/HBox/Health/HealthStat");
        _speedStat = GetNode<Label>("VBox/HBox/Speed/SpeedStat");
        _damageStat = GetNode<Label>("VBox/HBox/Damage/DamageStat");
        
        
        _healthUpgrade.Pressed += () =>
        {
            _healthInt += 10;
            _healthStat.Text = ("+ " + _healthInt + "%");
            GetTree().Paused = false;
            if (_healthInt <= 100) PlayerNode.HealthUpgrade();
            Visible = false;
        };
        
        _speedUpgrade.Pressed += () =>
        {
            _speedInt += 10;
            _speedStat.Text = ("+ " + _speedInt + "%");
            GetTree().Paused = false;
            if (_speedInt <= 100) PlayerNode.SpeedUpgrade();
            Visible = false;
        };

        _damageUpgrade.Pressed += () =>
        {
            _damageInt += 10;
            _damageStat.Text = ("+ " + _damageInt + "%");
            GetTree().Paused = false;
            if (_speedInt <= 100) PlayerNode.DamageUpgrade();
            Visible = false;
        };
    }
}
