Use steamUUID in highscore if available
parent
5d3c9cbe91
commit
a09064ea38
|
@ -36,30 +36,35 @@ campaignPlayer.route('/ranking/:campaignId')
|
||||||
}
|
}
|
||||||
|
|
||||||
const rankingItems = [];
|
const rankingItems = [];
|
||||||
new Set(items.map(x => x.name)).forEach(playerName => {
|
|
||||||
const playerInstances = items.filter(p => p.name === playerName);
|
// check only first player to have valid steamUUID - then decide if tracked by name or by ID
|
||||||
const resItem = {
|
const usesUUID = isSteamUUID(items[0].steamUUID);
|
||||||
name: playerName,
|
|
||||||
kill: 0,
|
new Set(items.map(usesUUID ? x => x.steamUUID : x => x.name))
|
||||||
vehicle: 0,
|
.forEach(player => {
|
||||||
death: 0,
|
const playerInstances = items.filter(usesUUID ? p => p.steamUUID === player : p => p.name === player);
|
||||||
friendlyFire: 0,
|
const resItem = {
|
||||||
revive: 0,
|
name: usesUUID ? playerInstances[playerInstances.length - 1].name : player,
|
||||||
respawn: 0,
|
kill: 0,
|
||||||
flagTouch: 0
|
vehicle: 0,
|
||||||
};
|
death: 0,
|
||||||
for (let i = 0; i < playerInstances.length; i++) {
|
friendlyFire: 0,
|
||||||
resItem.kill += playerInstances[i].kill;
|
revive: 0,
|
||||||
resItem.death += playerInstances[i].death;
|
respawn: 0,
|
||||||
resItem.friendlyFire += playerInstances[i].friendlyFire;
|
flagTouch: 0
|
||||||
resItem.vehicle += playerInstances[i].vehicle;
|
};
|
||||||
resItem.revive += playerInstances[i].revive;
|
for (let i = 0; i < playerInstances.length; i++) {
|
||||||
resItem.respawn += playerInstances[i].respawn;
|
resItem.kill += playerInstances[i].kill;
|
||||||
resItem.flagTouch += playerInstances[i].flagTouch;
|
resItem.death += playerInstances[i].death;
|
||||||
}
|
resItem.friendlyFire += playerInstances[i].friendlyFire;
|
||||||
resItem.fraction = playerInstances[playerInstances.length - 1].fraction;
|
resItem.vehicle += playerInstances[i].vehicle;
|
||||||
rankingItems.push(resItem);
|
resItem.revive += playerInstances[i].revive;
|
||||||
});
|
resItem.respawn += playerInstances[i].respawn;
|
||||||
|
resItem.flagTouch += playerInstances[i].flagTouch;
|
||||||
|
}
|
||||||
|
resItem.fraction = playerInstances[playerInstances.length - 1].fraction;
|
||||||
|
rankingItems.push(resItem);
|
||||||
|
});
|
||||||
|
|
||||||
function getSortedField(fieldName) {
|
function getSortedField(fieldName) {
|
||||||
let num = 1;
|
let num = 1;
|
||||||
|
|
|
@ -5,7 +5,6 @@ const isSteamUUID = (input) => {
|
||||||
return steamUIDPattern.test(input)
|
return steamUIDPattern.test(input)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const sortCollectionBy = (collection, key) => {
|
const sortCollectionBy = (collection, key) => {
|
||||||
collection.sort((a, b) => {
|
collection.sort((a, b) => {
|
||||||
a = a[key].toLowerCase();
|
a = a[key].toLowerCase();
|
||||||
|
@ -50,8 +49,8 @@ const decimalToTimeString = (decimal) => {
|
||||||
(seconds < 10 ? '0' + seconds : seconds);
|
(seconds < 10 ? '0' + seconds : seconds);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.isSteamUUID = isSteamUUID;
|
||||||
exports.sortCollection = sortCollectionBy;
|
exports.sortCollection = sortCollectionBy;
|
||||||
exports.playerArrayContains = playerArrayContains;
|
exports.playerArrayContains = playerArrayContains;
|
||||||
exports.timeStringToDecimal = timeStringToDecimal;
|
exports.timeStringToDecimal = timeStringToDecimal;
|
||||||
exports.decimalToTimeString = decimalToTimeString;
|
exports.decimalToTimeString = decimalToTimeString;
|
||||||
exports.isSteamUUID = isSteamUUID;
|
|
||||||
|
|
Loading…
Reference in New Issue