/// <summary> /// Returns a deal that can be applied to the given purchase. /// Takes the name of the item for matching and the amount of purchases /// for checking activation. /// </summary> /// <param name="name">The name of the item that's looking for a special.</param> /// <param name="amount">The amount of the item that have been purchased so far.</param> /// <returns></returns> internal static Special GetMatchingDeal(string name, int amount) { Special special = new Special(); int i = Database.GetSpecialCount(); for (int j = 0; j < GetSpecialsCount(); j++) { Special item = Database.GetSpecialAtPosition(j); if (item.Match(name) && item.itemsNeededToFire <= amount) { special = item; break; } } return(special); }
/// <summary> /// Returns true if there is a deal that can be applied with the given /// purchase and the amount of items within said purchase. /// </summary> /// <param name="talliedItems"></param> /// <returns></returns> internal static bool TryGetMatchingDeal(string name, int amount) { bool hasDeal = false; int i = Database.GetSpecialCount(); for (int j = 0; j < i; j++) { Special item = Database.GetSpecialAtPosition(j); if (item.Match(name) && item.itemsNeededToFire <= amount || amount == -1) { hasDeal = true; break; } } return(hasDeal); }