Request Count
Request count is a helper struct for defining how many items you want to modify from an inventory. Internally, it's defined as a positive range [Min, Max]; however, most of the time you will use the constructors: (All, AtLeast(N), AtMost(N), Exactly(N), InRange(M, N)).
If the inventory has fewer items than the minimum request count, the request will fail. If the inventory has more items than the maximum request count, it will be clamped to the maximum.
When constructing a request count, the min and max will be clamped so the range is always valid. E.g., passing AtMost(0) will clamp to AtMost(1).
Example
Suppose we're trying to withdrawn item X from an inventory: {(X, 3)}. Here are how many items we would withdraw if we passed the specified request counts:
RequestCount | Result |
---|---|
All | 3 |
AtMost(2) | 2 |
AtMost(3) | 3 |
AtMost(4) | 3 |
AtLeast(2) | 3 |
AtLeast(3) | 3 |
AtLeast(4) | Fail |
Exactly(2) | 2 |
Exactly(3) | 3 |
Exactly(4) | Fail |
InRange(1, 2) | 2 |
InRange(1, 3) | 3 |
InRange(3, 4) | 3 |
InRange(4, 5) | Fail |