/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Sep-25-2011 07:40:10pm
Filepath: scripts\Items\Misc\randomartydeed.cs
Lines of code: 64

Description: 

***********************************************************/


using System;
using Server.Items;

namespace Server.Items
{
	public class randomartydeed : Item
	{
	
		public override string DefaultName
		{
			get { return "A Random Artifact Deed"; }
		}

		[Constructable]
		public randomartydeed() : base( 5360 )
		{
			LootType = LootType.Blessed;
			Hue = 45;
		}
		


		public override void OnDoubleClick( Mobile from )
		{
			if ( !IsChildOf( from.Backpack ) ) // Make sure its in their pack
			{
				 from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			return;
			}		
		
		
		Item i =null;
		
		if(0.19>Utility.RandomDouble())i=Activator.CreateInstance( Misc.TreasuresOfTokuno.GreaterArtifacts[Utility.Random( Misc.TreasuresOfTokuno.GreaterArtifacts.Length )] ) as Item;
		else if(0.16>Utility.RandomDouble())i=Activator.CreateInstance( Mobiles.Paragon.Artifacts[Utility.Random( Mobiles.Paragon.Artifacts.Length )] ) as Item;
		else if(0.09>Utility.RandomDouble())i=Activator.CreateInstance( Misc.MlMartys.m_mlmartys[Utility.Random( Misc.MlMartys.m_mlmartys.Length )] ) as Item;
		else if(0.05>Utility.RandomDouble())i=Activator.CreateInstance( Misc.TreasuresOfFelucca.m_LesserArtifacts[Utility.Random( Misc.TreasuresOfFelucca.m_LesserArtifacts.Length )] ) as Item;
		else if(0.04>Utility.RandomDouble())i=Activator.CreateInstance( Server.Misc.OSI10Anniversary.artifacts[Utility.Random( Server.Misc.OSI10Anniversary.artifacts.Length )] ) as Item;
		else if(0.03>Utility.RandomDouble())i=Activator.CreateInstance( Misc.TreasuresOfFelucca.m_GreaterArtifacts[Utility.Random( Misc.TreasuresOfFelucca.m_GreaterArtifacts.Length )] ) as Item;
		else if(0.03>Utility.RandomDouble())i=Activator.CreateInstance( Server.Mobiles.DemonKnight.ArtifactRarity11[Utility.Random( Server.Mobiles.DemonKnight.ArtifactRarity11.Length )] ) as Item;
		else  i=Activator.CreateInstance( Server.Misc.TreasuresOfFelucca.m_LesserArtifacts[Utility.Random( Server.Misc.TreasuresOfFelucca.m_LesserArtifacts.Length )] ) as Item;		
		
		if(i==null)//this should not happen, but just in case
		{
		from.SendMessage("Error generating artifact");
		Console.WriteLine("Error generating artifact from arty deed ({0})",this.Serial);
		return;
		}
		

			
			
			if ( !from.AddToBackpack( i ) )
			{
			from.SendMessage( "Your bag is too full to use this!" );
			i.Delete(); 
			}
			else
			{
			from.SendMessage( "For your valor in double clicking this deed, a special artifact has been bestowed on you." );
			this.Delete();
			}
	
			
		}

		public randomartydeed( Serial serial ) : base( serial )
		{
		}

		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();
		}
	}
}