mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
fix: add summoner roles only to specific gamemodes
This commit is contained in:
parent
9552d2b103
commit
30301e7cd2
4 changed files with 26 additions and 6 deletions
|
|
@ -55,7 +55,7 @@ class BasicMatchTransformer extends MatchTransformer {
|
|||
const playerInfos = {
|
||||
account_id: summoner.player.currentAccountId,
|
||||
name: summoner.player.summonerName,
|
||||
role: super.getRoleName(allData.timeline),
|
||||
role: super.getRoleName(allData.timeline, match.queueId),
|
||||
champion: super.getChampion(allData.championId)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
const MatchTransformer = use('App/Transformers/MatchTransformer')
|
||||
const RoleIdentificationService = use('App/Services/RoleIdentificationService')
|
||||
const SummonerService = use('App/Services/SummonerService')
|
||||
const { queuesWithRole } = use('App/helpers')
|
||||
|
||||
/**
|
||||
* LiveMatchTransformer class
|
||||
|
|
@ -42,7 +43,7 @@ class LiveMatchTransformer extends MatchTransformer {
|
|||
const redTeam = [] // 200
|
||||
let blueRoles = []
|
||||
let redRoles = []
|
||||
if (this.championRoles) {
|
||||
if (this.championRoles && queuesWithRole.includes(match.gameQueueConfigId)) {
|
||||
match.participants.map(p => {
|
||||
const playerRole = { champion: p.championId, jungle: p.spell1Id === 11 || p.spell2Id === 11 }
|
||||
p.teamId === 100 ? blueTeam.push(playerRole) : redTeam.push(playerRole)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
'use strict'
|
||||
|
||||
const Jax = use('App/Services/Jax')
|
||||
const Helpers = use('App/helpers')
|
||||
const RoleIdentificationService = use('App/Services/RoleIdentificationService')
|
||||
const { queuesWithRole, sortTeamByRole } = use('App/helpers')
|
||||
|
||||
/**
|
||||
* MatchTransformer class
|
||||
|
|
@ -27,7 +27,7 @@ class MatchTransformer {
|
|||
this.perkstyles = perkstyles.styles
|
||||
this.summonerSpells = summonerSpells
|
||||
this.championRoles = championRoles
|
||||
this.sortTeamByRole = Helpers.sortTeamByRole
|
||||
this.sortTeamByRole = sortTeamByRole
|
||||
|
||||
// League of Legends seasons timestamps
|
||||
this.seasons = {
|
||||
|
|
@ -79,7 +79,7 @@ class MatchTransformer {
|
|||
const identity = match.participantIdentities.find(p => p.participantId === player.participantId)
|
||||
const name = identity.player.summonerName
|
||||
const champion = this.getChampion(player.championId)
|
||||
const role = this.getRoleName(player.timeline)
|
||||
const role = this.getRoleName(player.timeline, match.queueId)
|
||||
const level = player.stats.champLevel
|
||||
|
||||
// Regular stats / Full match stats
|
||||
|
|
@ -193,11 +193,17 @@ class MatchTransformer {
|
|||
/**
|
||||
* Return the lane of the summoner according to timeline
|
||||
* @param timeline from Riot Api
|
||||
* @param gamemode of the match to check if a role is needed
|
||||
*/
|
||||
getRoleName(timeline) {
|
||||
getRoleName(timeline, gamemode) {
|
||||
if(!queuesWithRole.includes(gamemode)) {
|
||||
return 'NONE'
|
||||
}
|
||||
|
||||
if (timeline.lane === 'BOTTOM' && timeline.role.includes('SUPPORT')) {
|
||||
return 'SUPPORT'
|
||||
}
|
||||
|
||||
return timeline.lane
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
/**
|
||||
* League of Legends queues with defined role for each summoner
|
||||
*/
|
||||
const queuesWithRole = [
|
||||
0, // Custom
|
||||
400, // Draft
|
||||
420, // Solo/Duo
|
||||
430, // Blind,
|
||||
440, // Flex
|
||||
700, // Clash
|
||||
]
|
||||
|
||||
/**
|
||||
* League of Legends seasons timestamps
|
||||
*/
|
||||
|
|
@ -7,6 +19,7 @@ const seasons = {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
queuesWithRole,
|
||||
seasons,
|
||||
/**
|
||||
* Get season number for a match
|
||||
|
|
|
|||
Loading…
Reference in a new issue