using Kryz.CharacterStats.Examples;
using Kryz.CharacterStats;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "UnitDifficultySettings", menuName = "RiftMayhem/Settings/Difficulty/UnitDifficultySettings", order = 0)]
public class UnitDifficultySettings : ScriptableObject
{
    [Header("Main Stat Modifiers:")]
    public float mainBaseStatFlatIncrease;
    public float mainStatPercentIncrease;
    [Header("Secondary Stats Modifiers:")]
    public float secondaryBaseStatsFlatIncrease;
    public float secondaryStatsPercentIncrease;
    [Header("Resources Modifiers:")]
    public float maxHealthPercentIncrease;
    public float maxManaPercentIncrease;

    private bool randomizedMainStat;

    public void SetDifficulty(ref Health health, ref Mana mana, ref CharacterStats stats)
    {
        randomizedMainStat = false;

        foreach (string stat in stats.statsDictionary.Keys)
        {
            if (Random.Range(0, 101) < 40 && !randomizedMainStat)
            {
                randomizedMainStat = true;
                stats.statsDictionary[stat].BaseValue += mainBaseStatFlatIncrease;
                stats.statsDictionary[stat].AddModifier(new StatModifier(mainStatPercentIncrease, StatModType.PercentMult, this));
            }
            else
            {
                stats.statsDictionary[stat].BaseValue += secondaryBaseStatsFlatIncrease;
                stats.statsDictionary[stat].AddModifier(new StatModifier(secondaryStatsPercentIncrease, StatModType.PercentMult, this));
            }
        }

        health.SetMaxValue((health.GetMaxValue() * (1f + maxHealthPercentIncrease)));
        mana.SetMaxValue((mana.GetMaxValue() * (1f + maxManaPercentIncrease)));
    }
}
