js_proto.htm 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  4. <link href="synrc.css" type="text/css" rel="stylesheet">
  5. </head>
  6. <body>
  7. <div class="threecol">
  8. <div class="left">
  9. <div class="hints"></div>
  10. <div class="main">
  11. <h1><a name="chapter2">JavaScript Public Game Protocol</a></h1>
  12. <h2><a name="p1.1">Session Attach</a></h2>
  13. <p>Session Attach is the first message that should be
  14. sent from JavaScript client using Authorization token. For test purposes you can use following token:</p>
  15. <code>ws.send(enc(tuple(
  16. atom('client'),
  17. tuple(
  18. atom('session_attach'),
  19. 'EBAs6dg2Xw6XuCdg8qiPmlBLgYJ6N4Ti0P+oGpWgY'+
  20. 'z4NW4nBBUzTe/wAuLYtPnjFpsjCExxSpV78fipmsP'+
  21. 'xcf+NGy+QKIM6rmVJhpnIlKf0bpFNuGaAPjZAWthh'+
  22. 'GO8nZ0V8UnA=='))));
  23. </code>
  24. <h2><a name="p1.1">Join Game</a></h2>
  25. <p>After session established you can join the game table.
  26. You should specify existed ID of game table. 1000001 is permanent lobby game ID:</p>
  27. <code>ws.send(enc(tuple(
  28. atom('client'),
  29. tuple(atom('join_game'),1000001))));
  30. </code>
  31. <h2><a name="p1.1">Game Events</a></h2>
  32. <p>Just after joining the table you will be able to listen the air.
  33. All messages from server to client are encoded as game events.
  34. You can make BERT huamn readable with:</P>
  35. <code>String(dec(raw))</code>
  36. <h3><a name="p1.1">Game Info</a></h3>
  37. <p>During each new game <b>okey_game_info</b> issued with full list of players.
  38. You should remeber thirs names to display in client.</p>
  39. <code>{game_event,undefined,okey_game_info,
  40. {players,
  41. {PlayerInfo,<<"dunes1500113">>,
  42. <<"dunes">>,<<"Abe">>,Kobo,undefined,undefined,undefined,
  43. <<"/files/users/user_dunes/avatar/1-small.jpg">>,true},
  44. {PlayerInfo,<<"wolves1500114">>,
  45. <<"wolves">>,<<"Herman">>,Hesse,undefined,undefined,undefined,
  46. <<"/files/users/user_wolves/avatar/1-small.jpg">>,true},
  47. {PlayerInfo,<<"wolves1500115">>,
  48. <<"wolves">>,<<"Herman">>,Hesse,undefined,undefined,undefined,
  49. <<"/files/users/user_wolves/avatar/1-small.jpg">>,true},
  50. {PlayerInfo,<<"dunes1500112">>,
  51. <<"dunes">>,<<"Abe">>,Kobo,undefined,undefined,undefined,
  52. <<"/files/users/user_dunes/avatar/1-small.jpg">>,false}},
  53. {timeouts,{OkeyTimeouts,normal,30000,10000,25000,45000}},
  54. {game_type,standard},
  55. {finish_with_gosterge,undefined},
  56. {pairs,null},
  57. {table_name,<<"I'm filling lucky">>},
  58. {sets,null},{set_no,null},{rounds,undefined},
  59. {mul_factor,1},{slang_flag,false},{observer_flag,false},
  60. {pause_enabled,true},{social_actions_enabled,true},
  61. {tournament_type,lucky},{series_confirmation_mode,<<"no">>}}
  62. </code>
  63. <h3><a name="p1.1">Player State</a></h3>
  64. <code>{game_event,undefined,okey_game_player_state,
  65. {whos_move,null},{game_state,game_initializing},
  66. {piles,null},{tiles,null},{gosterge,null},
  67. {pile_height,null},{current_round,0},{game_sub_type,null},
  68. {next_turn_in,0},{paused,false},{chanak_points,0},
  69. {round_timeout,null},{set_timeout,null}}</code>
  70. <h3><a name="p1.1">Game Started</a></h3>
  71. <p>During each new game <b>okey_game_started</b> issued with full list of cards.
  72. You should remeber them in client along with Gosterge Jocker card.</p>
  73. <code>{game_event,undefined,okey_game_started,
  74. {tiles,{OkeyPiece,3,2}, {OkeyPiece,3,4}, {OkeyPiece,2,12},
  75. {OkeyPiece,3,8}, {OkeyPiece,1,0}, {OkeyPiece,1,10},
  76. {OkeyPiece,2,13}, {OkeyPiece,2,6}, {OkeyPiece,2,10},
  77. {OkeyPiece,2,10}, {OkeyPiece,4,5}, {OkeyPiece,2,11},
  78. {OkeyPiece,2,4}, {OkeyPiece,4,10}},
  79. {gosterge,{OkeyPiece,2,8}},{pile_height,48},
  80. {current_round,1},{current_set,1},{game_type,null},
  81. {game_speed,null},{game_submode,null},{chanak_points,0},
  82. {round_timeout,null},{set_timeout,null}}</code>
  83. <h3><a name="p1.1">Next Turn</a></h3>
  84. <p>You should handle <b>okey_next_turn</b> message in order to give user ablity
  85. to play only when <b>player</b> is his name. Otherwise you messages will be ignored by server.</p>
  86. <code>{game_event,undefined,okey_next_turn,
  87. {player,<<"oldman1500118">>},{can_challenge,false}}</code>
  88. <h3><a name="p1.1">Discarded Notification</a></h3>
  89. <p>When someone discards the Tash you should update you
  90. corner cards placeholders with discarded Tash.</p>
  91. <code>{game_event,undefined,okey_tile_discarded,
  92. {player,<<"oldman1500118">>},{tile,{OkeyPiece,1,4}},{timeouted,true}}</code>
  93. <h3><a name="p1.1">Taken Notification</a></h3>
  94. <p>When someone take a cards from center of the table <b>pile=0</b>
  95. or from its neighbour <b>pile=1</b> you will be notified to update
  96. the <b>pile_height</b> cards left:</p>
  97. <code>{game_event,GameId,okey_tile_taken,
  98. {player,<<"wolves1500121">>},{pile,0},
  99. {revealed,null},{pile_height,47}}</code>
  100. <p>You the card was taken by you, you can see it in <b>tile</b>:</p>
  101. <code>{game_event,GameId,okey_tile_discarded,
  102. {player,<<"dunes1500120">>},
  103. {tile,{OkeyPiece,1,1}},{timeouted,false}}</code>
  104. <h3><a name="p1.1">Timeout Notification</a></h3>
  105. <p>Send when player was inactive during 30 seconds (timeout by default). Server is automaticaly take and discard cards</p>
  106. <code>{game_event,GameId,okey_turn_timeout,[{tile_taken,{'OkeyPiece',2,4}},
  107. {tile_discarded,{'OkeyPiece',2,4}}]}</code>
  108. <h3><a name="p1.1">Player Left Notification</a></h3>
  109. <p>Send when someone left the game and have replaced. Server will send additional information about new plyaer: is bot or is human - {bot_replaced,false} and {human_replaced,true} and new PlayerInfo in field replacment
  110. </p>
  111. <code>{game_event,GameId,player_left,
  112. [{player,<<"radio1500012">>},
  113. {bot_replaced,false},
  114. {human_replaced,true},
  115. {replacement,
  116. {'PlayerInfo',<<"betul_dogan1500001">>,
  117. <<"undefined">>,<<"Betul">>,<<"Dogan">>,
  118. undefined,0,0,<<"undefined">>,false}}]}</code>
  119. <h2><a name="p1.1">Game Actions</a></h2>
  120. <p>Game Actions is something that you can send only from client to server.
  121. But for debugging purposes during development phase your game actions
  122. will mirror from server as DATA BERT event also.</p>
  123. <h3><a name="p1.1">Take</a></h3>
  124. Take a card from.<br/>
  125. Fields:
  126. <ul>
  127. <li><b>GameId</b>: current game id (by default use 1000001)</li>
  128. <li><b>{pile: From}</b>: from which pile take a card. values: 0 - from table, 1 - from pile of left player</li>
  129. </ul>
  130. <code>ws.send(enc(tuple(atom('client'),tuple(atom('game_action'),GameId,
  131. atom('okey_take'),{'pile': From}))));</code>
  132. <h3><a name="p1.1">Discard</a></h3>
  133. Discard card from a hand.<br/>
  134. Fields:
  135. <ul>
  136. <li><b>GameId</b>: current game id (by default use 1000001)</li>
  137. <li><b>{'tile':tuple(atom('OkeyPiece'),Color,Vaue)}</b>: card description (#'OkeyPieces'{} record)<br>
  138. when <b>Colour</b> is card colour, number from 1 to 4, <b>Value</b> is card value, number from 1 to 13</li>
  139. </ul>
  140. <code>ws.send(enc(tuple(
  141. atom('client'),
  142. tuple(
  143. atom('game_action'),
  144. GameId,
  145. atom('okey_discard'),
  146. {'tile':tuple(atom('OkeyPiece'),Color,Vaue)}))));</code>
  147. <h3><a name="p1.1">Pause/Resume</a></h3>
  148. Game pause or resume.<br/>
  149. Fields:
  150. <ul>
  151. <li><b>GameId</b>: current game id (by default use 1000001)</li>
  152. <li><b>Action</b>: Send action. Value 'pause' or 'resume'</li>
  153. </ul>
  154. <code>ws:send(enc(tuple(atom('client'),
  155. tuple(atom("pause_game"),atom('undefined'),GameId,
  156. atom(Action)))));</code>
  157. <h3><a name="p1.1">Reveal</a></h3>
  158. Reveal a card:
  159. Fields:
  160. <ul>
  161. <li><b>GameId</b>: current game id (by default use 1000001)</li>
  162. <li><b>{discarded, tuple(atom("OkeyPiece"), Color, Value)}</b>: a card with you want reveal, (#'OkeyPieces'{} record)<br/>
  163. when <b>Colour</b> is card colour, number from 1 to 4, <b>Value</b> is card value, number from 1 to 13</li>
  164. <li><b>{hand, Hand}</b>: rest of hand, without revealed card<br>
  165. value - two lists in lists (upper and lower rows) of tuple(atom("OkeyPiece"), Color, Value) or 'null' if card doesn't exist<br/>
  166. </ul>
  167. <code>ws:send(enc(tuple(atom('client'),tuple(atom("game_action"),
  168. GameId,atom("okey_reveal"),
  169. [{discarded, tuple(atom("OkeyPiece"), Color, Value)},{hand, Hand}]))));</code>
  170. <h3><a name="p1.1">I Saw Okey</a></h3>
  171. Send by player when he sees Gosterge. (not tested fully)
  172. <code>ws:send(enc(tuple(atom('client'),
  173. tuple(atom("game_action"),GameId,atom("okey_i_saw_okey"),[]))));</code>
  174. <h3><a name="p1.1">I Have 8 Tashes</a></h3>
  175. Send by player when he has 8 tashes. (not tested fully)
  176. <code>ws:send(enc(tuple(atom('client'),
  177. tuple(atom("game_action"),GameId,atom("okey_i_have_8_tashes"),[]))));</code>
  178. </div>
  179. <div class="contents">
  180. <iframe src="contents.htm" frameborder=0 width=340 height=2190></iframe>
  181. </div>
  182. </body>
  183. </html>