feat: add role for summoner's matches

This commit is contained in:
Valentin Kaelin 2019-09-19 19:26:44 +02:00
parent c442d3ac1f
commit 8e1850b638
7 changed files with 41 additions and 27 deletions

View file

Before

Width:  |  Height:  |  Size: 520 B

After

Width:  |  Height:  |  Size: 520 B

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

Before

Width:  |  Height:  |  Size: 707 B

After

Width:  |  Height:  |  Size: 707 B

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 416 B

After

Width:  |  Height:  |  Size: 416 B

View file

@ -9,10 +9,11 @@
>{{ data.champ }}</div> >{{ data.champ }}</div>
<div class="flex"> <div class="flex">
<div class="flex flex-col justify-center items-center"> <div class="flex flex-col justify-end items-center">
<div <div
class="w-10 h-10 bg-blue-1000" v-if="data.role !== 'NONE'"
:style="{background: `url(${require('@/assets/img/roles/Bot.png')}) center/cover`}" class="w-10 h-10 bg-center bg-cover"
:style="{backgroundImage: `url(${require('@/assets/img/roles/' + data.role + '.png')})`}"
></div> ></div>
<span class="text-xs text-teal-500 font-extrabold">LVL {{ data.level }}</span> <span class="text-xs text-teal-500 font-extrabold">LVL {{ data.level }}</span>
</div> </div>
@ -22,12 +23,12 @@
></div> ></div>
<div class="ml-2 flex flex-row sm:flex-col sm:justify-around"> <div class="ml-2 flex flex-row sm:flex-col sm:justify-around">
<div <div
class="w-6 h-6 bg-blue-1000 rounded-md" class="w-6 h-6 bg-blue-1000 rounded-md bg-center bg-cover"
:style="{background: `url(${data.firstSum}) center/cover`}" :style="{backgroundImage: `url(${data.firstSum})`}"
></div> ></div>
<div <div
class="w-6 h-6 bg-blue-1000 rounded-md" class="w-6 h-6 bg-blue-1000 rounded-md bg-center bg-cover"
:style="{background: `url(${data.secondSum}) center/cover`}" :style="{backgroundImage: `url(${data.secondSum})`}"
></div> ></div>
</div> </div>
<div class="ml-1 flex flex-row sm:flex-col sm:justify-around"> <div class="ml-1 flex flex-row sm:flex-col sm:justify-around">
@ -62,8 +63,8 @@
<div <div
v-for="(item, index) in data.items" v-for="(item, index) in data.items"
:key="index" :key="index"
:style="{background: item}" :style="{backgroundImage: item}"
class="ml-1 w-8 h-8 rounded-md bg-blue-1000" class="ml-1 w-8 h-8 rounded-md bg-blue-1000 bg-center bg-cover"
></div> ></div>
</div> </div>

View file

