Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Room lifecycle

makemeunsee edited this page Nov 22, 2012 · 6 revisions
                       X
                       ^
                       |
        +---------+    | OWNER LEAVES
        |         |----+
        |  START  |
        |  LOBBY  |
        |         |
        +---------+
             |
             | START
             |
             V
        +---------+
        |         |<--------------+
        |   IN    |               |
+-------|  GAME   |<---+          |
|       |  PHASE1 |    |          |
|       +---------+    |          |
|            |         |          |
|            | SOLUTION|          |
|            | FOUND   |          |
|            V         |          |
|       +---------+    |          |
| TIME  |         |    |          |
| OUT   |   IN    |    |          |
|       |  GAME   |    |          |
|       |  PHASE2 |    |          |
|       +---------+    |          | RESTART
|            |         | NEXT     | SAME
|            | ROUND   | ROUND    | SESSION
|            | END     |          |
|            V         |          |
|       +---------+    |          |
|       |         |    |          |
+------>| SOLUTION|----+          |
        | DISPLAY |               |
        |         |               |
        +---------+               |
             | AFTER              |
             | LAST               |
             | ROUND              |
             V                    |
        +---------+               |
        |         |               |
        |  END    |---------------+
        |  LOBBY  |
        |         |    +(at any state)
        +---------+    | ALL LEAVE
                       |
                       V
                       X

START LOBBY

A user has just clicked on the "new room" link. He becomes the owner of the room.
Once created, other users can join using the room address.
The start lobby is a form describing the game session.
Form is read/write for the owner, read only for other users.
Visibility option: unlisted or public. Default: unlisted.
Duration option: specified number of rounds, or of victories, or unlimited. Default: 5 rounds.
Joining after start option: allowed or not allowed. Default: allowed.
Owner decides when game starts (START action).

Exchanges:

  • Cli -> Srv: start (owner only)
  • Cli -> Srv: set visibility (owner only)
  • Cli -> Srv: set duration (owner only)
  • Cli -> Srv: leaving room
  • Srv -> Cli: user joined
  • Srv -> Cli: user left
  • Srv -> Cli: visibility changed
  • Srv -> Cli: duration changed
  • Srv -> Cli: game started (includes game board)
  • Srv -> Cli: room killed by owner Future: 'user ready' signals, chat, invitation to join, kick, select different game boards

IN GAME, PHASE 1

Players have a time limit to find a solution before the round ends.
Upon finding a valid solution, phase 2 is triggered.
Upon reaching the time limit, the round ends.

Exchanges:

  • Cli -> Srv: leaving room
  • Cli -> Srv: announce solution
  • Cli -> Srv: fetch time left
  • Srv -> Cli: user joined
  • Srv -> Cli: user left
  • Srv -> Cli: solution announced - new phase starts
  • Srv -> Cli: round ends

IN GAME, PHASE 2

Players have a shorter time limit to improve on the previously announced solution.
Upon reaching the time limit, the round ends.

Exchanges:

  • Cli -> Srv: leaving room
  • Cli -> Srv: announce solution
  • Cli -> Srv: fetch time left
  • Srv -> Cli: user joined
  • Srv -> Cli: user left
  • Srv -> Cli: new best solution for a user announced
  • Srv -> Cli: round ends

SOLUTION DISPLAY

If a solution was found, it is replayed (automatically) and players have a time limit to study the solution.
Score is updated if needed.
Upon reaching the time limit, a new round starts or the end lobby is displayed if the last round was played.

Exchanges:

  • Cli -> Srv: leaving room
  • Cli -> Srv: fetch new scores
  • Cli -> Srv: fetch time left
  • Srv -> Cli: user joined
  • Srv -> Cli: user left
  • Srv -> Cli: new round starts
  • Srv -> Cli: game ends

END LOBBY

The final scores (rounds won, game winner) are displayed.
The lobby remains alive as long as one player stays.
The owner can restart the game session with the same parameters as when he created the game.

Exchanges:

  • Cli -> Srv: leaving room
  • Cli -> Srv: fetch new scores
  • Cli -> Srv: restart same game (owner only)
  • Srv -> Cli: user joined
  • Srv -> Cli: user left
  • Srv -> Cli: game started Future: 'user ready' signals, kick, chat

All states

If all players leave the room, the room is destroyed.