Skip to content

Commands

Jiří Petruželka edited this page Dec 1, 2013 · 24 revisions

Výstup kromě error je obalený v ['result' => ...]

Any

Returns:

errors: [string[]]

Create game

Expects:

command: create_game  
name [string] 
language: [string] // 2-char code
player_limit [integer > 0]  
time_limit [integer > 0] // seconds 
round_limit [integer > 0]  // no. of rounds
evaluation ["auto"|"manual"]
categories [string, CSV]  
player_name [string]

Returns:

game_id [integer]  
admin_token [string]  
player_id [integer]  
player_token [string]  

Start game

Expects:

command: start_game  
id [integer]  
admin_token [string]  

Returns:

void 

Adds message:

round_started { round: 1, timestamp [time of start] }

Stop game

Expects:

command: stop_game  
id [integer]  
admin_token [string]  

Returns:

void  

Adds message:

game_ended

Get players

Expects:

command: get_players  
token [string]  
id [integer]  

Returns:

string[] 

Get games

Expects:

command: get_games  
game_filter [json:game_filters]

Returns:

[
    id [integer]
    language [string:2]
    name [string]
    player_count [integer]
    player_total [integer]
    evaluation [string]
    time_limit [integer]
    round_limit [integer]
    categories [string:csv]
    is_running [bool]
]

JSON:game_filters

not_full:bool
language:"language_code"

Get scores

Expects:

command: get_scores  
game_id [integer]

Returns:

[
    player1_name => score,
    player2_name => score,
    ...
]

Join game

Expects:

command: join_game  
game_id [integer] 
player_name [string]

Returns:

player_id [integer]  
player_token [string]

Leave game

Expects:

command: leave_game  
game_id [integer]  
token [string]  

Returns:

void  

Adds message:

left_game

Post message (generic)

Expects:

command: post_message  
game_id [integer]  
token [string]  
type [string]  
data [string]  

Returns:

void  

Get messages (generic)

Expects:

command: leave_game  
game_id [integer]  
token [string]  
* since_id [integer]  

Returns:

[ 
    id [integer]
    type [string]
    data [string]
], ...

Implementations:

Send words

Expects:

command: post_message
action: send_words
game_id [integer]  
token [string]  
words [string, CSV]

Game Messages

  • left_game
  • joined_game
  • chat
  • round_started (+ evaluation)
  • round_ended
  • game_finished (intentional)
  • game_ended (unintentional)