snollygolly / open-hearts

:heart: An open source version of the card game Hearts.
21 stars 4 forks source link

Add action logic #26

Open snollygolly opened 8 years ago

snollygolly commented 8 years ago

Actions encompass all the actions a player can perform. Note: examples don't include non-action related fields, such as token

Client -> Server

{
  "type": "pass",
  "cards": [
    "2H", "3H", "QS"
  ],
  "to": "PLAYER ID RECEIVING CARDS"
}

Client -> Server

{
  "type": "play",
  "card": "5C"
}

We need to listen for the following.

Server -> Client

{
  "type": "pass",
  "cards": [
    "2H", "3H", "QS"
  ],
  "from": "PLAYER ID SENDING CARDS"
}

Server -> Client

{
  "from": "PLAYER ID WHO LAID THIS CARD DOWN",
  "type": "play",
  "card": "5C"
}

Server -> Client

{
  "type": "trick",
  "cards": [
    "2H", "3H", "QS", "5H"
  ],
  "to": "PLAYER TAKING CARDS"
}

All action events happen with the emitter/broadcast action