using UnityEngine;
using System.Collections.Generic;

/**
* Created by Chris Nail
*/
namespace com.triforce700.skill{
	
	public class Skill{

		public string Name{ get; set; }
		public int Level{ get; set; }
		public int TotalExperience{ get; set; }
		public List<Mastery> Masteries{ get; set; }

		public Skill(string name, string[] masteryList){
			Name = name;
			Level = 1;
			TotalExperience = 1;
			Masteries = new List<Mastery>();
			CreateMasteryList(masteryList);
		}

		public void CreateMasteryList(string[] list){
			foreach(string s in list){
				Masteries.Add(new Mastery(s));
			}
		}

		public int GetCurrentExperience(){
			return TotalExperience - GetLevelExperience(Level);
		}

		public static int GetLevelExperience(int level){
			return level * level * level;
		}

		public void AddExperience(int exp){
			TotalExperience += exp;
			while(TotalExperience > GetLevelExperience(Level + 1)){
				Level += 1;
			}
		}

		public bool HasMastery(string mastery){
			return Masteries.Contains(new Mastery(mastery));
		}

		public Mastery GetMastery(string mastery){
			int i = Masteries.IndexOf(new Mastery(mastery));
			return Masteries[i];
		}

		//Default Skills
		public static readonly Skill AlchemySkill = new Skill("Alchemy", new string[] {"Gathering", "Healing", "Poison"});
		//Alchemy Masteries: Gathering
		public static readonly Skill AthleticsSkill = new Skill("Athletics", new string[] {"Dodge", "Climb", "Jump", "Run"});
		//Athletic Masteries: Dodge, Climb, Jump, Roll, Run
		public static readonly Skill ArcherySkill = new Skill("Archery", new string[] { "Bow", "Crossbow", "Javelin"});
		//Archery Masteries: Bow, Crossbow, Javelin
		public static readonly Skill ConstructionSkill = new Skill("Construction", new string[] { "Masonry", "Metalwork", "Woodwork"});
		//Construction Masteries: Masonry, Metalwork, Woodwork
		public static readonly Skill CookingSkill = new Skill("Cooking", new string[]{ "Baking", "Grilling"});
		//Cooking Masteries: Baking, Grilling
		public static readonly Skill DeceptionSkill = new Skill("Deception", new string[] { "Bluff", "Conceal", "Disguise", "Steal", "Stealth"});
		//Deception Masteries: Bluff, Conceal, Disguise, Steal, Stealth
		public static readonly Skill DeviceSkill = new Skill("Device", new string[] { "Lockpick", "Trap"});
		//Device Masteries: Lockpick, Trap
		public static readonly Skill FabricationSkill = new Skill("Smithing", new string[] { "Equipment", "Blade Parts", "Gun Parts", "Smelting"});
		//Fabrication Masteries: Carbonization, Logging, Smelting
		public static readonly Skill FirearmSkill = new Skill("Gun", new string[] { "Gauss", "Laser", "Plasma" });
		//Firearm Masteries: Pistol, Rifle, Shotgun
		public static readonly Skill GuardSkill = new Skill("Guard", new string[] { "Armor", "Shield"});
		//Guard Masteries: Armor, Parry, Shield
		public static readonly Skill MagicSkill = new Skill("Magic", new string[] { "Alteration", "Destruction", "Illusion", "Recovery", "Summon"});
		//Magic Masteries: Alteration, Destruction, Illusion, Recovery, Summon
		public static readonly Skill MeleeSkill = new Skill("Melee", new string[] { "Fist", "Fusionblade" });
		//Melee Masteries: Axe, Fist, Hammer, Knife, Polearm, Straight Sword, Thrusting Sword
		public static readonly Skill MiningSkill = new Skill("Mining", new string[] { "Dig", "Drill", "Explosive"});
		//Mining Masteries: Dig, Drill
		public static readonly Skill PsionicSkill = new Skill("Psionic", new string[] { "ESP", "Telepathy", "Kinesis"});
		//Psionic Masteries: ESP, Telepathy, Kinesis
		public static readonly Skill RhetoricSkill = new Skill("Rhetoric", new string[] { "Barter", "Diplomacy", "Intimidate"});
        //Rhetoric Masteries: Barter, Diplomacy, Intimidate

        public static readonly Skill[] DEFAULT_SKILLS = {AthleticsSkill, ArcherySkill, BladeSkill, BluntSkill, ConstructionSkill,
            CookingSkill, DeceptionSkill, DeviceSkill, FabricationSkill, FirearmSkill, GuardSkill, MagicSkill, MiningSkill, PsionicSkill, RhetoricSkill};
	}

}