- Using Boolean values for conditions
- Using counters for cumulative values
- Tracking a personal best
- Tracking the most recent
Using Boolean values for conditions
Goal: Track whether a particular condition has been met
Use this pattern when you want to flag whether the user has met a specific condition in the game logic.Use cases
- Flag if the user’s character has died on a particular level
- Flag whether the user has unlocked each specific collectible
- Flag if the user is currently playing on hardcore difficulty
- Flag if the user has meet all five conditions to unlock a complex achievement
Example: Flag if the user got 90 kills by using the shotgun or 10 kills by using the sniper
Rules
Apply theREPLACE operator with a literal value of “1” if the flag must be read as TRUE.
Apply the SUM operator with a literal value of “1” if the flag must be equal to or greater than 1 to trigger the game logic.
Cautions
If necessary, initialize or reset the value forREPLACE Boolean stats. Otherwise, the most recently set value is persisted.
In some cases, it’s convenient to define an event that allows resetting a Boolean stat to FALSE. In those cases, use a REPLACE operation with a literal value of “0”.
Return to the top of this topic.
Using counters for cumulative values
Goal: Increment (or decrement) an all-time cumulative value for the user on a particular metric
Use this pattern when you want to increment the stat value by a fixed or variable amount each time that the event is processed.Use cases
- Player level
- Total kills
- Number of videos uploaded
- Number of times that the user has played on each map
- Cumulative distance driving each vehicle type
- Current number of items in inventory
Example: Counter of multiplayer matches won
Rules
Apply theSUM operator to the corresponding event field or specify a fixed constant value as the parameter.
To decrement the value of the stat, use a negative value as the parameter, either as a fixed constant or as a runtime value in the event field.
Cautions
Don’t use string data type “literal” values as parameters with theSUM operator.
Don’t apply the SUM operator to a string data type event field.
If you have multiple events that are updating the same stat, ensure that all the stat rules updating that stat use the same operator.
Return to the top of this topic.
Tracking a personal best
Goal: Track the all-time “best” score for the user on a particular metric
Use this pattern when you want to persist the largest (MAX) or smallest (MIN) record for the user. Discard any values that don’t improve the user’s record.
Use cases
- Longest kill streak
- Fewest deaths on a multiplayer round
- Fastest time completing each race track
- Longest distance drive on every hole on any golf course
Example: Fastest time completing any track in the Europe set
Rules
Apply theMAX or MIN operator to the corresponding event field.
Cautions
Don’t use “literal” values as parameters with theMAX or MIN operator.
Don’t apply the MAX or MIN operator to a string data type event field.
If you have multiple events that are updating the same stat, ensure that all the stat rules updating that stat use the same operator.
Return to the top of this topic.
Tracking the most recent
Goal: Track the most recent score posted by the user on a particular metric
Use this pattern when you want to persist the latest record for the user, regardless of whether the value improves the user’s best record.Use cases
- Current difficulty
- Number of deaths on the current multiplayer round
- Top speed on the most recent race for each track
- Boolean flag for premium golf club currently equipped
Example: Most recent completed time on any track
Rules
Apply theREPLACE operator to the corresponding event field or literal value.
Cautions
If necessary, initialize or reset the value forREPLACE stats. Otherwise, the most recently set value is persisted.
Return to the top of this topic.