/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Jan-01-2012 10:08:52pm
Filepath: scripts\Engines\donation\DonationEntry.cs
Lines of code: 51

Description: 

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


using Server;
using Server.DataStorage;
using System;
using Server.Accounting;


//class to track a certain donation entry

namespace Server.DonationSystem
{
	public class DonationEntry
	{
		int m_id;
		string m_account;
		int m_amount;
		bool m_processed=false;
		bool m_processerror=false;
		
	
		public DonationEntry(int id,string account,int amount)
		{
			m_id=id;
			m_account=account;
			m_amount=amount;		
		}
		
		
		
		//adds points to account, if account is not found, it returns error
		public void Process()
		{
			if(m_processed)return;
			
			m_processed=true;			
			
			IAccount a = Accounts.GetAccount( m_account );
			
			if(a!=null && a is Account)
			{
				int togive=m_amount*DonationHandler.PointsPerDollar;
				((Account)a).DonationPoints=((Account)a).DonationPoints+togive;
				
				System.Debugger.Write("donationsystem",false,"Processed {0} dollars donated by {1}",m_amount,m_account);				
				
				//Check if any character from this account is online and send message:
				((Account)a).SendMessage(200,"As a thank you for your recent monetary donation to help support the server, you have been rewarded {0} donation points",togive);
			}
			else
			{				
				m_processerror=true;
				
				System.Debugger.Write("donationsystem",false,"Error processing {0} dollars donated by {1}, possible cause is the account was not found",m_amount,m_account);
			}
		}
	
		public int GetID()
		{
			return m_id;
		}
	
	
		public bool Processed()
		{
			return m_processed;
		}
	
	
		public bool ProcessError()
		{
			return m_processerror;
		}
	
	}



}