/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Sep-24-2011 10:26:44pm
Filepath: scripts\events and scenarios\misc\CakeStatue.cs
Lines of code: 60

Description: 

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


using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Mobiles;

namespace Server.Items
{

	public class CakeStatue : Item
	{
		//Hashtable eggRecords = new Hashtable();
		//Hashtable eggPrizes = new Hashtable();
		
		Dictionary<int, int> eggRecords = new Dictionary<int, int>();
		Dictionary<int, int> eggPrizes = new Dictionary<int, int>();
		
		Dictionary<int, int> accounts = new Dictionary<int, int>();
		
		//HashSet<int> oddNumbers = new HashSet<int>();

		
		//Hashtable eggPrizes = new Hashtable();
		//Hashtable prizeSlot = (Hashtable)eggPrizes[columnName];
		//return hColumn.ContainsKey(codeValue);
		
		[Constructable]
		public CakeStatue() : base(4825)
		{
			Name = "Double Click to Receive a Birthday Cake";
			Hue = 1153;
			Movable=false;
		}
		
		public override void OnDoubleClick( Mobile from )
		{
		if(!from.InRange(this,1))return;
		
		//int whiteAmt=0, goldAmt=0;
		//int points;
		
		//whiteAmt = from.Backpack.GetAmount(typeof(WhiteEgg));
		//goldAmt = from.Backpack.GetAmount(typeof(GoldenEgg));
		/*if(whiteAmt<=0 && goldAmt<=0) {
			from.SendMessage(200, "You have {0} points. Bring your Easter eggs here and double click the statue",((eggRecords.ContainsKey(from.Serial)) ? eggRecords[from.Serial] : 0));
			return;
		}*/
	
		Modify();
		//points = whiteAmt + (goldAmt * 5);
		
		//if we made it here, we have all the components, so we can consume them		
		//
		//from.Backpack.ConsumeTotal(typeof(WhiteEgg),whiteAmt );
		//from.Backpack.ConsumeTotal(typeof(GoldenEgg),goldAmt );

		
		if (accounts.ContainsKey(from.Account.Id))
			from.SendMessage(33, "You have already received a birthday cake");
		else {
			from.SendMessage(200, "Happy 14th birthday Ultima Online!");
			from.AddToBackpack(new AnniversaryCake());
			accounts.Add(from.Account.Id, 1);
		}
		
		/*if (eggPrizes.ContainsKey(from.Serial)) {
			if((int)eggRecords[from.Serial] >= 10 && (int)eggPrizes[from.Serial] <= 10) {
				eggPrizes[from.Serial] = 25;
				from.SendMessage(200, "You have been given an Easter Basket as thanks");
				from.AddToBackpack(new EasterBasket());
			}
			
			if((int)eggRecords[from.Serial] >= 11) {
				from.SendMessage(33, "You already have your Easter Basket. You cannot collect anymore prizes");  
			}
			
			for (int i = 1; i < 100; i++) {
				if((int)eggRecords[from.Serial] >= (i*25) && (int)eggPrizes[from.Serial] <= (i*25)) {
					//from.SendMessage(200, "A reward and some gold have been placed in your pack");           					
					//from.AddToBackpack(new randomartydeed());
					//from.AddToBackpack(new BankCheck(250000));
					eggPrizes[from.Serial] = (i+1)*25;
				}
			}
		}
		else {
			from.SendMessage(33, "Egg Prize Error");
		}
		
		from.SendMessage(200, "You turn in your eggs, you now have " + eggRecords[from.Serial] + " points");
	

		//Check for null account
		//Store in a hash set
		from.SendMessage(200, "Account: " + from.Account.Id);*/
		}		
		
		
		public CakeStatue( Serial serial ) : base( serial )
		{
		}
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 );
			
			
			//write Account IDs:
			
			writer.Write((int)accounts.Count); 
			
			foreach(KeyValuePair<int, int> kvp in accounts)
			{	
				writer.Write((int)kvp.Key);
			}
			
			
		}
		
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();			
			
			int tmpcount, tmpkey; //temp vars for reading eggRecords and eggPrizes			
			
			//read accounts:
			tmpcount = reader.ReadInt();			
			for(int i=0;i<tmpcount;i++)
			{
				tmpkey = reader.ReadInt();
				
				if (accounts.ContainsKey(tmpkey)) accounts[tmpkey] = 1;
				else accounts.Add(tmpkey, 1);
			}
			
		}
	}
}