Created
January 11, 2017 00:47
-
-
Save shockwaves/03d4369f16b0e866016b9c5cf83ce2a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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