Use steamUUID in highscore if available

pull/29/head
HardiReady 2018-03-04 10:55:59 +01:00
parent 5d3c9cbe91
commit a09064ea38
2 changed files with 30 additions and 26 deletions

View File

@ -36,10 +36,15 @@ campaignPlayer.route('/ranking/:campaignId')
}
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 usesUUID = isSteamUUID(items[0].steamUUID);
new Set(items.map(usesUUID ? x => x.steamUUID : x => x.name))
.forEach(player => {
const playerInstances = items.filter(usesUUID ? p => p.steamUUID === player : p => p.name === player);
const resItem = {
name: playerName,
name: usesUUID ? playerInstances[playerInstances.length - 1].name : player,
kill: 0,
vehicle: 0,
death: 0,

View File

@ -5,7 +5,6 @@ const isSteamUUID = (input) => {
return steamUIDPattern.test(input)
};
const sortCollectionBy = (collection, key) => {
collection.sort((a, b) => {
a = a[key].toLowerCase();
@ -50,8 +49,8 @@ const decimalToTimeString = (decimal) => {
(seconds < 10 ? '0' + seconds : seconds);
};
exports.isSteamUUID = isSteamUUID;
exports.sortCollection = sortCollectionBy;
exports.playerArrayContains = playerArrayContains;
exports.timeStringToDecimal = timeStringToDecimal;
exports.decimalToTimeString = decimalToTimeString;
exports.isSteamUUID = isSteamUUID;