Skip to content

Instantly share code, notes, and snippets.

@shockwaves
Created January 11, 2017 00:47
Show Gist options
  • Save shockwaves/03d4369f16b0e866016b9c5cf83ce2a5 to your computer and use it in GitHub Desktop.
Save shockwaves/03d4369f16b0e866016b9c5cf83ce2a5 to your computer and use it in GitHub Desktop.
"use strict";
class Users {
constructor(id) {
this.id = id;
}
static create(id) {
this.all.push(new this(id));
}
}
Users.all = [];
class Battles {
constructor(id) {
this.id = id;
this.round = this.constructor.round;
}
static create(id) {
this.all.push(new this(id));
}
}
Battles.all = [];
Battles.round = 1;
for(var i=1;i<=8;i++) {
Users.create(i);
}
var battleId = 1;
var battlesInRound = Users.all.length / 2;
for(;battlesInRound >= 1;battlesInRound /= 2, Battles.round++) {
console.log(['battlesInRound', battlesInRound]);
for(var i=battlesInRound;i>=1;i--, battleId++) {
console.log(['battleId', battleId]);
console.log(['round', Battles.round]);
Battles.create(battleId);
}
}
console.log(Battles.all);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment