Events Process Question

edited November 2012 in Flash (deprecated)
Hi there, I'd love any help and advice on the below if you could spare a few moments.

What would be the correct or recommended proceedure to check that all players in a room have performed a certain action before moving the game to its next stage.

Specifically, a player chooses an item for example, and then the game waits for all other players to have performed the same action. Once this is complete the game moves on.

Any code examples would be greatly appreciated as I'm feeling my way around the SDK the moment.

Thanks in advance.


  • Each player could send his "OK" (an event) and when this is received by all, make one client advance the game state by sending a "round start" event.
    Instead of using one event per state, you could also define a "state" event where the content defines the current state.
  • Hi Tobias and thanks for your speedy response.

    The first suggestion makes sense to me, so would you suggest that every time a player receives the event sent from a another player, I check the current count of received "OKs" against the total number of players in the room? I'm wondering if anyone was to loose connection during this time this would bug out the loop.

    I'm a little unclear about your second suggestion?

    Thanks again mate.
  • Every player should remember which other players said "ok". When someone leaves or drops out, it's no longer relevant if this player sent an ok or not.
    Nevermind the second suggestion :)
    You will understand when you begin working on your network workflow.
  • Brilliant, thanks again. One final question (until the next one!):

    How do I only allow one client to advance the game state?

    Thanks again.
  • We usually pick the one with the lowest actorNumber to be the "Master Client". This "assignment" only switches on create of a room (player 1 becomes master) and if the current master leaves. Then the next active player gets to be master and advances game state.
    It's important to get the state stable, even if the master leaves when some state change is required. So if a new master is picked, this must check current state and advance it, even if the event that triggers this was received before being master.
  • Thank you Tobias, that makes perfect sense.

    I must say, I'm more of a designer than developer but have managed to get our concept pretty much up and running within 2-3 days.

    The Photon Cloud is awesome and we are hugely impressed. The AS3 load balancer demo served as a perfect foundation for our build.

    Thank you !
  • :D
    Thanks for that feedback. It's always great to read about someone getting along with Photon nicely!