using Assets.Scripts;
using Assets.Scripts.Slimes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Assets.Scripts
{
    public class Enemy : MonoBehaviour
    {
        string enemyname;
        System.Random rand = new System.Random();
        BasicSlime slime;
        SlimeFactory factory = new SlimeFactory();

        // Start is called before the first frame update
        void Start()
        {
            enemyname = gameObject.name;
            if (enemyname.Contains("("))
            {
                enemyname = enemyname.Split('(')[0];
            }

            renameEnemy();
        }

        // Update is called once per frame
        void Update()
        {

        }

        private void renameEnemy()
        {
            switch (enemyname)
            {
                case "SlimeMageIdle":
                    enemyname = "Slime (Mage)";
                    break;
                case "SlimeBaseIdle":
                    enemyname = "Slime";
                    break;
                case "SlimeMetalIdle":
                    enemyname = "Slime (Metal)";
                    break;
                case "SlimeMiniBossIdle":
                    enemyname = "Slime (MiniBoss)";
                    break;
                case "SlimeWarriorIdle":
                    enemyname = "Slime (Warrior)";
                    break;
                case "SlimeWaterIdle":
                    enemyname = "Slime (Water)";
                    break;
                case "SlimeBossIdle":
                    enemyname = "Slime (Boss)";
                    break;
            }
        }

        public void scaleEnemy(Player player)
        {
            if (slime == null)
            {
                switch (enemyname)
                {
                    case "Slime (Mage)":
                        slime = factory.generateMageSlime(player);
                        break;
                    case "Slime":
                        slime = factory.generateNormalSlime(player);
                        break;
                    case "Slime (Metal)":
                        slime = factory.generateMetalSlime(player);
                        break;
                    case "Slime (MiniBoss)":
                        slime = factory.generateMiniBossSlime(player);
                        break;
                    case "Slime (Warrior)":
                        slime = factory.generateWarriorSlime(player);
                        break;
                    case "Slime (Water)":
                        slime = factory.generateWaterSlime(player);
                        break;
                    case "Slime (Boss)":
                        slime = factory.generateBossSlime(player);
                        break;
                }
            }
        }

        public int[] getStats()
        {
            return slime.getStats();
        }

        public string getEnemyName()
        {
            return enemyname;
        }

        public int calculateDamage()
        {
            return slime.calculateDamage(rand);
        }

        public int calculateHeavy()
        {
            return slime.calculateHeavy(rand);
        }

        public bool takeDamage(int amount)
        {
            return slime.takeDamage(amount,rand);
        }

        public int getExperience()
        {
            return slime.getExperience();
        }
    }
}