Computed quantities for stackable items
What's new
Items accept an optional quantity_expression — a math expression that computes how much of a stackable item to grant, instead of the fixed quantity integer. The expression reuses the MathExpression shape already used by campaign conditions and persistent campaign attributes: a name plus a list of tokens, where each token has a type (attribute, custom_attribute, event_attribute, custom_event_attribute, operator, number, date, string, boolean, list, variable, or virtual_currency) and a value.
Impact
A single item can now scale its grant to the player. Previously a reward of "10% of the player's coin balance" needed a separate item per tier or a campaign to compute it; now the item itself carries the formula, and the platform evaluates it when the item is granted.
Because quantity_expression lives on ItemRead, it also surfaces on every response that embeds an item — nested items, fallback items, store item bonuses, coupon grants, and order line items.
Changes
| Resource | Change |
|---|---|
| create_item, update_item, bulk_create_or_update_items, bulk_update_items | Optional quantity_expression accepted in the item request body |
| get_items, get_item, translate_item | quantity_expression returned on the item, its fallback_item, and each nested_items_read entry |
| get_all_store_items, get_store_items, create_store_item, update_store_item, bulk_update_store_items | quantity_expression returned on item, bonus_items, and dynamic_nested_items_read |
| get_coupons, get_coupon, get_user_coupons, create_coupon, update_coupon, bulk_update_coupon | quantity_expression returned on each entry of the coupon items array |
| create_order, get_order, update_order | quantity_expression returned on the item behind each order line item |
Upgrade
- No action required.
quantity_expressionis optional, and items that set onlyquantitybehave exactly as before. - If you read item quantities to decide what to grant in game, handle the case where
quantity_expressionis present — the effective amount comes from the expression, not fromquantity.
需要技术支持?
联系我们的集成技术团队: [email protected]