mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 21:07:27 +00:00
feat: set summoner role to jungle in live tab if he has a smite
This commit is contained in:
parent
93a46d3a9e
commit
b335b53869
2 changed files with 18 additions and 4 deletions
|
|
@ -142,13 +142,18 @@ class RoleIdentificationService {
|
||||||
* Get roles for the 5 players of a team
|
* Get roles for the 5 players of a team
|
||||||
* @param championPositions
|
* @param championPositions
|
||||||
* @param composition
|
* @param composition
|
||||||
|
* @param jungle
|
||||||
*/
|
*/
|
||||||
getRoles (championPositions, composition) {
|
getRoles (championPositions, composition, jungle = null) {
|
||||||
const identified = {}
|
const identified = {}
|
||||||
let positions = {}
|
let positions = {}
|
||||||
let secondaryPositions = null
|
let secondaryPositions = null
|
||||||
let secondaryMetric = -Infinity
|
let secondaryMetric = -Infinity
|
||||||
|
|
||||||
|
if(jungle) {
|
||||||
|
identified['JUNGLE'] = jungle
|
||||||
|
}
|
||||||
|
|
||||||
while (Object.keys(identified).length < composition.length - 1) {
|
while (Object.keys(identified).length < composition.length - 1) {
|
||||||
let { bestPositions, bestMetric: metric, secondBestPositions: sbp } =
|
let { bestPositions, bestMetric: metric, secondBestPositions: sbp } =
|
||||||
this._getPositions(championPositions, composition,
|
this._getPositions(championPositions, composition,
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,13 @@ class LiveMatchTransformer extends MatchTransformer {
|
||||||
return participant
|
return participant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getTeamRoles(team) {
|
||||||
|
const teamJunglers = team.filter(p => p.jungle)
|
||||||
|
const jungle = teamJunglers.length === 1 ? teamJunglers[0].champion : null
|
||||||
|
|
||||||
|
return RoleIdentificationService.getRoles(this.championRoles, team.map(p => p.champion), jungle)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform raw data from Riot API
|
* Transform raw data from Riot API
|
||||||
* @param match data from Riot API, one live match
|
* @param match data from Riot API, one live match
|
||||||
|
|
@ -37,10 +44,12 @@ class LiveMatchTransformer extends MatchTransformer {
|
||||||
let redRoles = []
|
let redRoles = []
|
||||||
if (this.championRoles) {
|
if (this.championRoles) {
|
||||||
match.participants.map(p => {
|
match.participants.map(p => {
|
||||||
p.teamId === 100 ? blueTeam.push(p.championId) : redTeam.push(p.championId)
|
const playerRole = { champion: p.championId, jungle: p.spell1Id === 11 || p.spell2Id === 11 }
|
||||||
|
p.teamId === 100 ? blueTeam.push(playerRole) : redTeam.push(playerRole)
|
||||||
})
|
})
|
||||||
blueRoles = RoleIdentificationService.getRoles(this.championRoles, blueTeam)
|
|
||||||
redRoles = RoleIdentificationService.getRoles(this.championRoles, redTeam)
|
blueRoles = this._getTeamRoles(blueTeam)
|
||||||
|
redRoles = this._getTeamRoles(redTeam)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const participant of match.participants) {
|
for (const participant of match.participants) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue