Skip to content

Latest commit

 

History

History
96 lines (78 loc) · 1.04 KB

File metadata and controls

96 lines (78 loc) · 1.04 KB

Game rules

{
  "tries": 3, // number
  "items": [
    {
      "name": "rock",
      "weakness": ["paper"],
      "picture": "url_or_data"
    },
    {
      "name": "paper",
      "weakness": ["scissors"],
      "picture": "url_or_data"
    },
    {
      "name": "scissors",
      "weakness": ["rock"],
      "picture": "url_or_data"
    }
  ]
}

OP Codes

1

Ping Client:

{
  "op": 1,
  "d": "Ping pong"
}

Server:

{
  "op": 1,
  "d": "Ping pong"
}

2

Join

Client:

{
  "op": 2,
  "d": {
    "username": "my username",
    "against": "other username" // Optional.
  }
}

Server:

{
  "op": 2,
  "d": {
    "status": "ready", // "waiting" || "ready"
    "rules": {
      // see #Game-rules
    }
  }
}

3

Server:

{
  "op": 3,
  "d": "paper" // "paper" | "scissor" | "rock" (or whatever there is in the rules) (this is what the other player chose)
}

Client:

{
  "op": 3,
  "d": "rock" // "paper" | "scissor" | "rock" (or whatever there is in the rules)
}