mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 21:07:27 +00:00
feat: add SoloQ winrate
This commit is contained in:
parent
db939459a0
commit
f48bfc92ec
2 changed files with 27 additions and 19 deletions
|
|
@ -15,6 +15,15 @@ export function createSummonerData(RiotData, championsInfos) {
|
||||||
const soloQStats = RiotData.soloQ
|
const soloQStats = RiotData.soloQ
|
||||||
const matches = RiotData.matchesDetails
|
const matches = RiotData.matchesDetails
|
||||||
|
|
||||||
|
const soloQ = soloQStats ? {} : null
|
||||||
|
if (soloQ) {
|
||||||
|
soloQ.rank = soloQStats.rank
|
||||||
|
soloQ.rankImgLink = getRankImg(soloQStats)
|
||||||
|
soloQ.wins = soloQStats.wins
|
||||||
|
soloQ.losses = soloQStats.losses
|
||||||
|
soloQ.winrate = (soloQ.wins * 100 / (soloQ.wins + soloQ.losses)).toFixed(1) + '%'
|
||||||
|
}
|
||||||
|
|
||||||
const matchesInfos = []
|
const matchesInfos = []
|
||||||
// Loop on all matches
|
// Loop on all matches
|
||||||
for (let i = 0; i < matches.length; i++) {
|
for (let i = 0; i < matches.length; i++) {
|
||||||
|
|
@ -78,10 +87,7 @@ export function createSummonerData(RiotData, championsInfos) {
|
||||||
profileIconId: userStats.profileIconId,
|
profileIconId: userStats.profileIconId,
|
||||||
name: userStats.name,
|
name: userStats.name,
|
||||||
level: userStats.summonerLevel,
|
level: userStats.summonerLevel,
|
||||||
rank: soloQStats ? soloQStats.tier + ' ' + soloQStats.rank : 'Player is unranked',
|
soloQ,
|
||||||
rankImgLink: getRankImg(soloQStats),
|
|
||||||
rankedWins: soloQStats ? soloQStats.wins : undefined,
|
|
||||||
rankedLosses: soloQStats ? soloQStats.losses : undefined
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,26 +16,28 @@
|
||||||
<div class="mt-4 mx-auto p-4 text-center bg-blue-100 border border-gray-300 rounded-lg">
|
<div class="mt-4 mx-auto p-4 text-center bg-blue-100 border border-gray-300 rounded-lg">
|
||||||
<div
|
<div
|
||||||
class="mx-auto w-16 h-16 bg-gray-300"
|
class="mx-auto w-16 h-16 bg-gray-300"
|
||||||
:style="{background: `url(https://ddragon.leagueoflegends.com/cdn/${this.$patch}/img/profileicon/${localInfos.profileIconId}.png) center/cover`}"
|
:style="{background: `url(https://ddragon.leagueoflegends.com/cdn/${this.$patch}/img/profileicon/${summonerInfos.profileIconId}.png) center/cover`}"
|
||||||
></div>
|
></div>
|
||||||
<h1 class="player__name">{{ localInfos.name }}</h1>
|
<h1>{{ summonerInfos.name }}</h1>
|
||||||
<h3 class="player__level">{{ localInfos.level }}</h3>
|
<h3>{{ summonerInfos.level }}</h3>
|
||||||
<h3 class="player__rank">{{ localInfos.rank }}</h3>
|
|
||||||
<div
|
|
||||||
class="mx-auto w-16 h-16 bg-gray-300"
|
|
||||||
:style="{background: `url(${localInfos.rankImgLink}) center/cover`}"
|
|
||||||
></div>
|
|
||||||
<h3
|
|
||||||
class="player__ratio"
|
|
||||||
>{{ localInfos.rankedWins ? localInfos.rankedWins + ' wins / ' + localInfos.rankedLosses + ' losses' : localInfos.rank }}</h3>
|
|
||||||
|
|
||||||
<RecentActivity :matches="localInfos.allMatches" />
|
<div v-if="summonerInfos.soloQ">
|
||||||
|
<h3>{{ summonerInfos.rank }}</h3>
|
||||||
|
<div
|
||||||
|
class="mx-auto w-16 h-16 bg-gray-300"
|
||||||
|
:style="{background: `url(${summonerInfos.soloQ.rankImgLink}) center/cover`}"
|
||||||
|
></div>
|
||||||
|
<h3>{{ `${summonerInfos.soloQ.wins} wins / ${summonerInfos.soloQ.losses} losses` }}</h3>
|
||||||
|
<span>Winrate: {{ summonerInfos.soloQ.winrate }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<RecentActivity :matches="summonerInfos.allMatches" />
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<Match
|
<Match
|
||||||
v-for="(match, index) in localInfos.matches"
|
v-for="(match, index) in summonerInfos.matches"
|
||||||
:key="index"
|
:key="index"
|
||||||
:data="localInfos.matches[index]"
|
:data="summonerInfos.matches[index]"
|
||||||
/>
|
/>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -75,7 +77,7 @@ export default {
|
||||||
return this.$route.params.region
|
return this.$route.params.region
|
||||||
},
|
},
|
||||||
...mapState({
|
...mapState({
|
||||||
localInfos: state => state.summoner.infos
|
summonerInfos: state => state.summoner.infos
|
||||||
}),
|
}),
|
||||||
...mapGetters('ddragon', ['areChampionsLoaded']),
|
...mapGetters('ddragon', ['areChampionsLoaded']),
|
||||||
...mapGetters('summoner', ['summonerFound', 'summonerNotFound', 'summonerLoading'])
|
...mapGetters('summoner', ['summonerFound', 'summonerNotFound', 'summonerLoading'])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue