using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NPC_Behavior : MonoBehaviour
{
    [SerializeField] private double _caffeineLevel = 0.0; // max 100, min 0
    [SerializeField] private double _hungerLevel = 0.0;    // max 100, min 0
    [SerializeField] private double _happinessLevel = 100.0; // max 100, min 0
    [SerializeField] private double _baseDevelopementPower = 100.0; // max 100, min 0
    [SerializeField] private double _developementPower = 100.0; // max unlimited, min 0
    [SerializeField] double eventRate = 1.0; // max 60, min 0 -> how many events are requested per minute

    /// <summary>
    /// Gibt das Koffeinlevel des Entwicklers zurück
    /// </summary>
    public double CaffeineLevel => _caffeineLevel;
    /// <summary>
    /// Gibt das Hungerlevel des Entwicklers zurück
    /// </summary>
    public double HungerLevel => _hungerLevel;
    /// <summary>
    /// Gibt das Zufriedenheitslevel des Entwicklers zurück
    /// </summary>
    public double HappnessLevel => _happinessLevel;
    /// <summary>
    /// Gibt die Basisentwicklungskraft des Entwicklers zurück
    /// </summary>
    public double BaseDevelopementPower => _baseDevelopementPower;
    /// <summary>
    /// Gibt die jetzige Entwicklungskraft des Entwicklers zurück
    /// </summary>
    public double DevelopmentPower => _developementPower;

    private GameManager _gameManager;
    private DeveloperNeeds _developerNeeds;

    // Start is called before the first frame update
    void Start()
    {
        _gameManager = GameManager.Instance;
        _developerNeeds = GetComponent<DeveloperNeeds>();
    }

    // Update is called once per frame
    void Update()
    {
        // fire event
        if (UnityEngine.Random.Range(0, 60) == 0)
        {
            Debug.Log("TEST");
        }
    }

    public Dictionary<string, double> GetStats()
    {
        return new Dictionary<string, double>
        {
            { "Caffine", _caffeineLevel },
            { "Hunger", _hungerLevel },
            { "Happiness", _happinessLevel },
            { "Developement Power", _developementPower }
        };
    }

    public void SetStats(Dictionary<string, double> stats)
    {
        foreach (string key in stats.Keys)
        { 
            switch (key)
            {
                case "Caffine": 
                    _caffeineLevel = stats[key];
                    break;
                case "Hunger":
                    _hungerLevel = stats[key];
                    break;
                case "Happiness":
                    _happinessLevel = stats[key];
                    break;
                case "Developement Power":
                    _developementPower = stats[key];
                    break;
                default:
                    Debug.LogError("Unknown Stat/Key");
                    break;
            }
        }
    }
}
