handle ambiguity of the setters (players, bots)

* cases where the protocol overwrites the property with a prepared Players instance (eg.: minecraft & gamespy3)
This commit is contained in:
Smith 2021-12-09 22:41:12 +01:00
parent e6db2a9b72
commit 6354e34d18

View file

@ -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;
}
}
}