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

public enum MagicType
{
    Fire,
    Frost,
    Bolt,
    None
}

public enum MagicID
{
    Fire1,
    Fire2,
    Fire3,
    Fire4,

    Frost1,
    Frost2,
    Frost3,
    Frost4,

    Bolt1,
    Bolt2,
    Bolt3,
    Bolt4,

    Heal1,
    Heal2,
    Heal3,
    Heal4,
}

public class CharacterMagic
{
    public string m_name;
    public MagicType m_type;

    public int m_mpCost;
    public bool m_offensive;
    public int m_damageAmount;
    public int m_range;
    public int m_aoe;
    public int m_healAmount;

    static public Dictionary<MagicID, CharacterMagic> ms_magic = new Dictionary<MagicID, CharacterMagic>();

    static public CharacterMagic GetMagic(MagicID id)
    {
        CharacterMagic retVal;
        if ( ms_magic.TryGetValue( id, out retVal ))
        {
            return retVal;
        }
        Debug.LogError("Magic not found :" + id);
        return null;
    }

    static CharacterMagic()
    {
        NewOffensiveMagic(MagicID.Fire1,"Fire Lv1", MagicType.Fire, 3, 5, 2, 1);
        NewOffensiveMagic(MagicID.Fire2, "Fire Lv2", MagicType.Fire, 7, 9, 2, 2);
        NewOffensiveMagic(MagicID.Fire3, "Fire Lv3", MagicType.Fire, 13, 15, 3, 2);
        NewOffensiveMagic(MagicID.Fire4, "Fire Lv4", MagicType.Fire, 21, 18, 3, 3);

        NewOffensiveMagic(MagicID.Frost1, "Frost Lv1", MagicType.Frost, 5, 9, 1, 1);
        NewOffensiveMagic(MagicID.Frost2, "Frost Lv2", MagicType.Frost, 9, 14, 2, 1);
        NewOffensiveMagic(MagicID.Frost3, "Frost Lv3", MagicType.Frost, 14, 20, 3, 1);
        NewOffensiveMagic(MagicID.Frost4, "Frost Lv4", MagicType.Frost, 19, 25, 4, 2);

        NewOffensiveMagic(MagicID.Bolt1, "Bolt Lv1", MagicType.Bolt, 5, 8, 3, 2);
        NewOffensiveMagic(MagicID.Bolt2, "Bolt Lv2", MagicType.Bolt, 10, 10, 3, 3);
        NewOffensiveMagic(MagicID.Bolt3, "Bolt Lv3", MagicType.Bolt, 17, 13, 4, 3);
        NewOffensiveMagic(MagicID.Bolt4, "Bolt Lv4", MagicType.Bolt, 23, 14, 4, 4);

        NewDefensiveMagic(MagicID.Heal1, "Heal Lv1", 3, 9);
        NewDefensiveMagic(MagicID.Heal2, "Heal Lv2", 5, 16);
        NewDefensiveMagic(MagicID.Heal3, "Heal Lv3", 7, 23);
        NewDefensiveMagic(MagicID.Heal4, "Heal Lv4", 11, 35);
    }
     
    public static void NewOffensiveMagic( MagicID id, string name, MagicType type, int cost, int damage, int range, int aoe )
    {
        CharacterMagic magic = new CharacterMagic();
        magic.m_name = name;
        magic.m_mpCost = cost;
        magic.m_damageAmount = damage;
        magic.m_range = range;
        magic.m_aoe = aoe;
        magic.m_offensive = true;
        magic.m_type = type;
        ms_magic.Add(id,magic);
    }

    public static void NewDefensiveMagic(MagicID id, string name, int cost, int healAmount)
    {
        // TODO : other defensive magic than just heal? Buffs? Can't see having the time tho
        // All defensive spells have an aoe of 1. Since it's just one player char

        CharacterMagic magic = new CharacterMagic();
        magic.m_name = name;
        magic.m_mpCost = cost;
        magic.m_healAmount = healAmount;
        magic.m_aoe = 1;
        magic.m_offensive = false;
        ms_magic.Add(id, magic);
    }


}
