/**********************************************************
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\Painted Caves\Grobu's Quest\Questgiver\GrobuQuest.cs
Lines of code: 72
***********************************************************/


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

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

		public override Type[] TypeReferenceTable{ get{ return m_TypeReferenceTable; } }
		
		public bool UserGotFur=false;

		public override object Name
		{
			get
			{
				return 1074684; //New Cloak (Quest Name)
			}
		}

		public override object OfferMessage
		{
			get
			{
				return 1074685; //Grobu's Quest message
			}
		}

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

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


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

		// Serialization
		public GrobuQuest()
		{
		}

		public override void ChildDeserialize( GenericReader reader )
		{
			int version = reader.ReadEncodedInt();
			
			if(version>=1)UserGotFur=reader.ReadBool();
		}

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

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

			AddConversation( new AcceptConversation() );
		}

		public static void GiveRewardTo( PlayerMobile from)
		{
			GrobuQuest qs = from.Quest as GrobuQuest;
			if(qs==null)return; //this should not happen, but just to be safe
		
			int amt=0;
		
			amt += from.Backpack.GetAmount(typeof(GrobusFur));
			
			if(amt<1)
			{
			qs.AddConversation( new NotDoneConversation() );
			return;
			}
			
			//take items
			from.Backpack.ConsumeTotal(typeof(GrobusFur),1 );		
			
			//give reward
			from.GiveItem(new CraftsmansSatchel());

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