using System; using System.Diagnostics; using System.Globalization; using LavishScriptAPI; using MRBot.IsxEq2.Helpers; namespace MRBot.IsxEq2.InventoryConsignment { /// /// This DataType includes all of the data available to ISXEQ2 that is related to items that can be bought from brokers. /// public class Consignment : LavishScriptObject { #region Constructor /// /// Constructor /// /// LS Object public Consignment(LavishScriptObject copy) : base(copy) { } #endregion #region Members /// /// The price of the item, without broker commission, in silver pieces. /// public float BasePrice { get { Trace.WriteLine(String.Format("Consignment:BasePrice")); return this.GetFloatFromLSO("BasePrice"); } } /// /// The price of the item, without broker commission, in the following format: #p,#g,#s,#c /// public string BasePriceString { get { Trace.WriteLine(String.Format("Consignment:BasePriceString")); return this.GetStringFromLSO("BasePriceString"); } } /// /// Returns TRUE is the item is listed /// public bool IsListed { get { Trace.WriteLine(String.Format("Consignment:IsListed")); return this.GetBoolFromLSO("IsListed"); } } /// /// Cache of Level /// private int? _level; /// /// Level of the consignment /// public int Level { get { Trace.WriteLine(String.Format("Consignment:Level")); if(!_level.HasValue) _level = this.GetIntFromLSO("Level"); return _level.Value; } } /// /// Link ID /// public int LinkID { get { Trace.WriteLine(String.Format("Consignment:LinkID")); return this.GetIntFromLSO("LinkID"); } } /// /// Possible values: "Qeynos" "Freeport" "Kelethin" "Haven" "Neriak" (or "Unknown" which should not be possible) /// public string Market { get { Trace.WriteLine(String.Format("Consignment:Market")); return this.GetStringFromLSO("Market"); } } /// /// Cache of Name /// private string _name; /// /// Consignment name /// public string Name { get { Trace.WriteLine(String.Format("Consignment:Name")); return _name ?? (_name = this.GetStringFromLSO("Name")); } } /// /// The price of the item, including broker commission, in silver pieces. /// public float Price { get { Trace.WriteLine(String.Format("Consignment:Price")); return this.GetFloatFromLSO("Price"); } } /// /// Item quantity in consignment /// public int Quantity { get { Trace.WriteLine(String.Format("Consignment:Quantity")); return this.GetIntFromLSO("Quantity"); } } /// /// Consignment Serial Number /// public long SerialNumber { get { Trace.WriteLine(String.Format("Consignment:SerialNumber")); return this.GetInt64FromLSO("SerialNumber"); } } /// /// 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("Consignment:ToLink")); return this.GetStringFromLSO("ToLink"); } } /// /// Cache of Value /// private float? _value; /// /// This is the price (in silver pieces) that an NPC merchant would buy this item from you. /// public float Value { get { Trace.WriteLine(String.Format("Consignment:Value")); if(!_value.HasValue) _value = this.GetFloatFromLSO("Value"); return _value.Value; } } #endregion #region Methods /// /// Buys 1 of the items in consignment /// /// call success public bool Buy() { Trace.WriteLine(String.Format("Consignment:Buy()")); return this.ExecuteMethod("Buy"); } /// /// Buys the quantity specified from the consignment. /// If # is specified, it is assumed to be the quantity of items to buy. /// If the value is large, it will buy as many as are in the selected stack. /// /// quantity /// call success public bool Buy(int quantity) { Trace.WriteLine(String.Format("Consignment:Buy({0})", quantity.ToString(CultureInfo.InvariantCulture))); return this.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("Consignment:Examine()")); return this.ExecuteMethod("Examine"); } /// /// Lists any item for sale that is currently in your consignment listing. /// /// call success public bool List() { Trace.WriteLine(String.Format("Consignment:List()")); return this.ExecuteMethod("List"); } /// /// Removes a consignment item from the vendor and places it in your inventory. /// /// public bool Remove() { Trace.WriteLine(String.Format("Consignment:Remove()")); return this.ExecuteMethod("Remove"); } /// /// Removes the quantity of a consignment item from the vendor and places it in your inventory. /// /// quantity /// call success public bool Remove(int quantity) { Trace.WriteLine(String.Format("Consignment:Remove({0})", quantity.ToString(CultureInfo.InvariantCulture))); return this.ExecuteMethod("Remove", Quantity.ToString(CultureInfo.InvariantCulture)); } /// /// Sets the price of any consignment item that is currently in your consignment listing. /// The price is one value in silver pieces and it CAN be a float value (eg, 1.20 == 1 silver, 20 copper). /// /// price in silver as float /// call success public bool SetPrice(float price) { Trace.WriteLine(String.Format("Consignment:SetPrice({0})", price.ToString(CultureInfo.InvariantCulture))); return this.ExecuteMethod("SetPrice", price.ToString(CultureInfo.InvariantCulture)); } /// /// Sets the price of any consignment item that is currently in your consignment listing. /// The price is one value in silver pieces. /// /// price in silver /// call success public bool SetPrice(int price) { Trace.WriteLine(String.Format("Consignment:SetPrice({0})", price.ToString(CultureInfo.InvariantCulture))); return this.ExecuteMethod("SetPrice", price.ToString(CultureInfo.InvariantCulture)); } /// /// Unlists any consignment item that is currently for sale. /// /// call success public bool Unlist() { Trace.WriteLine(String.Format("Consignment:Unlist()")); return this.ExecuteMethod("Unlist"); } #endregion } }