connection with TCP socket
Host: 140.113.123.225
Port: 7975
{
action: "room",
command: "create" | "join" | "random"
}
- Send
{
action: "room",
command: "create"
}
- Receive
{
reply: 0,
game_id: < game id >,
player_id: < your player id >
}
There should come delay when join the room, 1 second is recommanded.
- Send
{
action: "room",
command: "join",
game_id: < the room id you want to join >
}
- Receive
{
reply: 0,
game_id: < game id >,
player_id: < your player id >
}
- Boardcast
{
reply: 0,
msg: "Player <your number> join the game"
}
Not yet complete
{
action: "game",
command: "take" | "draw" | "throw",
game_id: < your game id >
}
Game would start automatically while four player are all connected. If it is your turn, server would send message as below
{
reply: 1,
action: "get",
game_id: < your game id >,
hand: < current cards in your hand >,
discard: < discard from the last player >, // if not exist, the color would be empty and number would be 0
msg: "Take or draw a new card."
}
- Send
{
action: "game",
command: "take",
game_id: < your game id >
}
- Receive
{
reply: 1,
action: "throw",
get: < the card last player throw >,
msg: "You choose to get last player's card, now choose which to throw"
}
- Boardcast
{
action: "take",
player: < your order >,
taken: < the card you take >
}
- Send
{
action: "game",
command: "draw",
game_id: < your game id >
}
- Receive
{
reply: 1,
action: "throw",
msg: "You choose to draw a new card, now choose which to throw",
get: < the card is newly drawed >
}
- Boardcast
{
action: "draw"
player: < your order >,
}
- Send
{
action: "game",
command: "throw",
game_id: < your game id >
hand: [ < the new status in your hand, system would > ]
}
- Receive
//Nothing is sent back if no error
- Boardcast
{
action: "throw",
player: < your order >,
thrown: < the card you throw >
}