/// <summary> /// Execute a sale /// </summary> /// <param name="item">the item in question</param> /// <param name="price">the sale price</param> /// <returns>error or blank</returns> public string Instruct(IMobile customer, string qualityName, int level, int price) { string returnString = string.Empty; if (customer == null) { return("Invalid customer"); } IQuality quality = TeachableProficencies.FirstOrDefault(qual => qual.Name.Equals(qualityName, StringComparison.InvariantCultureIgnoreCase) && qual.Value > level); if (quality == null) { return("I can't teach that proficency to you."); } int customerWallet = customer.GetQuality("Bells"); if (customerWallet < price) { return("Insufficient Funds."); } customer.SetQuality(-1 * price, "Bells", true); customer.SetQuality(1, quality.Name, true); return(returnString); }
/// <summary> /// Price check on teaching qualities /// </summary> /// <param name="name">The name of the quality</param> /// <param name="level">The level to teach to</param> /// <returns>the price, -1 indicates it wont be taught</returns> public int InstructionPriceCheck(string qualityName, int level) { decimal value = -1; IQuality quality = TeachableProficencies.FirstOrDefault(qual => qual.Name.Equals(qualityName, StringComparison.InvariantCultureIgnoreCase) && qual.Value > level); //If we need it in stock but don't have it it's sell price is invalid if (quality != null) { value = 5; //base price, needs to be a config TODO value *= level; } return((int)Math.Truncate(value)); }
/// <summary> /// Indicates whether this is actually a merchant or not who sells things /// </summary> /// <returns>if they sell things (but not if they have stock)</returns> public bool DoITeachThings() { return(TeachableProficencies != null && TeachableProficencies.Count() > 0); }