ravens-engine / core

A Javascript library for building multiplayer turn-based games
https://ravens.dev/
15 stars 2 forks source link

Add timed actions #27

Open Longwelwind opened 3 years ago

Longwelwind commented 3 years ago

Timed actions would be a way to program the execution of an action in the future. This could have multiple usage:

The API would roughly look like:

processAction(action) {
  if (action.type == "move-troops") {
    const time = this.computeTimeInMsForTroopToMove();
    this.planAction(time, {
      type: "troop-arrived",
      troop: action.troopId
    });
  }
}

processTimedAction(action) {
  if (action.type == "troop-arrived") {
    // Process the action
  }
}