some more refactoring
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user