timotheeg / nestrischamps

A web-based OCR and restreamer system for NES Classic Tetris players
MIT License
48 stars 12 forks source link

feat: support starting and ending rounds and querying round data #139

Open timotheeg opened 1 year ago

timotheeg commented 1 year ago

Allows game host to start and end rounds.

The room will record the state of the room at start point and end point (who is connected, which users are selected as players), and when a round is ended, the results can be queried (so far only as json).

All the games results from al the players will be returned.

image

Round result API (protected with admin session): /api/room/round

Example dataset

{
  "start": {
    "producers": [
      {
        "id": "434015974",
        "login": "yobi9",
        "display_name": "yobi9",
        "profile_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/7cfa0e8d-4e5c-41c4-803e-7036939a44a9-profile_image-300x300.png",
        "country_code": "SG"
      }
    ],
    "bestof": 3,
    "selected_match": null,
    "curtain_logo": null,
    "players": [
      {
        "id": "434015974",
        "login": "yobi9",
        "display_name": "yobi9",
        "country_code": "SG",
        "profile_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/7cfa0e8d-4e5c-41c4-803e-7036939a44a9-profile_image-300x300.png",
        "victories": 0,
        "camera": {
          "mirror": 0
        }
      },
      {
        "id": "",
        "login": "",
        "display_name": "",
        "country_code": "",
        "profile_image_url": "",
        "victories": 0,
        "camera": {
          "mirror": 0
        }
      }
    ],
    "ts": 1667137291328
  },
  "end": {
    "producers": [
      {
        "id": "434015974",
        "login": "yobi9",
        "display_name": "yobi9",
        "profile_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/7cfa0e8d-4e5c-41c4-803e-7036939a44a9-profile_image-300x300.png",
        "country_code": "SG"
      }
    ],
    "bestof": 3,
    "selected_match": null,
    "curtain_logo": null,
    "players": [
      {
        "id": "434015974",
        "login": "yobi9",
        "display_name": "yobi9",
        "country_code": "SG",
        "profile_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/7cfa0e8d-4e5c-41c4-803e-7036939a44a9-profile_image-300x300.png",
        "victories": 0,
        "camera": {
          "mirror": 0
        }
      },
      {
        "id": "",
        "login": "",
        "display_name": "",
        "country_code": "",
        "profile_image_url": "",
        "victories": 0,
        "camera": {
          "mirror": 0
        }
      }
    ],
    "ts": 1667137330621
  },
  "results": {
    "yobi9": {
      "id": "434015974",
      "login": "yobi9",
      "games": [
        {
          "id": 218854,
          "start_time": "2022-10-30T13:41:36.875Z",
          "end_time": "2022-10-30T13:41:47.356Z",
          "duration": 10481,
          "score": 78,
          "start_level": 3,
          "lines": 0,
          "end_level": 3,
          "tetris_rate": null
        },
        {
          "id": 218855,
          "start_time": "2022-10-30T13:41:54.248Z",
          "end_time": "2022-10-30T13:42:04.648Z",
          "duration": 10400,
          "score": 80,
          "start_level": 8,
          "lines": 0,
          "end_level": 8,
          "tetris_rate": null
        }
      ]
    }
  }
}
timotheeg commented 1 year ago

The command startRound could be forwarded to views (to display a countdown), and possibly producers, to inform the players of the countdown 🤔

This is related to having the renderer shown on the producer page btw, so players can take a peek at their opponent's state in real time (much more real-time than watching the twitch stream).