@ -29,9 +29,10 @@ export function createSummonerData(RiotData, championsInfos, runesInfos) {
// Loop on all matches // Loop on all matches
for (let i = 0; i < matches.length; i++) { for (let i = 0; i < matches.length; i++) {
const currentMatch = matches[i] const currentMatch = matches[i]
const participantId = currentMatch.participantIdentities.find((p) => p.player.currentAccountId === userStats.accountId).participantId - 1 const participantId = currentMatch.participantIdentities.find((p) => p.player.currentAccountId === userStats.accountId).participantId
const player = currentMatch.participants[participantId - 1]
const teamId = player.teamId
const teamId = currentMatch.participants[participantId].teamId
let win = currentMatch.teams.find((t) => t.teamId === teamId).win let win = currentMatch.teams.find((t) => t.teamId === teamId).win
// Match less than 5min // Match less than 5min
@ -43,27 +44,36 @@ export function createSummonerData(RiotData, championsInfos, runesInfos) {
let mode = gameModes[currentMatch.queueId] let mode = gameModes[currentMatch.queueId]
if (!mode) if (!mode)
mode = 'Undefined gamemode' mode = 'Undefined gamemode'
const champion = Object.entries(championsInfos).find(([, champion]) => Number(champion.key) === currentMatch.participants[participantId].championId)[0] const champion = Object.entries(championsInfos).find(([, champion]) => Number(champion.key) === player.championId)[0]
const role = currentMatch.participants[participantId].timeline.lane
let role = player.timeline.lane
if(role === 'BOTTOM') {
if(player.timeline.role.includes('SUPPORT')) {
role = 'SUPPORT'
} else {
role = 'BOTTOM'
}
}
const timeAgo = timeDifference(currentMatch.gameCreation) const timeAgo = timeDifference(currentMatch.gameCreation)
const time = secToTime(currentMatch.gameDuration) const time = secToTime(currentMatch.gameDuration)
const kills = currentMatch.participants[participantId].stats.kills const kills = player.stats.kills
const deaths = currentMatch.participants[participantId].stats.deaths const deaths = player.stats.deaths
const assists = currentMatch.participants[participantId].stats.assists const assists = player.stats.assists
const kda = ((kills + assists) / deaths).toFixed(2) const kda = ((kills + assists) / deaths).toFixed(2)
const level = currentMatch.participants[participantId].stats.champLevel const level = player.stats.champLevel
const damage = (currentMatch.participants[participantId].stats.totalDamageDealtToChampions / 1000).toFixed(1) + 'k' const damage = (player.stats.totalDamageDealtToChampions / 1000).toFixed(1) + 'k'
const primaryRuneCategory = runesInfos.find(r => r.id === currentMatch.participants[participantId].stats.perkPrimaryStyle) const primaryRuneCategory = runesInfos.find(r => r.id === player.stats.perkPrimaryStyle)
let primaryRune let primaryRune
for (const subCat of primaryRuneCategory.slots) { for (const subCat of primaryRuneCategory.slots) {
primaryRune = subCat.runes.find(r => r.id === currentMatch.participants[participantId].stats.perk0) primaryRune = subCat.runes.find(r => r.id === player.stats.perk0)
if (primaryRune) { if (primaryRune) {
break break
} }
} }
primaryRune = `https://ddragon.leagueoflegends.com/cdn/img/${primaryRune.icon}` primaryRune = `https://ddragon.leagueoflegends.com/cdn/img/${primaryRune.icon}`
let secondaryRune = runesInfos.find(r => r.id === currentMatch.participants[participantId].stats.perkSubStyle) let secondaryRune = runesInfos.find(r => r.id === player.stats.perkSubStyle)
secondaryRune = `https://ddragon.leagueoflegends.com/cdn/img/${secondaryRune.icon}` secondaryRune = `https://ddragon.leagueoflegends.com/cdn/img/${secondaryRune.icon}`
@ -78,14 +88,14 @@ export function createSummonerData(RiotData, championsInfos, runesInfos) {
const items = [] const items = []
for (let i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
const currentItem = 'item' + i const currentItem = 'item' + i
items.push(getItemLink(currentMatch.participants[participantId].stats[currentItem])) items.push(getItemLink(player.stats[currentItem]))
} }
const gold = (currentMatch.participants[participantId].stats.goldEarned / 1000).toFixed(1) + 'k' const gold = (player.stats.goldEarned / 1000).toFixed(1) + 'k'
const minions = currentMatch.participants[participantId].stats.totalMinionsKilled + currentMatch.participants[participantId].stats.neutralMinionsKilled const minions = player.stats.totalMinionsKilled + player.stats.neutralMinionsKilled
const firstSum = currentMatch.participants[participantId].spell1Id const firstSum = player.spell1Id
const secondSum = currentMatch.participants[participantId].spell2Id const secondSum = player.spell2Id
matchesInfos.push({ matchesInfos.push({
result: win, result: win,
@ -126,7 +136,10 @@ export function createSummonerData(RiotData, championsInfos, runesInfos) {
} }
function getItemLink(id) { function getItemLink(id) {
return `url('https://ddragon.leagueoflegends.com/cdn/${process.env.VUE_APP_PATCH}/img/item/${id === 0 ? 3637 : id}.png') no-repeat center center / contain` if(id === 0) {
return null
}
return `url('https://ddragon.leagueoflegends.com/cdn/${process.env.VUE_APP_PATCH}/img/item/${id}.png')`
} }
function getSummonerLink(id) { function getSummonerLink(id) {