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

public enum EnemyID
{
    Enemy1,
    Enemy2,
    Enemy3,
    Enemy4,
    Enemy5,
    Enemy6,
    Enemy7,
    Enemy8,
    Enemy9,
    Enemy10,
    Enemy11,
    Enemy12,
    Enemy13,
    Enemy14,
    Enemy15,
    Enemy16,
    Enemy17,
    Enemy18,
    Enemy19,
    Enemy20
}

public class EnemyDatabase 
{
    public static int Count
    {
        get { return ms_db.Count; }
    }

    private static Dictionary<EnemyID, CharacterInfo> ms_db = new Dictionary<EnemyID, CharacterInfo>() 
    {
        //                                                    hp,     mp   atk def move canFly
        { EnemyID.Enemy1, new CharacterInfo( "Wisp"         , 5     , 0,    5,  3,  7,  false ).EnemyIcon(0).AddItem(ItemID.Sword1) },
        { EnemyID.Enemy2, new CharacterInfo( "Slime"        , 9     , 0,    7,  4,  6,  false ).EnemyIcon(1).AddItem(ItemID.Sword2) },
        { EnemyID.Enemy3, new CharacterInfo( "Jellyfish"    , 11    , 0,    9,  4,  5,  false ).EnemyIcon(2).AddItem(ItemID.Sword2) },
        { EnemyID.Enemy4, new CharacterInfo( "Witch"        , 12    , 10,   11,  8,  5,  false ).EnemyIcon(3).AddItem(ItemID.Sword1).AddMagic(MagicID.Fire1) },
        { EnemyID.Enemy5, new CharacterInfo( "Ghost"        , 15     , 0,    13,  8,  7,  false ).EnemyIcon(0).AddItem(ItemID.Bow2) },
        { EnemyID.Enemy6, new CharacterInfo( "Ooze"         , 18     , 0,    14,  8,  6,  false ).EnemyIcon(1).AddItem(ItemID.Sword2) },
        { EnemyID.Enemy7, new CharacterInfo( "Mushroom"     , 23    , 0,    17,  12,  5,  false ).EnemyIcon(2).AddItem(ItemID.Sword3) },
        { EnemyID.Enemy8, new CharacterInfo( "Priest"       , 26    , 20,   18,  12,  5,  false ).EnemyIcon(3).AddItem(ItemID.Bow2).AddMagic(MagicID.Fire2) },
        { EnemyID.Enemy9, new CharacterInfo( "Plague"       , 30     , 0,    19,  12,  7,  false ).EnemyIcon(0).AddItem(ItemID.Sword3) },
        { EnemyID.Enemy10, new CharacterInfo( "Leech"       , 35    , 24,    23,  15,  6,  false ).EnemyIcon(1).AddItem(ItemID.Sword3).AddMagic(MagicID.Frost2) },
        { EnemyID.Enemy11, new CharacterInfo( "Ghost"       , 38    , 0,    25,  15,  5,  false ).EnemyIcon(2).AddItem(ItemID.Bow3) },
        { EnemyID.Enemy12, new CharacterInfo( "Wizard"       , 42    , 27,   26,  15,  5,  false ).EnemyIcon(3).AddItem(ItemID.Sword4).AddMagic(MagicID.Fire3) },
        { EnemyID.Enemy13, new CharacterInfo( "Evil Archer"    , 45     , 0,    28,  17,  7,  false ).EnemyIcon(0).AddItem(ItemID.Bow4) },
        { EnemyID.Enemy14, new CharacterInfo( "Void"        , 47     , 0,    30,  19,  6,  false ).EnemyIcon(1).AddItem(ItemID.Ninja1) },
        { EnemyID.Enemy15, new CharacterInfo( "Spirit"      , 52    , 0,    32,  23,  5,  false ).EnemyIcon(2).AddItem(ItemID.Cannon1) },
        { EnemyID.Enemy16, new CharacterInfo( "Wraith"       , 55    , 30,   34,  25,  5,  false ).EnemyIcon(3).AddItem(ItemID.Ninja2).AddMagic(MagicID.Fire3) },
        { EnemyID.Enemy17, new CharacterInfo( "Rocket"        , 57     , 0,    37,  27,  7,  false ).EnemyIcon(0).AddItem(ItemID.Cannon2) },
        { EnemyID.Enemy18, new CharacterInfo( "Frostwrym"       , 60     , 35,    39,  34,  6,  false ).EnemyIcon(1).AddItem(ItemID.Ninja2).AddMagic(MagicID.Frost3) },
        { EnemyID.Enemy19, new CharacterInfo( "Cannon"      , 63   , 0,    40,  35,  5,  false ).EnemyIcon(2).AddItem(ItemID.Cannon3) },
        { EnemyID.Enemy20, new CharacterInfo( "Demon"         , 67    , 42,   42,  37,  5,  false ).EnemyIcon(3).AddItem(ItemID.Ninja3).AddMagic(MagicID.Fire4) },

    };

    static public EnemyID GetID(int index)
    {
        if (index < 0)
            return (EnemyID.Enemy1);
        if (index > (int)EnemyID.Enemy20)
            return (EnemyID.Enemy20);

        return ((EnemyID)index);
    }

    
    static public CharacterInfo GetItem(EnemyID id)
    {
        CharacterInfo retVal;
        if (ms_db.TryGetValue(id, out retVal))
        {
            // What a plum!
            return CharacterInfo.MakeCopyOf(retVal);
        }
        Debug.LogError("Enemy not found :" + id);
        return null;
    }
}
