Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow asynchronous process action #2

Open
Longwelwind opened this issue Aug 3, 2021 · 0 comments
Open

Allow asynchronous process action #2

Longwelwind opened this issue Aug 3, 2021 · 0 comments

Comments

@Longwelwind
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant