mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 21:07:27 +00:00
feat(basic-matches): add summonerSpell
This commit is contained in:
parent
218b97f88e
commit
96352669d0
4 changed files with 30 additions and 9 deletions
|
|
@ -35,11 +35,11 @@
|
||||||
></div>
|
></div>
|
||||||
<div class="flex flex-col justify-around ml-2">
|
<div class="flex flex-col justify-around ml-2">
|
||||||
<div
|
<div
|
||||||
:style="{backgroundImage: `url(${data.firstSum})`}"
|
:style="{backgroundImage: `url(${data.summonerSpell1.icon})`}"
|
||||||
class="w-6 h-6 bg-center bg-cover rounded-md bg-blue-1000"
|
class="w-6 h-6 bg-center bg-cover rounded-md bg-blue-1000"
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
:style="{backgroundImage: `url(${data.secondSum})`}"
|
:style="{backgroundImage: `url(${data.summonerSpell2.icon})`}"
|
||||||
class="w-6 h-6 bg-center bg-cover rounded-md bg-blue-1000"
|
class="w-6 h-6 bg-center bg-cover rounded-md bg-blue-1000"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,6 @@ const leaguesNumbers = { 'I': 1, 'II': 2, 'III': 3, 'IV': 4 }
|
||||||
*/
|
*/
|
||||||
export function createMatchData(matches) {
|
export function createMatchData(matches) {
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
match.firstSum = getSummonerLink(match.firstSum)
|
|
||||||
match.secondSum = getSummonerLink(match.secondSum)
|
|
||||||
|
|
||||||
const date = new Date(match.date)
|
const date = new Date(match.date)
|
||||||
const dateOptions = { day: '2-digit', month: '2-digit', year: 'numeric' }
|
const dateOptions = { day: '2-digit', month: '2-digit', year: 'numeric' }
|
||||||
const timeOptions = { hour12: false, hour: '2-digit', minute: '2-digit' }
|
const timeOptions = { hour12: false, hour: '2-digit', minute: '2-digit' }
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {
|
||||||
SerializedMatchItem,
|
SerializedMatchItem,
|
||||||
SerializedMatchPerks,
|
SerializedMatchPerks,
|
||||||
SerializedMatchStats,
|
SerializedMatchStats,
|
||||||
|
SerializedMatchSummonerSpell,
|
||||||
SerializedMatchTeamPlayer,
|
SerializedMatchTeamPlayer,
|
||||||
} from './SerializedTypes'
|
} from './SerializedTypes'
|
||||||
|
|
||||||
|
|
@ -45,6 +46,23 @@ class BasicMatchSerializer extends MatchSerializer {
|
||||||
return players.map((p) => this.getPlayerSummary(p)).sort(sortTeamByRole)
|
return players.map((p) => this.getPlayerSummary(p)).sort(sortTeamByRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Summoner Spell Data from CDragon
|
||||||
|
* @param id of the summonerSpell
|
||||||
|
*/
|
||||||
|
public getSummonerSpell(id: number): SerializedMatchSummonerSpell | null {
|
||||||
|
if (id === 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const spell = CDragonService.summonerSpells.find((s) => s.id === id)!
|
||||||
|
const spellName = spell.iconPath.split('/assets/')[1].toLowerCase()
|
||||||
|
return {
|
||||||
|
name: spell.name,
|
||||||
|
description: spell.description,
|
||||||
|
icon: `https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/${spellName}`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected getItems(player: MatchPlayer): Array<SerializedMatchItem | null> {
|
protected getItems(player: MatchPlayer): Array<SerializedMatchItem | null> {
|
||||||
const items: (SerializedMatchItem | null)[] = []
|
const items: (SerializedMatchItem | null)[] = []
|
||||||
for (let i = 0; i < 6; i++) {
|
for (let i = 0; i < 6; i++) {
|
||||||
|
|
@ -123,7 +141,6 @@ class BasicMatchSerializer extends MatchSerializer {
|
||||||
champion: this.getChampion(identity.championId),
|
champion: this.getChampion(identity.championId),
|
||||||
date: match.date,
|
date: match.date,
|
||||||
enemyTeam: this.getTeamSummary(enemyPlayers),
|
enemyTeam: this.getTeamSummary(enemyPlayers),
|
||||||
firstSum: identity.summoner1Id,
|
|
||||||
matchId: match.id,
|
matchId: match.id,
|
||||||
gamemode: match.gamemode,
|
gamemode: match.gamemode,
|
||||||
items: this.getItems(identity),
|
items: this.getItems(identity),
|
||||||
|
|
@ -135,9 +152,10 @@ class BasicMatchSerializer extends MatchSerializer {
|
||||||
result: allyTeam.result,
|
result: allyTeam.result,
|
||||||
role: identity.teamPosition.length ? identity.teamPosition : 'NONE',
|
role: identity.teamPosition.length ? identity.teamPosition : 'NONE',
|
||||||
season: getSeasonNumber(match.date),
|
season: getSeasonNumber(match.date),
|
||||||
secondSum: identity.summoner2Id,
|
|
||||||
stats: this.getStats(identity),
|
stats: this.getStats(identity),
|
||||||
summonerId: identity.summonerId,
|
summonerId: identity.summonerId,
|
||||||
|
summonerSpell1: this.getSummonerSpell(identity.summoner1Id),
|
||||||
|
summonerSpell2: this.getSummonerSpell(identity.summoner2Id),
|
||||||
summonerPuuid: puuid,
|
summonerPuuid: puuid,
|
||||||
time: match.gameDuration,
|
time: match.gameDuration,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ export interface SerializedMatch {
|
||||||
champion: SerializedMatchChampion
|
champion: SerializedMatchChampion
|
||||||
date: number
|
date: number
|
||||||
enemyTeam: SerializedMatchTeamPlayer[]
|
enemyTeam: SerializedMatchTeamPlayer[]
|
||||||
firstSum: number
|
|
||||||
matchId: string
|
matchId: string
|
||||||
gamemode: number
|
gamemode: number
|
||||||
items: Array<SerializedMatchItem | null>
|
items: Array<SerializedMatchItem | null>
|
||||||
|
|
@ -15,10 +14,11 @@ export interface SerializedMatch {
|
||||||
result: string
|
result: string
|
||||||
role: string
|
role: string
|
||||||
season: number
|
season: number
|
||||||
secondSum: number
|
|
||||||
stats: SerializedMatchStats
|
stats: SerializedMatchStats
|
||||||
summonerId: string
|
summonerId: string
|
||||||
summonerPuuid: string
|
summonerPuuid: string
|
||||||
|
summonerSpell1: SerializedMatchSummonerSpell | null
|
||||||
|
summonerSpell2: SerializedMatchSummonerSpell | null
|
||||||
time: number
|
time: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,6 +37,12 @@ export interface SerializedMatchChampion {
|
||||||
roles: string[]
|
roles: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SerializedMatchSummonerSpell {
|
||||||
|
name: string
|
||||||
|
description: string
|
||||||
|
icon: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface SerializedMatchItem {
|
export interface SerializedMatchItem {
|
||||||
description: string
|
description: string
|
||||||
image: string
|
image: string
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue