{{ data.time }}
{{ data.date }}
@@ -82,6 +118,16 @@ export default {
data: {
type: Object,
required: true
+ },
+ },
+
+ computed: {
+ matchResultClass() {
+ return {
+ 'win': this.data.result === 'Win',
+ 'loss': this.data.result === 'Fail',
+ 'remake': this.data.result === 'Remake',
+ }
}
}
}
@@ -89,66 +135,52 @@ export default {
diff --git a/client/src/data/data.js b/client/src/data/data.js
index aad19f8..8acaa83 100644
--- a/client/src/data/data.js
+++ b/client/src/data/data.js
@@ -1,3 +1,3 @@
export const maps = { 10: 'The Twisted Treeline', 11: "Summoner's Rift", 12: 'Howling Abyss' }
-export const gameModes = { 76: 'URF', 100: 'ARAM', 400: 'Normal (Draft)', 420: 'Ranked (Solo)', 430: 'Normal (Blind)', 440: 'Ranked (Flex)', 460: '3v3 Blind', 470: '3v3 Ranked (Flex)', 800: '3v3 Co-op vs. AI (Intermediate)', 810: '3v3 Co-op vs. AI (Intro)', 820: '3v3 Co-op vs. AI (Beginner)', 830: 'Co-op vs. AI (Intro)', 840: 'Co-op vs. AI (Beginner)', 850: 'Co-op vs. AI (Intermediate)' }
+export const gameModes = { 76: 'URF', 100: 'ARAM', 400: 'DRAFT 5vs5', 420: 'Solo/Duo', 430: 'BLIND 5v5', 440: 'FLEX 5vs5', 460: 'BLIND 3vs3', 470: 'FLEX 3vs3', 800: '3v3 Co-op vs. AI (Intermediate)', 810: '3v3 Co-op vs. AI (Intro)', 820: '3v3 Co-op vs. AI (Beginner)', 830: 'Co-op vs. AI (Intro)', 840: 'Co-op vs. AI (Beginner)', 850: 'Co-op vs. AI (Intermediate)' }
diff --git a/client/src/helpers/summoner.js b/client/src/helpers/summoner.js
index f2272dc..46fcae2 100644
--- a/client/src/helpers/summoner.js
+++ b/client/src/helpers/summoner.js
@@ -7,7 +7,7 @@ import summonersJSON from '@/data/summoner.json'
* @param {Object} RiotData : all data from the Riot API
* @param {Object} championsInfos : champions data from the Riot API
*/
-export function createSummonerData(RiotData, championsInfos) {
+export function createSummonerData(RiotData, championsInfos, runesInfos) {
console.log('--- ALL INFOS ---')
console.log(RiotData)
@@ -21,43 +21,71 @@ export function createSummonerData(RiotData, championsInfos) {
soloQ.rankImgLink = getRankImg(soloQStats)
soloQ.wins = soloQStats.wins
soloQ.losses = soloQStats.losses
- soloQ.winrate = (soloQ.wins * 100 / (soloQ.wins + soloQ.losses)).toFixed(1) + '%'
- soloQ.lp = soloQStats.leaguePoints
+ soloQ.winrate = (soloQ.wins * 100 / (soloQ.wins + soloQ.losses)).toFixed(1) + '%'
+ soloQ.lp = soloQStats.leaguePoints
}
const matchesInfos = []
// Loop on all matches
for (let i = 0; i < matches.length; i++) {
const currentMatch = matches[i]
- const participantId = currentMatch.participantIdentities.find((p) => p.player.currentAccountId === userStats.accountId).participantId
+ const participantId = currentMatch.participantIdentities.find((p) => p.player.currentAccountId === userStats.accountId).participantId - 1
- const teamId = currentMatch.participants[participantId - 1].teamId
- const win = currentMatch.teams.find((t) => t.teamId === teamId).win === 'Win'
+ const teamId = currentMatch.participants[participantId].teamId
+ let win = currentMatch.teams.find((t) => t.teamId === teamId).win
+
+ // Match less than 5min
+ if (currentMatch.gameDuration < 300) {
+ win = 'Remake'
+ }
const map = maps[currentMatch.mapId]
let mode = gameModes[currentMatch.queueId]
if (!mode)
mode = 'Undefined gamemode'
- const champion = Object.entries(championsInfos).find(([, champion]) => Number(champion.key) === currentMatch.participants[participantId - 1].championId)[0]
- const role = currentMatch.participants[participantId - 1].timeline.lane
+ const champion = Object.entries(championsInfos).find(([, champion]) => Number(champion.key) === currentMatch.participants[participantId].championId)[0]
+ const role = currentMatch.participants[participantId].timeline.lane
const timeAgo = timeDifference(currentMatch.gameCreation)
const time = secToTime(currentMatch.gameDuration)
- const kills = currentMatch.participants[participantId - 1].stats.kills
- const deaths = currentMatch.participants[participantId - 1].stats.deaths
- const assists = currentMatch.participants[participantId - 1].stats.assists
- const level = currentMatch.participants[participantId - 1].stats.champLevel
+ const kills = currentMatch.participants[participantId].stats.kills
+ const deaths = currentMatch.participants[participantId].stats.deaths
+ const assists = currentMatch.participants[participantId].stats.assists
+ const kda = ((kills + assists) / deaths).toFixed(2)
+ const level = currentMatch.participants[participantId].stats.champLevel
+ const damage = (currentMatch.participants[participantId].stats.totalDamageDealtToChampions / 1000).toFixed(1) + 'k'
+
+ const primaryRuneCategory = runesInfos.find(r => r.id === currentMatch.participants[participantId].stats.perkPrimaryStyle)
+ let primaryRune
+ for (const subCat of primaryRuneCategory.slots) {
+ primaryRune = subCat.runes.find(r => r.id === currentMatch.participants[participantId].stats.perk0)
+ if (primaryRune) {
+ break
+ }
+ }
+ primaryRune = `https://ddragon.leagueoflegends.com/cdn/img/${primaryRune.icon}`
+ let secondaryRune = runesInfos.find(r => r.id === currentMatch.participants[participantId].stats.perkSubStyle)
+ secondaryRune = `https://ddragon.leagueoflegends.com/cdn/img/${secondaryRune.icon}`
+
+
+ const totalKills = currentMatch.participants.reduce((prev, current) => {
+ if (current.teamId !== teamId) {
+ return prev
+ }
+ return prev + current.stats.kills
+ }, 0)
+ const kp = ((kills + assists) * 100 / totalKills).toFixed(1) + '%'
const items = []
for (let i = 0; i < 6; i++) {
const currentItem = 'item' + i
- items.push(getItemLink(currentMatch.participants[participantId - 1].stats[currentItem]))
+ items.push(getItemLink(currentMatch.participants[participantId].stats[currentItem]))
}
- const gold = (currentMatch.participants[participantId - 1].stats.goldEarned / 1000).toFixed(1) + 'k'
- const minions = currentMatch.participants[participantId - 1].stats.totalMinionsKilled + currentMatch.participants[participantId - 1].stats.neutralMinionsKilled
+ const gold = (currentMatch.participants[participantId].stats.goldEarned / 1000).toFixed(1) + 'k'
+ const minions = currentMatch.participants[participantId].stats.totalMinionsKilled + currentMatch.participants[participantId].stats.neutralMinionsKilled
- const firstSum = currentMatch.participants[participantId - 1].spell1Id
- const secondSum = currentMatch.participants[participantId - 1].spell2Id
+ const firstSum = currentMatch.participants[participantId].spell1Id
+ const secondSum = currentMatch.participants[participantId].spell2Id
matchesInfos.push({
result: win,
@@ -65,12 +93,17 @@ export function createSummonerData(RiotData, championsInfos) {
gamemode: mode,
champ: champion,
role: role,
+ primaryRune,
+ secondaryRune,
date: timeAgo,
time: time,
kills: kills,
deaths: deaths,
assists: assists,
+ kda,
level: level,
+ damage,
+ kp,
items: items,
gold: gold,
minions: minions,
diff --git a/client/src/store/modules/ddragon.js b/client/src/store/modules/ddragon.js
index 15f8794..fac4572 100644
--- a/client/src/store/modules/ddragon.js
+++ b/client/src/store/modules/ddragon.js
@@ -3,12 +3,16 @@ import { axios } from '@/plugins/axios'
export const namespaced = true
export const state = {
- champions: []
+ champions: [],
+ runes: []
}
export const mutations = {
PUSH_CHAMPIONS(state, champions) {
state.champions = champions
+ },
+ PUSH_RUNES(state, runes) {
+ state.runes = runes
}
}
@@ -18,7 +22,14 @@ export const actions = {
const endpoint = 'Champion'
const resp = await axios(({ url: 'ddragon', data: { endpoint }, method: 'POST' }))
commit('PUSH_CHAMPIONS', resp.data.data)
- }
+ },
+
+ async getRunes({ commit }) {
+ console.log('API CALL FOR RUNES')
+ const endpoint = 'Rune'
+ const resp = await axios(({ url: 'ddragon', data: { endpoint }, method: 'POST' }))
+ commit('PUSH_RUNES', resp.data)
+ },
}
export const getters = {
diff --git a/client/src/store/modules/summoner.js b/client/src/store/modules/summoner.js
index 4b1982b..f378061 100644
--- a/client/src/store/modules/summoner.js
+++ b/client/src/store/modules/summoner.js
@@ -28,7 +28,7 @@ export const actions = {
try {
const resp = await axios(({ url: 'api', data: { summoner, region }, method: 'POST' }))
if (resp.data) {
- const infos = createSummonerData(resp.data, rootState.ddragon.champions)
+ const infos = createSummonerData(resp.data, rootState.ddragon.champions, rootState.ddragon.runes)
commit('SUMMONER_FOUND', infos)
} else {
commit('SUMMONER_NOT_FOUND')
diff --git a/client/src/views/Summoner.vue b/client/src/views/Summoner.vue
index ea9c5d3..db0a6ce 100644
--- a/client/src/views/Summoner.vue
+++ b/client/src/views/Summoner.vue
@@ -152,12 +152,14 @@ export default {
if (!this.areChampionsLoaded)
await this.getChampions()
+ await this.getRunes()
+
this.summonerRequest({ summoner: this.summoner, region: this.region })
},
redirect(summoner, region) {
this.$router.push(`/summoner/${region}/${summoner}`)
},
- ...mapActions('ddragon', ['getChampions']),
+ ...mapActions('ddragon', ['getChampions', 'getRunes']),
...mapActions('summoner', ['summonerRequest'])
}
}
diff --git a/client/tailwind.config.js b/client/tailwind.config.js
index a418018..3d58e42 100644
--- a/client/tailwind.config.js
+++ b/client/tailwind.config.js
@@ -248,6 +248,7 @@ module.exports = {
none: '0',
sm: '.125rem',
default: '.25rem',
+ md: '.375rem',
lg: '.5rem',
full: '9999px',
},
diff --git a/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonRuneEndpoint.js b/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonRuneEndpoint.js
new file mode 100644
index 0000000..a190ef2
--- /dev/null
+++ b/server/providers/Jax/src/Endpoints/DDragonEndpoints/DDragonRuneEndpoint.js
@@ -0,0 +1,17 @@
+const DDragonRequest = require('../../DDragonRequest')
+
+class DDragonRuneEndpoint {
+ constructor(version) {
+ this.version = version
+ }
+
+ list() {
+ return new DDragonRequest(
+ `runesReforged.json`,
+ 'cdn',
+ this.version
+ ).execute()
+ }
+}
+
+module.exports = DDragonRuneEndpoint
diff --git a/server/providers/Jax/src/Jax.js b/server/providers/Jax/src/Jax.js
index 1afb33c..d77313c 100644
--- a/server/providers/Jax/src/Jax.js
+++ b/server/providers/Jax/src/Jax.js
@@ -7,6 +7,7 @@ const SummonerEndpoint = require('./Endpoints/SummonerEndpoint')
const DDragonVersionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonVersionEndpoint')
const DDragonChampionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonChampionEndpoint')
+const DDragonRuneEndpoint = require('./Endpoints/DDragonEndpoints/DDragonRuneEndpoint')
class Jax {
constructor(key, env) {
@@ -30,6 +31,7 @@ class Jax {
this.DDragon = {
Champion: new DDragonChampionEndpoint(this.version),
+ Rune: new DDragonRuneEndpoint(this.version),
Version: this.version
}
}