Discount

Purpose

Sometimes, it is desirable to discount menu item costs for certain people. This makes the fanclub into a loyalty program of sorts, and can be a way of "paying" moderators for their volunteered assistance.

Use

Two properties fanclub and moderator are the respective discounts. This should be treated as a discount percentage between 0~1. So for a discount of 10%, use 0.1.

To calculate the discounted price, pass into apply() both the item to apply, and a relevant object which contains user properties. It is important to understand this function returns only the price after discount, not a whole Menu Item object. This is a performance consideration, as creating that many new objects every time someone tips rapidly overworks a garbage collector, which will present itself as delays in response time, stalled timers, and more.

Requirements