Skip to content

How to Handle Multiple Round 0 Restarts at the beginning and a Round 0 Restart at the End of a Demo #378

Answered by saul
dbalders asked this question in Questions
Discussion options

You must be logged in to vote

One solution would be to keep track of all rounds. Each time you see the round number resets to 1, assume that a new 'game' is starting. The key part is to never drop any data - capture it all while the demo is running, and decide which rounds were part of the actual match when the demo finishes.

By the end of the demo you will have something like this:

const games = [
  {
    rounds: [
      // round 1
    ]
  },
  {
    rounds: [
      // round 1
      // round 2
      // ...
      // round 10
    ]
  },
  {
    rounds: [
      // round 1
    ]
  },
];

demoFile.on('end', e => {
  let longestGame = games[0];
  for (let game of games) {
    if (game.rounds.length > longestGame.rounds.length

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dbalders
Comment options

Answer selected by saul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants