using System;
using System.Diagnostics;
using System.Globalization;
using LavishScriptAPI;
using MRBot.IsxEq2.Helpers;
using MRBot.IsxEq2.InventoryConsignment;
namespace MRBot.IsxEq2.Utility
{
///
/// This DataType includes all of the data available to ISXEQ2 that is related to an individual email
///
public class EQ2Mail : LavishScriptObject
{
#region Constructor
///
/// Constructor
///
/// LS Object
public EQ2Mail(LavishScriptObject copy) : base(copy) { }
#endregion
#region Members
///
/// Cache of Body
///
private string _body;
///
/// The body of the email
///
public string Body
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:Body"));
return _body ?? (_body = this.GetStringFromLSO("Body"));
}
}
///
/// Cache of Copper
///
private int? _copper;
///
/// Amount of copper attached to the email. Only works if mail is opened or composing.
///
public int Copper
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:Copper"));
if(!_copper.HasValue)
_copper = this.GetIntFromLSO("Copper");
return _copper.Value;
}
}
///
/// Should return the item datatype for the attachment
///
public Item Gift
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:Gift"));
return new Item(this.GetMember("Gift"));
}
}
///
/// Cache of Gold
///
private int? _gold;
///
/// Amount of gold attached to the email. Only works if mail is opened or composing.
///
public int Gold
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:Gold"));
if(!_gold.HasValue)
_gold = this.GetIntFromLSO("Gold");
return _gold.Value;
}
}
///
/// Cache of ID
///
private int? _iD;
///
/// Mail ID
///
public int ID
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:ID"));
if(!_iD.HasValue)
_iD = this.GetIntFromLSO("ID");
return _iD.Value;
}
}
///
/// Cache of Platinum
///
private int? _platinum;
///
/// Amount of platinum attached to the email. Only works if mail is opened or composing.
///
public int Platinum
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:Platinum"));
if(!_platinum.HasValue)
_platinum = this.GetIntFromLSO("Platinum");
return _platinum.Value;
}
}
///
/// Cache of recipient
///
private string _recipient;
///
/// Name of the recipient
///
public string Recipient
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:Recipient"));
return _recipient ?? (_recipient = this.GetStringFromLSO("Recipient"));
}
}
///
/// Cache of Sender
///
private string _sender;
///
/// Returns the name of the sender
///
public string Sender
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:Sender"));
return _sender ?? (_sender = this.GetStringFromLSO("Sender"));
}
}
///
/// Cache of Silver
///
private int? _silver;
///
/// Amount of silver attached to the email. Only works if mail is opened or composing.
///
public int Silver
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:Silver"));
if(!_silver.HasValue)
_silver = this.GetIntFromLSO("Silver");
return _silver.Value;
}
}
///
/// Cache of Subject
///
private string _subject;
///
/// The subject of the email
///
public string Subject
{
get
{
Trace.WriteLine(String.Format("EQ2Mail:Subject"));
return _subject ?? (_subject = this.GetStringFromLSO("Subject"));
}
}
#endregion
#region Methods
///
/// Adds copper to an email. Requires email to be composing.
///
/// the amount of ccopper to add
/// call success
public bool AddCopper(int value)
{
Trace.WriteLine(String.Format("EQ2Mail:AddCopper({0})", value.ToString(CultureInfo.InvariantCulture)));
return this.ExecuteMethod("AddCopper", value.ToString(CultureInfo.InvariantCulture));
}
///
/// Add gold to an email. Requires email to be composing.
///
/// the amount of gold to add
/// call success
public bool AddGold(int value)
{
Trace.WriteLine(String.Format("EQ2Mail:AddGold({0})", value.ToString(CultureInfo.InvariantCulture)));
return this.ExecuteMethod("AddGold", value.ToString(CultureInfo.InvariantCulture));
}
///
/// Adds platinum to an email. Requires email to be composing.
///
/// the amount of platinum to add
/// call success
public bool AddPlatinum(int value)
{
Trace.WriteLine(String.Format("EQ2Mail:AddPlatinum({0})", value.ToString(CultureInfo.InvariantCulture)));
return this.ExecuteMethod("AddPlatinum", value.ToString(CultureInfo.InvariantCulture));
}
///
/// Adds silver to an email. Requires email to be composing.
///
/// the amount of silver to add
/// call success
public bool AddSilver(int value)
{
Trace.WriteLine(String.Format("EQ2Mail:AddSilver({0})", value.ToString(CultureInfo.InvariantCulture)));
return this.ExecuteMethod("AddSilver", value.ToString(CultureInfo.InvariantCulture));
}
///
/// Adds additional text to the body of an email. Requires email to be composing.
///
/// text to append
/// call success
public bool AppendBody(string text)
{
Trace.WriteLine(String.Format("EQ2Mail:AppendBody({0})", text));
return this.ExecuteMethod("AppendBody", text);
}
///
/// Adds an additional recipient to an email. Requires email to be composing.
///
/// text to append
/// call success
public bool AppendRecipient(string text)
{
Trace.WriteLine(String.Format("EQ2Mail:AppendRecipient({0})", text));
return this.ExecuteMethod("AppendRecipient", text);
}
///
/// Adds additional text to the subject of an email. Requires email to be composing.
///
/// text to append
/// call success
public bool AppendSubject(string text)
{
Trace.WriteLine(String.Format("EQ2Mail:AppendSubject({0})", text));
return this.ExecuteMethod("AppendSubject", text);
}
///
/// Cancels the email.
///
/// call success
public bool Cancel()
{
Trace.WriteLine(String.Format("EQ2Mail:Cancel()"));
return this.ExecuteMethod("Cancel");
}
///
/// Deletes the email. Does not require the email to be opened or composing.
///
/// call success
public bool Delete()
{
Trace.WriteLine(String.Format("EQ2Mail:Delete()"));
return this.ExecuteMethod("Delete");
}
///
/// Opens the email. Does not require the email to be opened or composing.
///
/// call success
public bool Open()
{
Trace.WriteLine(String.Format("EQ2Mail:Open()"));
return this.ExecuteMethod("Open");
}
///
/// Extracts the attached gift from the email. Does not require the email to be opened or composing.
///
/// call success
public bool ReceiveGifts()
{
Trace.WriteLine(String.Format("EQ2Mail:ReceiveGifts()"));
return this.ExecuteMethod("ReceiveGifts");
}
///
/// Removes copper from an email. Requires email to be composing.
///
/// the amount of copper to remove
/// call success
public bool RemoveCopper(int value)
{
Trace.WriteLine(String.Format("EQ2Mail:RemoveCopper({0})", value.ToString(CultureInfo.InvariantCulture)));
return this.ExecuteMethod("RemoveCopper", value.ToString(CultureInfo.InvariantCulture));
}
///
/// Removes the gift from an email. Requires email to be composing.
///
/// call success
public bool RemoveGift()
{
Trace.WriteLine(String.Format("EQ2Mail:RemoveGift()"));
return this.ExecuteMethod("RemoveGift");
}
///
/// Removes gold from an email. Requires email to be composing.
///
/// the amount of gold to remove
/// call success
public bool RemoveGold(int value)
{
Trace.WriteLine(String.Format("EQ2Mail:RemoveGold({0})", value.ToString(CultureInfo.InvariantCulture)));
return this.ExecuteMethod("RemoveGold", value.ToString(CultureInfo.InvariantCulture));
}
///
/// Removes platinum from an email. Requires email to be composing.
///
/// the amount of platinum to remove
/// call success
public bool RemovePlatinum(int value)
{
Trace.WriteLine(String.Format("EQ2Mail:RemovePlatinum({0})", value.ToString(CultureInfo.InvariantCulture)));
return this.ExecuteMethod("RemovePlatinum", value.ToString(CultureInfo.InvariantCulture));
}
///
/// Removes silver from an email. Requires email to be composing.
///
/// the amount of silver to remove
/// call success
public bool RemoveSilver(int value)
{
Trace.WriteLine(String.Format("EQ2Mail:RemoveSilver({0})", value.ToString(CultureInfo.InvariantCulture)));
return this.ExecuteMethod("RemoveSilver", value.ToString(CultureInfo.InvariantCulture));
}
///
/// Sends the email. Requires email to be composing.
///
/// call success
public bool Send()
{
Trace.WriteLine(String.Format("EQ2Mail:Send()"));
return this.ExecuteMethod("Send");
}
#endregion
}
}