some more refactoring

This commit is contained in:
cnachtigall1991
2021-10-17 18:06:28 +02:00
parent 6ffd7685ab
commit 123f78cb21
5 changed files with 364 additions and 167 deletions

View File

@@ -45,3 +45,24 @@ export const getPlayerArr = (stats, team, color) => {
return arr
}
export const constructAvatarUrl = (hash, size) => {
const base = 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars'
const imgSize = size ? `_${size}` : ''
const hashDir = hash.substring(0, 2)
return `${base}/${hashDir}/${hash}${imgSize}.jpg`
}
export const GetAvgRank = (stats) => {
let count = 0
let fullRank = 0
stats.map(player => {
if (player.rank?.old) {
fullRank += player.rank?.old
count += 1
}
})
return count === 0 ? 0 : Math.floor(fullRank / count)
}