From 6354e34d182229bafcb3f52a6dc08efca9dd8d74 Mon Sep 17 00:00:00 2001 From: Smith Date: Thu, 9 Dec 2021 22:41:12 +0100 Subject: [PATCH] handle ambiguity of the setters (players, bots) * cases where the protocol overwrites the property with a prepared Players instance (eg.: minecraft & gamespy3) --- lib/Results.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/Results.js b/lib/Results.js index fc7a252..fafa54a 100644 --- a/lib/Results.js +++ b/lib/Results.js @@ -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; + } } }