/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\items\resources\AnguimentisMind.cs
Lines of code: 590
***********************************************************/


using System;
using System.Collections;
using Server.Network;
using Server.Items;
using Server.Targeting;

namespace Server.Items
{

	public class AnguimentisMind : Item
	{
		public bool RedoSelect = true;
		public virtual int Bonus{ get{ return 50; } }
		public virtual StatType Type{ get{ return StatType.Str; } }

		public override string DefaultName
		{
			get { return "Anguimentis' Mind"; }
		}

		[Constructable]
		public AnguimentisMind() : base( 7408 )
		{
		Hue = 91;
		}
		
		public AnguimentisMind( Serial serial ) : base( serial )
		{
		}

		public override void OnDoubleClick( Mobile from )
		{
			if ( !IsChildOf( from.Backpack ) )
			{
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			}
			else 
			{
				if ( !m_Table.Contains( from ) )
				{	
					SkillMod mod;
				
				for (int i = 0; i < 100; i++)
				{
				switch ( Utility.Random( 55 ) )
				{
					default:
					case 0: 
					if ( from.Skills[SkillName.Magery].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Magery, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 1: 
					if ( from.Skills[SkillName.MagicResist].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.MagicResist, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 2: 
					if ( from.Skills[SkillName.Tactics].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Tactics, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 3: 
					if ( from.Skills[SkillName.EvalInt].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.EvalInt, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 4: 
					if ( from.Skills[SkillName.SpiritSpeak].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.SpiritSpeak, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 5: 
					if ( from.Skills[SkillName.Tailoring].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Tailoring, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 6: 
					if ( from.Skills[SkillName.Anatomy].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Anatomy, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 7: 
					if ( from.Skills[SkillName.Necromancy].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Necromancy, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 8: 
					if ( from.Skills[SkillName.Meditation].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Meditation, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 9: 
					if ( from.Skills[SkillName.AnimalTaming].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.AnimalTaming, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 10: 
					if ( from.Skills[SkillName.Healing].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Healing, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 11: 
					if ( from.Skills[SkillName.AnimalLore].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.AnimalLore, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 12: 
					if ( from.Skills[SkillName.Blacksmith].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Blacksmith, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 13: 
					if ( from.Skills[SkillName.Swords].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Swords, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 14: 
					if ( from.Skills[SkillName.Veterinary].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Veterinary, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 15: 
					if ( from.Skills[SkillName.Musicianship].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Musicianship, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 16: 
					if ( from.Skills[SkillName.Archery].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Archery, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 17: 
					if ( from.Skills[SkillName.Inscribe].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Inscribe, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 18: 
					if ( from.Skills[SkillName.Hiding].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Hiding, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 19: 
					if ( from.Skills[SkillName.Peacemaking].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Peacemaking, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 20: 
					if ( from.Skills[SkillName.Chivalry].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Chivalry, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 21: 
					if ( from.Skills[SkillName.Mining].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Mining, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 22: 
					if ( from.Skills[SkillName.Parry].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Parry, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 23: 
					if ( from.Skills[SkillName.Tinkering].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Tinkering, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 24: 
					if ( from.Skills[SkillName.Focus].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Focus, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 25: 
					if ( from.Skills[SkillName.Fencing].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Fencing, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 26: 
					if ( from.Skills[SkillName.Poisoning].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Poisoning, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 27: 
					if ( from.Skills[SkillName.Wrestling].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Wrestling, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 28: 
					if ( from.Skills[SkillName.Ninjitsu].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Ninjitsu, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 29: 
					if ( from.Skills[SkillName.Stealth].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Stealth, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 30: 
					if ( from.Skills[SkillName.Stealing].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Stealing, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 31: 
					if ( from.Skills[SkillName.Discordance].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Discordance, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 32: 
					if ( from.Skills[SkillName.Carpentry].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Carpentry, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 33: 
					if ( from.Skills[SkillName.Bushido].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Bushido, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 34: 
					if ( from.Skills[SkillName.Lockpicking].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Lockpicking, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 35: 
					if ( from.Skills[SkillName.Macing].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Macing, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 36: 
					if ( from.Skills[SkillName.Fletching].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Fletching, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 37: 
					if ( from.Skills[SkillName.Alchemy].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Alchemy, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 38: 
					if ( from.Skills[SkillName.Cartography].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Cartography, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 39: 
					if ( from.Skills[SkillName.DetectHidden].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.DetectHidden, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 40: 
					if ( from.Skills[SkillName.Lumberjacking].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Lumberjacking, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 41: 
					if ( from.Skills[SkillName.RemoveTrap].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.RemoveTrap, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 42: 
					if ( from.Skills[SkillName.Provocation].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Provocation, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 43: 
					if ( from.Skills[SkillName.Snooping].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Snooping, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 44: 
					if ( from.Skills[SkillName.ArmsLore].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.ArmsLore, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 45: 
					if ( from.Skills[SkillName.Fishing].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Fishing, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 46: 
					if ( from.Skills[SkillName.Tracking].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Tracking, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 47: 
					if ( from.Skills[SkillName.Camping].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Camping, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 48: 
					if ( from.Skills[SkillName.Begging].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Begging, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 49: 
					if ( from.Skills[SkillName.Cooking].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Cooking, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 50: 
					if ( from.Skills[SkillName.Forensics].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Forensics, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 51: 
					if ( from.Skills[SkillName.ItemID].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.ItemID, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 52: 
					if ( from.Skills[SkillName.Spellweaving].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Spellweaving, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 53: 
					if ( from.Skills[SkillName.TasteID].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.TasteID, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
					case 54: 
					if ( from.Skills[SkillName.Herding].Base == 0 )
					{
						mod = new DefaultSkillMod( SkillName.Herding, true, 100.0 ); 
						from.AddSkillMod( mod );
						m_Table[from] = mod;
						RedoSelect = false;
					}
					break;
				} 	
					if ( !RedoSelect) break;
				}
					if (RedoSelect)
					{		
						from.SendMessage( "Your are already too knowledgeable, try again later" );
						//mod = 0;
					}
					else
					{
						RedoSelect = true;
						from.SendMessage( "You feel knowledgeable" );
						from.FixedParticles( 0x375A, 1, 17, 9919, 91, 7, EffectLayer.Waist );
						from.PlaySound( 0x1F7 );
					
						TimeSpan duration = TimeSpan.FromSeconds( 20.0 ); 
						Timer.DelayCall( duration, new TimerStateCallback( EffectExpire_Callback ), from);
						//mod = 0;
						Delete();
					}
				}
				else 
				{
					from.SendMessage( "You cannot gain another skill until this one expires" );
				}
			}	
		}

		private static Hashtable m_Table = new Hashtable();

		private static void EffectExpire_Callback( object state )
		{
			CheckEffect( (Mobile)state );
		}

		public static bool CheckEffect( Mobile m )
		{
			SkillMod mod = (SkillMod)m_Table[m];

			if ( mod == null )
				return false;

			m.SendMessage( "The mind's effect wears off" );
			m.FixedParticles( 0x375A, 1, 17, 9919, 91, 7, EffectLayer.Waist );
			m.PlaySound( 0xF8 );
			m_Table.Remove( m );
			mod.Remove();

			return true;
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			if ( Hue == 376 )
				Hue = 33;
		}
	}
}