/// <summary> /// What will the merchant buy this item for /// </summary> /// <param name="item">the item in question</param> /// <returns>the price, -1 indicates they wont buy it</returns> public int HaggleCheck(IInanimate item) { decimal value = -1; if (item != null) { IInanimateTemplate template = item.Template <IInanimateTemplate>(); if (WillPurchase.Any(merch => merch.Item.Id == item.TemplateId)) { DataStructure.Gaia.IEconomy theEconomy = CurrentLocation.CurrentZone.GetWorld().Macroeconomy; if (theEconomy != null) { DataStructure.Gaia.IEconomicBasis priceBasis = theEconomy.Bases.FirstOrDefault(basis => basis.ItemType.Id == item.TemplateId); if (priceBasis != null) { value = priceBasis.Basis * priceBasis.Adjustment; } else { value = theEconomy.MakeValuation(template); } foreach (IQuality quality in item.Qualities) { DataStructure.Gaia.IEconomicTrend trend = theEconomy.Trends.FirstOrDefault(trnd => trnd.Quality.Equals(quality.Name, StringComparison.InvariantCultureIgnoreCase)); if (trend != null) { value += trend.Basis * trend.Adjustment; } else { value += theEconomy.MakeValuation(template); } } decimal myAdjustments = 1; foreach (IMerchandise adjustment in WillPurchase.Where(merch => merch.Item.Id == item.TemplateId)) { if (string.IsNullOrWhiteSpace(adjustment.Quality) || item.Qualities.Any(quality => quality.Name.Equals(adjustment.Quality) && quality.Value.IsBetweenOrEqual(adjustment.QualityRange.Low, adjustment.QualityRange.High))) { myAdjustments += adjustment.MarkRate; } } value += value * myAdjustments; } } } return((int)Math.Truncate(value)); }
/// <summary> /// Indicates whether this is actually a merchant who buys things /// </summary> /// <returns>if they buy things (but not if they have the money to do so)</returns> public bool DoIBuyThings() { return(WillPurchase != null && WillPurchase.Count() > 0); }