I'm working on a game where, at any time (even during other players turn) it is possible for a player to do an exchange (e.g spend two fish to gain one wood, this does not affect other players in any way).
These kinds of exchange are quite rare (maybe once or twice per game, across all players),
but sometimes you want to do them between other players turns (because of some benefits you may gain when some actions are triggered).
Now, the game has quick turns, and I don't want to ask all players if they want to do an exchange at every player's turn.
I was thinking of an approach like this:
On the server I add a multiactive state between regular player states.
During that state the possible actions are "exchange" or "skip"
On the client I add a small box where users can click at any time when they want to do the action. The client just saves the click information as still "pending".
Now, the idea is that when the game enters the "exchange" state, the client will automatically execute an "exchange" action if there is a pending exchange otherwise it automatically sends a "skip" action.
The question is, where exactly can I make an ajaxcall like that ?
I tried both onEnteringState() adn onUpdateActionButtons() and in both cases I get errors like
"It is not your turn" or "please wait, an action is already in progress".
Then the client get stuck in the multiactive state with no possibility for the players to get unstuck
(once all players hit f5 the game proceeds).
Are there any examples of games that do something like this (with the possibility to look at their code) ?
Thanks in advance
F.
These kinds of exchange are quite rare (maybe once or twice per game, across all players),
but sometimes you want to do them between other players turns (because of some benefits you may gain when some actions are triggered).
Now, the game has quick turns, and I don't want to ask all players if they want to do an exchange at every player's turn.
I was thinking of an approach like this:
On the server I add a multiactive state between regular player states.
During that state the possible actions are "exchange" or "skip"
On the client I add a small box where users can click at any time when they want to do the action. The client just saves the click information as still "pending".
Now, the idea is that when the game enters the "exchange" state, the client will automatically execute an "exchange" action if there is a pending exchange otherwise it automatically sends a "skip" action.
The question is, where exactly can I make an ajaxcall like that ?
I tried both onEnteringState() adn onUpdateActionButtons() and in both cases I get errors like
"It is not your turn" or "please wait, an action is already in progress".
Then the client get stuck in the multiactive state with no possibility for the players to get unstuck
(once all players hit f5 the game proceeds).
Are there any examples of games that do something like this (with the possibility to look at their code) ?
Thanks in advance
F.