using System;
using System.Diagnostics;
using System.Globalization;
using LavishScriptAPI;
using MRBot.IsxEq2.Helpers;
namespace MRBot.IsxEq2.InventoryConsignment
{
///
/// This class is a hybrid of the common members and methods of the Merchandise
/// and Consignment DataTypes to allow the Item() Member of Vendor to work
///
public class VendorItem : LavishScriptObject
{
#region Constructor
///
/// Constructor
///
/// LS Object
public VendorItem(LavishScriptObject copy) : base(copy) {}
#endregion
#region Members
///
/// Level
///
public int Level
{
get
{
Trace.WriteLine(String.Format("VendorItem:Level"));
return this.GetIntFromLSO("Level");
}
}
///
/// Link ID
///
public int LinkID
{
get
{
Trace.WriteLine(String.Format("VendorItem:LinkID"));
return this.GetIntFromLSO("LinkID");
}
}
///
/// Cache of Name
///
private string _name;
///
/// Name
///
public string Name
{
get
{
Trace.WriteLine(String.Format("VendorItem:Name"));
return _name ?? (_name = this.GetStringFromLSO("Name"));
}
}
///
/// The price of the item in silver pieces.
///
public float Price
{
get
{
Trace.WriteLine(String.Format("VendorItem:Price"));
return this.GetFloatFromLSO("Price");
}
}
///
/// Quantity Available
///
public int Quantity
{
get
{
Trace.WriteLine(String.Format("VendorItem:Quantity"));
return this.GetIntFromLSO("Quantity");
}
}
///
/// This will recreate the actual link used with in game chat channels (used typically with eq2echo or eq2execute).
///
public string ToLink
{
get
{
Trace.WriteLine(String.Format("VendorItem:ToLink"));
return this.GetStringFromLSO("ToLink");
}
}
#endregion
#region Method
///
/// Will try to buy 1 of an item
///
/// call success
public bool Buy()
{
Trace.WriteLine(String.Format("VendorItem:Buy()"));
return this.ExecuteMethod("Buy");
}
///
/// Will try to buy the quantity of an item.
/// Quantity only works for items that are stackable.
/// Tf you try to buy more than a stack can hold, Quantity will default to max.
///
/// quantity
/// call success
public bool Buy(int quantity)
{
Trace.WriteLine(String.Format("VendorItem:Buy({0})", quantity.ToString(CultureInfo.InvariantCulture)));
return ExecuteMethod("Buy", quantity.ToString(CultureInfo.InvariantCulture));
}
///
/// This brings up the 'examine window' for the given item.
///
/// call success
public bool Examine()
{
Trace.WriteLine(String.Format("Merchandise:Examine()"));
return this.ExecuteMethod("Examine");
}
#endregion
}
}