Merge pull request #258 from a-sync/hotfix/patch-1

bugfix for Players/Results
This commit is contained in:
Michael Morrison 2021-12-09 17:06:26 -06:00 committed by GitHub
commit c46e8efb0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,7 @@ class Players extends Array {
// run out of ram allocating these objects.
num = Math.min(num, 10000);
while(this.players.length < num) {
while(this.length < num) {
this.push({});
}
}
@ -40,11 +40,19 @@ class Results {
players = new Players();
bots = new Players();
set players(num) {
this.players.setNum(num);
set players(val) {
if (typeof val === 'number') {
this.players.setNum(val);
} else if (Array.isArray(val)) {
this.players = val;
}
}
set bots(num) {
this.bots.setNum(num);
set bots(val) {
if (typeof val === 'number') {
this.bots.setNum(val);
} else if (Array.isArray(val)) {
this.bots = val;
}
}
}