diff --git a/server/app/Transformers/BasicMatchTransformer.js b/server/app/Transformers/BasicMatchTransformer.js index 71175a7..d534d8a 100644 --- a/server/app/Transformers/BasicMatchTransformer.js +++ b/server/app/Transformers/BasicMatchTransformer.js @@ -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) } diff --git a/server/app/Transformers/LiveMatchTransformer.js b/server/app/Transformers/LiveMatchTransformer.js index 63e7faa..02ff616 100644 --- a/server/app/Transformers/LiveMatchTransformer.js +++ b/server/app/Transformers/LiveMatchTransformer.js @@ -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) diff --git a/server/app/Transformers/MatchTransformer.js b/server/app/Transformers/MatchTransformer.js index 907d162..02c5b10 100644 --- a/server/app/Transformers/MatchTransformer.js +++ b/server/app/Transformers/MatchTransformer.js @@ -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 } diff --git a/server/app/helpers.js b/server/app/helpers.js index cdfd1af..09ee708 100644 --- a/server/app/helpers.js +++ b/server/app/helpers.js @@ -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