gamedigz 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/protocols/valve.js +15 -14
package/package.json
CHANGED
package/protocols/valve.js
CHANGED
|
@@ -427,21 +427,22 @@ class Valve extends Core {
|
|
|
427
427
|
async cleanup(/** Results */ state) {
|
|
428
428
|
// Organize players / hidden players into player / bot arrays
|
|
429
429
|
const botProbability = (p) => {
|
|
430
|
-
if (p.time === -1) return Number.MAX_VALUE
|
|
431
|
-
return p.time
|
|
432
|
-
};
|
|
433
|
-
const sortedPlayers = state.raw.players.sort((a,b) => {
|
|
434
|
-
return botProbability(a) - botProbability(b);
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
const numBots = state.raw.numbots || 0;
|
|
438
|
-
const numPlayers = state.raw.numplayers - numBots;
|
|
439
|
-
while(state.bots.length < numBots) {
|
|
440
|
-
if (sortedPlayers.length) state.bots.push(sortedPlayers.pop());
|
|
441
|
-
else state.bots.push({});
|
|
430
|
+
if (p.time === -1) return Number.MAX_VALUE
|
|
431
|
+
return p.time
|
|
442
432
|
}
|
|
443
|
-
|
|
444
|
-
|
|
433
|
+
|
|
434
|
+
const rawPlayers = [...state.raw.players]
|
|
435
|
+
const sortedPlayers = rawPlayers.sort((a, b) => {
|
|
436
|
+
return botProbability(a) - botProbability(b)
|
|
437
|
+
})
|
|
438
|
+
|
|
439
|
+
const numBots = state.raw.numbots || 0
|
|
440
|
+
|
|
441
|
+
while (state.bots.length < numBots && sortedPlayers.length) {
|
|
442
|
+
state.bots.push(sortedPlayers.pop())
|
|
443
|
+
}
|
|
444
|
+
while ((state.players.length < state.numplayers - numBots || sortedPlayers.length) && sortedPlayers.length) {
|
|
445
|
+
state.players.push(sortedPlayers.pop())
|
|
445
446
|
}
|
|
446
447
|
}
|
|
447
448
|
|