Skip to content

Proposal for Triggers

Razvan Deaconescu edited this page Aug 22, 2014 · 6 revisions

Triggers are actions that take place when a certain condition is met. There may be player triggers (when a player collects a certain type of resource, when a player reaches a certain level), general triggers (when a certain day in a game is reached) or game triggers (when a quest ends, when a challenge is run). A trigger is made of two components: a condition and an action. Triggers are the basis for gaining skills, badges and achievements, though they may be used for other items as well.

You may think of triggers as hooks in the code. When ever an event occurs, the hook/trigger is "triggered" and its effect is applied.

Triggers are connected to effects. Triggers are the mapping of an effect to a specific situation/condition. One may consider the casting of a spell to be a trigger. Any running of an effect is caused by a trigger.

Implementing Triggers

There should be a Trigger top-level class/model that defines what a trigger should look like. Each instance of the class would be an actual trigger to be used in the code, identified by a given string.

The trigger action is implemented, similarly to a hook, in a certain area of code. When that area is reached, the instances of triggers identified by a string are searched and their effects are applied. The condition/code placing of the trigger is predefined in the implementation. Initially there are no trigger instances so no effects are applied when particular trigger areas are reached.

The Trigger class would consist of the following attributes:

  • name: a unique name/identifier of a trigger
  • description: a description of the event/condition that enables the trigger to get trigged
  • expression: an expression of the trigger condition; for example, the user may need to supply the player level the player must have in order for the trigger to run
  • list of effects (most of the time there would be a single one): what are the effects of running a trigger

There would be a single method:

  • run: go through list of effects and apply them

Actions on Triggers

Triggers may be added, removed and edited only by the priviliged user.

The entire list of trigger identifiers is defined in the code and is available to the Control Panel interface where the privileged user may manage triggers. An element of the list consists of the its identifier and a expression with items to be defined when a trigger instance is added.

Triggers may be added on a per-game basis, for example one could add specific triggers only for the quest game, or only for the challenge game. Adding or editing them will happen through the game interface in Control Panel. Or triggers may also be added in a general interface; per-game triggers may also be added in the general interface, by mentioning the game id in the expression (for example the quest id). Some triggers (for example the on-day-any-player trigger) may only be managed from the general interface, since they aren't particular to a given game.

  1. Add trigger

    Adding a triggers means first selecting a trigger identifier. After this the player can see the description and then provide two types of elements:

    • the trigger expression
    • the list of effects (that may have expressions to be filled themselves)

    When adding a trigger, a privileged user may select a trigger identifier multiple times and add it; obviously the trigger expression or the list of effects would be different (possibly both).

  2. Edit trigger

    When editing a trigger, the privileged user may update the expression or may add or remove effects, or she may edit the effects.

  3. Remove trigger

    Removing a trigger requires no precondition. Its effects are removed together with it.

  4. List triggers

    Browse through all triggers added and show a table with all of them. Column tables would be attribuges of triggers: identifier, description, expression, list of effects.

Example of Adding a Trigger

As an example, let's consider that, inside the implementation an entry would be: ("on-day-any-player", "On given day apply effects on any player in the game."%day%", "2014-12-25"). This means that when a player want to add a trigger he may select the on-day-any-player identifier. He would then be prompted to provide the day where the trigger effects will take place; the default value for the day would be Christmas day.

In detail, if the user wishes to add a trigger that delivers gold to all users in a given day, one would:

  • select the on-day-any-player trigger identifier string; this is mapped internally (in the implementation) with the %day% expression
  • fill the expression field with the day
  • select the effect give-resource and fill the effect expression field

At the beginning of the day the implementation would check the on-day-any-player triggers (there may be multiple such triggers). If that particular day is reached, the give-resource effect is run, delivering the given resource amount to all players.

Sample Triggers

This is an initial list of triggers that may be implemented inside wouso. Other triggers may be implemented as well. These are only conditions, effects are to be defined elsewhere.

Player Triggers

  1. on-level-any-player

    • Description: Run effect on player when reaching a given level.
    • Data to be filled: On what level will the effect take place: may be any, or may be specific level.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge)
  2. on-level-any-player-of-group

    • Description: Run effect on any player of a selected group when reaching a given level.
    • Data to be filled: On what level will the effect take place; what group must the player be part of in order for the effect to take place.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  3. on-resource-type-any-player

    • Description: Run effect on any player when reaching a given resource amount.
    • Data to be filled: What type of resource and what amount of that resource.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  4. on-any-day-any-player

    • Description: Run effect at the beginning of every day on each player.
    • Data to be filled: None
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  5. on-day-any-player

    • Description: Run effect at a specific day on each player.
    • Data to be filled: What day will the effect take place?
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).

Game Triggers

  1. on-quest-end-players-complete

    • Description: Run effect when quest ends on players who completed the test.
    • Data to be filled: None
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  2. on-quest-end-players-quest-level

    • Description: Run effect when quest ends on players who reached a given level inside the game.
    • Data to be filled: What level in the quest should players have reached?
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  3. on-quest-start-any-player

    • Description: Run effect on any player who starts the quest.
    • Data to be filled: None
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  4. on-quest-start-player-of-group

    • Description: Run effect on any player of a given group who starts the quest.
    • Data to be filled: What group must the player be part of in order for the effect to take place.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  5. on-challenge-run-players

    • Description: Run effect on players at the running of a challenge.
    • Data to be filled: None
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  6. on-challenge-end-winning-player

    • Description: Run effect on winning player of a challenge.
    • Data to be filled: None
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  7. on-challenge-end-losing-player

    • Description: Run effect on losing player of a challenge.
    • Data to be filled: None
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  8. on-challenge-end-draw

    • Description: Run effect on both players when challenge ends in a draw.
    • Data to be filled: None
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  9. on-number-of-challenges-run-any-player

    • Description: Run effect on player after running number of challenges.
    • Data to be filled: Number of challenges to be run in order to trigger the effect.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  10. on-number-of-challenges-run-in-a-day-any-player

    • Description: Run effect on player after running number of challenges.
    • Data to be filled: Number of challenges to be run in order to trigger the effect.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  11. on-number-of-challenges-won-any-player

    • Description: Run effect on player after winning number of challenges.
    • Data to be filled: Number of challenges to be won in order to trigger the effect.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  12. on-number-of-challenges-won-streak-player

    • Description: Run effect on player after winning number of challenges in a streak (continuously).
    • Data to be filled: Number of challenges to be won in a streak in order to trigger the effect.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  13. on-number-of-qotd-answered-any-player

    • Description: Run effect on player after answering number of questions of the day.
    • Data to be filled: Number of qotd answers required in order to trigger the effect.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  14. on-number-of-qotd-answered-streak-any-player

    • Description: Run effect on player after answering number of questions of the day in a streak (continuously).
    • Data to be filled: Number of qotd answers in a streak required in order to trigger the effect.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  15. on-number-of-qotd-correctly-answered-any-player

    • Description: Run effect on player after answering number of questions of the day correctly.
    • Data to be filled: Number of correct qotd answers required in order to trigger the effect.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
  16. on-number-of-qotd-correctly-answered-streak-any-player

    • Description: Run effect on player after answering number of questions of the day correctly in a streak (continuously).
    • Data to be filled: Number of correct qotd answers in a streak required in order to trigger the effect.
    • Effect: What is the effect when trigger is run (e.g. give resource, give artifact, give badge).
Clone this wiki locally