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 vendors within the game.
/// For the purposes of ISXEQ2, a vendor is any actor that is capable of selling and/or buying items.
///
public class Vendor : LavishScriptObject
{
#region Constructor
///
/// Constructor
///
/// LS Object
public Vendor(LavishScriptObject copy) : base(copy) { }
#endregion
#region Members
///
/// This member returns a 'consignment' object that the broker is currently capable of selling (on the current 'Search
/// Page' only) based upon the index of its location within the array.
///
/// index
/// Consignment
public Consignment Broker(int index)
{
Trace.WriteLine(String.Format("Vendor:Broker({0})", index.ToString(CultureInfo.InvariantCulture)));
return new Consignment(this.GetMember("Broker", index.ToString(CultureInfo.InvariantCulture)));
}
///
/// This member returns a 'consignment' object that the broker is currently capable of selling (on the current 'Search
/// Page' only) based upon a substring of the item's name.
///
/// name
/// Consignment
public Consignment Broker(string name)
{
Trace.WriteLine(String.Format("Vendor:Broker({0})", name));
return new Consignment(this.GetMember("Broker", name));
}
///
/// Percent commission. Brokers Only. Non-Brokers will be zero.
///
public float Commission
{
get
{
Trace.WriteLine(String.Format("Vendor:Commission"));
return this.GetFloatFromLSO("Commission");
}
}
///
/// Current Search Page. Brokers only.
///
public int CurrentSearchPage
{
get
{
Trace.WriteLine(String.Format("Vendor:CurrentSearchPage"));
return this.GetIntFromLSO("CurrentSearchPage");
}
}
///
/// Cache of IsBroker
///
private bool? _isBroker;
///
/// Returns TRUE if the vendor is a broker (PC)
///
public bool IsBroker
{
get
{
Trace.WriteLine(String.Format("Vendor:IsBroker"));
if(!_isBroker.HasValue)
_isBroker = this.GetBoolFromLSO("IsBroker");
return _isBroker.Value;
}
}
///
/// Cache of IsMerchant
///
private bool? _isMerchant;
///
/// Returns TRUE if the vendor is a merchant (NPC)
///
public bool IsMerchant
{
get
{
Trace.WriteLine(String.Format("Vendor:IsMerchant"));
if(!_isMerchant.HasValue)
_isMerchant = this.GetBoolFromLSO("IsMerchant");
return _isMerchant.Value;
}
}
///
/// This member returns either a 'consignment' or 'merchandise' object that the
/// broker or vendor is currently capable of selling (on the current 'Search Page'
/// only, for broker) based upon the index. Only the members and methods they have
/// in common are available.
///
/// index
/// call success
public VendorItem Item(int index)
{
Trace.WriteLine(String.Format("Vendor:Item({0})", index.ToString(CultureInfo.InvariantCulture)));
return new VendorItem(this.GetMember("Item", index.ToString(CultureInfo.InvariantCulture)));
}
///
/// This member returns either a 'consignment' or 'merchandise' object that the
/// broker or vendor is currently capable of selling (on the current 'Search Page'
/// only, for broker) based upon an exact match of the item name. Only the members
/// and methods they have in common are available.
///
/// name
/// call success
public VendorItem Item(string name)
{
Trace.WriteLine(String.Format("Vendor:Item({0})", name));
return new VendorItem(this.GetMember("Item", name));
}
///
/// Number of items for sale (use with Broker or Merchant 1 to NumItemsForSale)
///
public int NumItemsForSale
{
get
{
Trace.WriteLine(String.Format("Vendor:NumItemsForSale"));
return this.GetIntFromLSO("NumItemsForSale");
}
}
///
/// This member returns a 'merchandise' object that the merchant is currently capable of selling
/// (on the current 'Search Page' only) based upon the index of its location within the array.
///
/// index
/// Merchandise
public Merchandise Merchant(int index)
{
Trace.WriteLine(String.Format("Vendor:Merchant({0})", index.ToString(CultureInfo.InvariantCulture)));
return new Merchandise(this.GetMember("Merchant", index.ToString(CultureInfo.InvariantCulture)));
}
///
/// This member returns a 'merchandise' object that the merchant is currently capable of selling
/// (on the current 'Search Page' only) based upon a substring of the item's name.
///
/// name
/// Merchandise
public Merchandise Merchant(string name)
{
Trace.WriteLine(String.Format("Vendor:Merchant({0})", name));
return new Merchandise(this.GetMember("Merchant", name));
}
///
/// Total Number of Search Pages (Broker Only)
///
public int TotalSearchPages
{
get
{
Trace.WriteLine(String.Format("Vendor:TotalSearchPages"));
return this.GetIntFromLSO("TotalSearchPages");
}
}
#endregion
#region Methods
///
/// Selects the indicated page between 1 and TotalSearchPages (Broker Only)
///
/// page
/// call success
public bool GoToSearchPage(int page)
{
Trace.WriteLine(String.Format("Vendor:GoToSearchPage({0})", page.ToString(CultureInfo.InvariantCulture)));
return this.ExecuteMethod("GoToSearchPage", page.ToString(CultureInfo.InvariantCulture));
}
#endregion
}
}