Skip to content

Allow asynchronous process action #2

@Longwelwind

Description

@Longwelwind

At the moment, processAction is a synchronous function. This means that when the action of a player arrives.

Client-side, it may be useful to allow for an asynchronous processAction. This could be used to trigger animations during the processing of an action. In code, this would translate into:

async processAction(userId, action) {
  if (action.type == "pay-money-for-item-in-shop") {
    await decreaseMoneyOfPlayer();
    this.state.money -= priceOfItem;
    await animateItemFromShopToPlayerInventory();
    transferItemFromShopToInventory();
  }
}

This is useful because sometimes you may want to maintain the state of the game to an intermediary state, between the processing of actions.

This would have a lot of impact on the architecture of Ravens, as all the code was done synchronously. There are also some questions that should be answered, like what to do when an action arrives from the server while processAction is waiting for a promise.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions