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 either bought from or sold to NPC or PC merchants. /// public class Merchandise : LavishScriptObject { #region Constructor /// /// Constructor /// /// LS Object public Merchandise(LavishScriptObject copy) : base(copy) { } #endregion #region Members /// /// Returns FALSE if the "not for sale" checkbox/flag is selected for this item /// public bool IsForSale { get { Trace.WriteLine(String.Format("Merchandise:IsForSale")); return this.GetBoolFromLSO("IsForSale"); } } /// /// Merchandise Level /// public int Level { get { Trace.WriteLine(String.Format("Merchandise:Level")); return this.GetIntFromLSO("Level"); } } /// /// Link ID /// public int LinkID { get { Trace.WriteLine(String.Format("Merchandise:LinkID")); return this.GetIntFromLSO("LinkID"); } } /// /// For stackable items, this number will be the maximum number that a stack can hold. /// Therefore, it is the maximum quantity of said item that can be bought at once. /// public int MaxQuantity { get { Trace.WriteLine(String.Format("Merchandise:MaxQuantity")); return this.GetIntFromLSO("MaxQuantity"); } } /// /// Cache of Name /// private string _name; /// /// Name /// public string Name { get { Trace.WriteLine(String.Format("Merchandise:Name")); return _name ?? (_name = this.GetStringFromLSO("Name")); } } /// /// The price of the item in silver pieces. /// public float Price { get { Trace.WriteLine(String.Format("Merchandise:Price")); return this.GetFloatFromLSO("Price"); } } /// /// If the item has a status cost, then the format of this string will be #SP,#p,#g,#s,#c. /// Otherwise, the format will be #p,#g,#s,#c /// public string PriceString { get { Trace.WriteLine(String.Format("Merchandise:PriceString")); return GetMember("PriceString"); } } /// /// Quantity Available /// public int Quantity { get { Trace.WriteLine(String.Format("Merchandise:Quantity")); return this.GetIntFromLSO("Quantity"); } } /// /// Status Cost /// public int StatusCost { get { Trace.WriteLine(String.Format("Merchandise:StatusCost")); return this.GetIntFromLSO("StatusCost"); } } /// /// 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("Merchandise:ToLink")); return this.GetStringFromLSO("ToLink"); } } #endregion #region Methods /// /// Will try to buy 1 of an item /// /// call success public bool Buy() { Trace.WriteLine(String.Format("Merchandise:Buy()")); return this.ExecuteMethod("Buy"); } /// /// Will try to buy the quantity of an item. /// Quantity only works for items that are stackable. /// If you try to buy more than MaxQuantity, Quantity will default to MaxQuantity. /// /// quantity /// call success public bool Buy(int quantity) { Trace.WriteLine(String.Format("Merchandise: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"); } /// /// This datatype method is used to set a piece of store merchandise to be 'for sale'. /// Please note that you should test to see if the merchandise's bool IsForSale is /// already set or not before using this method in order to avoid sending bogus messages /// to the server asking to set an item for sale that's already 'for sale'. /// /// call success public bool ListForSale() { Trace.WriteLine(String.Format("Merchandise:ListForSale")); return this.ExecuteMethod("ListForSale"); } /// /// Will try to buy 1 of the item /// /// call success public bool Sell() { Trace.WriteLine(String.Format("Merchandise:Sell")); return this.ExecuteMethod("Sell"); } /// /// Will try to sell the quantity of the item. /// If you try sell more than the current quantity of that stack, /// "Quantity#" will default to the current quantity of the stack. /// /// quantity /// call success public bool Sell(int quantity) { Trace.WriteLine(String.Format("Merchandise:Sell({0})", quantity.ToString(CultureInfo.InvariantCulture))); return ExecuteMethod("Sell", quantity.ToString(CultureInfo.InvariantCulture)); } /// /// This datatype method is used in conjunction with player stores in order to set the price of a piece of merchandise. /// The format is SetPrice[platinum,gold,silver,copper]. /// /// platinum /// gold /// silver /// copper /// public bool SetPrice(int platinum, int gold, int silver, int copper) { Trace.WriteLine(String.Format("Merchandise:SetPrice({0}, {1}, {2}, {3})", platinum.ToString(CultureInfo.InvariantCulture), gold.ToString(CultureInfo.InvariantCulture), silver.ToString(CultureInfo.InvariantCulture), copper.ToString(CultureInfo.InvariantCulture))); return this.ExecuteMethod("SetPrice", platinum.ToString(CultureInfo.InvariantCulture), gold.ToString(CultureInfo.InvariantCulture), silver.ToString(CultureInfo.InvariantCulture), copper.ToString(CultureInfo.InvariantCulture)); } /// /// This datatype method is used to unlist a piece of store merchandise from the market. /// Please note that you should test to see if the merchandise's bool IsForSale is already /// set or not before using this method in order to avoid sending bogus messages to the /// server asking to unlist an item that's not currently on the market in the first place. /// /// call success public bool UnListForSale() { Trace.WriteLine(String.Format("Merchandise:UnListForSale()")); return this.ExecuteMethod("UnListForSale"); } #endregion } }