-
Notifications
You must be signed in to change notification settings - Fork 103
Proposal for Constraints
Constraints are requirements that a player should satisfy in order to get an item. Such constraints may be the item cost, level requirement, actions in player history, the presence of items in player profile.
Constraints may also be implemented in a formula fashion, similar to effects.
Constraints are implemented and then customized to the privileged user to be attached to a given item.
There should be a Constraint top-level class/model that defines what a constraint should look like. Each instance of the class would be an actual constraint that is to be attached to a modifier or a game. A player need to satisfy that constraint in order to acquire that modifier item or to run the game.
The Constraint class would consist of the following attributes:
- name: a unique name/identifier of a condition
- description: a description of the what the constraint does: what is required in order for the constraint to be satisfied
- expression: an expression of the constraint condition; for example, the user needs to be part of a certain group, or the user needs to have a certain amount of a given resource
- owner: what type of game or modifier items does the constraint apply to; it may be general or it may only apply to a certain set of games or items
There would be a single method:
- check: verify that the constraint is satisfied
Constraint types are predefined in the implementation. A constraint type is defined as a tuple of the constraint name, description, expression and owner. The expression is a user customizable string, such as "{player-level} >= %user-provided-level%". This expression translates to the player level being greater than a custom user provided level when instancing a constraint. A sample of the constraint type tuple would be: ("player-level-above", "Check player level is above configuration provided level", "{player-level} >= %config-provided-level%", "2", "general"). The last two items are the default value for the user provided level and the owner of the constraint.
In the Control Panel interface, the privileged user may create constraint instances. Constraint instances may only be created in conjunction with creating modifier items or games. For example, if creating a spell, we might configure the constraint for that spell to be used only by players above level 5. Or, if creating a quest, we might configure the quest to only be playable by players of a given group.
The privileged user may do the following actions:
-
Add constraint
Adding a constraint means first selecting a constraint identifier. After this the player can see the description and fill a set of elements, those required by the constraint expression. It may so be that there is no element to be filled.
-
Edit constraint
When editing a constraint, the privileged user may update the elements in the expression.
-
Remove constraint
Removing a constraint requires no precondition.
Below is an initial set of constraint types. Each shows the item name, the description, expression and owner.
-
player-level-above
- description: Check player level is above configuration provided level
- expression: {player-level} >= %config-provided-level%
- owner: general
-
player-level-below
- description: Check player level is above configuration provided level
- expression: {player-level} <= %config-provided-level%
- owner: general
-
player-level-equals
- description: Check player level is above configuration provided level
- expression: {player-level} == %config-provided-level%
- owner: general
-
player-resource-above
- description: Check player resource is above configuration provided amount
- expression: {player-resource}%config-provided-resource-type% >= %config-provided-amount%
- owner: general
-
player-of-group
- description: Check player is part of a configuration provided group
- expression: {player-group} == %config-provided-group%
- owner: general
-
player-not-of-group
- description: Check player is not part of a configuration provided group
- expression: {player-group} != %config-provided-group%
- owner: general
-
player-schedule-challenge-difference-below
- description: Check difference between player level and challenged player level is below a configuration provided threshold
- expression: {player-level} - {chalenged-player-level} >= %config-provided-threshold%
- owner: challenge game