/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\engines\ML Peerless + misc areas\Interred Grizzle\Questgiver\GrizzleQuest.cs
Lines of code: 79
***********************************************************/


using System;
using Server;
using Server.Mobiles;
using Server.Items;

namespace Server.Engines.Quests.Grizzle
{
	public class GrizzleQuest : QuestSystem
	{
		private static Type[] m_TypeReferenceTable = new Type[]
			{
				typeof( Grizzle.DontOfferConversation ),
				typeof( Grizzle.AcceptConversation ),
				typeof(Grizzle.NotDoneConversation),
				typeof( Grizzle.EndConversation )
			};

		public override Type[] TypeReferenceTable{ get{ return m_TypeReferenceTable; } }

		public override object Name
		{
			get
			{
				return "Cohenn Quest";
			}
		}

		public override object OfferMessage
		{
			get
			{
				return 
"You see a woman before you. She is probably younger than she looks but life here will age anyone. <br><br>She barely turns around but notices you: <br><br><i>Tell me you are here to help me!?</i><br><br>You tell her you have heard of tales of the Interred Grizzle.<br><br>She takes a deep breath and sizes you up. <br><Br><i>I can only help you with part of it and it's the easy part. You need to gather some items to prove you are worthy. <br><br>If you get my missing thesis notes, I will be honored to give you a chance to slay the Mighty Foe.</i>";
			}
		}

		public override TimeSpan RestartDelay{ get{ return TimeSpan.Zero; } }
		public override bool IsTutorial{ get{ return false; } }

		public override int Picture{ get{ return 0x15C9; } }


		public GrizzleQuest( PlayerMobile from ) : base( from )
		{
		}

		// Serialization
		public GrizzleQuest()
		{
		}

		public override void ChildDeserialize( GenericReader reader )
		{
			int version = reader.ReadEncodedInt();
		}

		public override void ChildSerialize( GenericWriter writer )
		{
			writer.WriteEncodedInt( (int) 0 ); // version
		}

		public override void Accept()
		{
			base.Accept();

			AddConversation( new AcceptConversation() );
		}

		public static void GiveRewardTo( PlayerMobile from)
		{
			GrizzleQuest qs = from.Quest as GrizzleQuest;
			if(qs==null)return; //this should not happen, but just to be safe
		
			int amt=0;
		
			amt += from.Backpack.GetAmount(typeof(CohennNote1))>0 ? 1 : 0;
			amt += from.Backpack.GetAmount(typeof(CohennNote2))>0 ? 1 : 0;
			amt += from.Backpack.GetAmount(typeof(CohennNote3))>0 ? 1 : 0;
			amt += from.Backpack.GetAmount(typeof(CohennNote4))>0 ? 1 : 0;
			amt += from.Backpack.GetAmount(typeof(CohennNote5))>0 ? 1 : 0;
			
			if(amt<5)
			{
			qs.AddConversation( new NotDoneConversation() );
			return;
			}
			
			//take items
			from.Backpack.ConsumeTotal(typeof(CohennNote1),1 );		
			from.Backpack.ConsumeTotal(typeof(CohennNote2),1 );		
			from.Backpack.ConsumeTotal(typeof(CohennNote3),1 );		
			from.Backpack.ConsumeTotal(typeof(CohennNote4),1 );		
			from.Backpack.ConsumeTotal(typeof(CohennNote5),1 );		
			
			
			//give reward
			from.GiveItem(new LibraryKey());
			from.SendMessage("You have been given the library key.  Place it on the table (by double clicking it) near the entrance");

			//end quest
			qs.Complete();			
		}
	}
}