mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 21:07:27 +00:00
feat: set player role to support if 1 player in the team has a supp item
This commit is contained in:
parent
5bf24d540a
commit
7bbf5edb4a
3 changed files with 28 additions and 10 deletions
|
|
@ -143,8 +143,9 @@ class RoleIdentificationService {
|
||||||
* @param championPositions
|
* @param championPositions
|
||||||
* @param composition
|
* @param composition
|
||||||
* @param jungle
|
* @param jungle
|
||||||
|
* @param support
|
||||||
*/
|
*/
|
||||||
getRoles(championPositions, composition, jungle = null) {
|
getRoles(championPositions, composition, jungle = null, support = null) {
|
||||||
const identified = {}
|
const identified = {}
|
||||||
let positions = {}
|
let positions = {}
|
||||||
let secondaryPositions = null
|
let secondaryPositions = null
|
||||||
|
|
@ -154,10 +155,14 @@ class RoleIdentificationService {
|
||||||
identified['JUNGLE'] = jungle
|
identified['JUNGLE'] = jungle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (support) {
|
||||||
|
identified['UTILITY'] = support
|
||||||
|
}
|
||||||
|
|
||||||
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,
|
||||||
identified.TOP, identified.JUNGLE, identified.MIDDLE, identified.ADC, identified.SUPPORT
|
identified.TOP, identified.JUNGLE, identified.MIDDLE, identified.ADC, identified.UTILITY
|
||||||
)
|
)
|
||||||
|
|
||||||
positions = bestPositions
|
positions = bestPositions
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const Jax = use('App/Services/Jax')
|
const Jax = use('App/Services/Jax')
|
||||||
const RoleIdentificationService = use('App/Services/RoleIdentificationService')
|
const RoleIdentificationService = use('App/Services/RoleIdentificationService')
|
||||||
const { getSeasonNumber, queuesWithRole, sortTeamByRole } = use('App/helpers')
|
const { getSeasonNumber, queuesWithRole, sortTeamByRole, supportItems } = use('App/helpers')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MatchTransformer class
|
* MatchTransformer class
|
||||||
|
|
@ -198,10 +198,12 @@ class MatchTransformer {
|
||||||
* @param team 5 champions + smite from a team
|
* @param team 5 champions + smite from a team
|
||||||
*/
|
*/
|
||||||
getTeamRoles(team) {
|
getTeamRoles(team) {
|
||||||
const teamJunglers = team.filter(p => p.jungle)
|
const teamJunglers = team.filter(p => p.jungle && !p.support)
|
||||||
const jungle = teamJunglers.length === 1 ? teamJunglers[0].champion : null
|
const jungle = teamJunglers.length === 1 ? teamJunglers[0].champion : null
|
||||||
|
const teamSupports = team.filter(p => p.support && !p.jungle)
|
||||||
|
const support = teamSupports.length === 1 ? teamSupports[0].champion : null
|
||||||
|
|
||||||
return RoleIdentificationService.getRoles(this.championRoles, team.map(p => p.champion), jungle)
|
return RoleIdentificationService.getRoles(this.championRoles, team.map(p => p.champion), jungle, support)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -211,10 +213,10 @@ class MatchTransformer {
|
||||||
* @param {Object} playerData data of the searched player, only for basic matches
|
* @param {Object} playerData data of the searched player, only for basic matches
|
||||||
*/
|
*/
|
||||||
updateTeamRoles(team, champs, playerData = null) {
|
updateTeamRoles(team, champs, playerData = null) {
|
||||||
const actualRoles = [...new Set(team.map(p => p.role))]
|
// const actualRoles = [...new Set(team.map(p => p.role))]
|
||||||
if (actualRoles.length === 5) {
|
// if (actualRoles.length === 5) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
champs = this.getTeamRoles(champs)
|
champs = this.getTeamRoles(champs)
|
||||||
for (const summoner of team) {
|
for (const summoner of team) {
|
||||||
|
|
@ -242,7 +244,12 @@ class MatchTransformer {
|
||||||
let allyChamps = []
|
let allyChamps = []
|
||||||
let enemyChamps = []
|
let enemyChamps = []
|
||||||
match.participants.map(p => {
|
match.participants.map(p => {
|
||||||
const playerRole = { champion: p.championId, jungle: p.spell1Id === 11 || p.spell2Id === 11 }
|
const items = [p.stats.item0, p.stats.item1, p.stats.item2, p.stats.item3, p.stats.item4, p.stats.item5]
|
||||||
|
const playerRole = {
|
||||||
|
champion: p.championId,
|
||||||
|
jungle: p.spell1Id === 11 || p.spell2Id === 11,
|
||||||
|
support: supportItems.some(suppItem => items.includes(suppItem))
|
||||||
|
}
|
||||||
p.teamId === allyTeamId ? allyChamps.push(playerRole) : enemyChamps.push(playerRole)
|
p.teamId === allyTeamId ? allyChamps.push(playerRole) : enemyChamps.push(playerRole)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,15 @@ const seasons = {
|
||||||
1578628800000: 10
|
1578628800000: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* League of Legends all support item ids
|
||||||
|
*/
|
||||||
|
const supportItems = [3850, 3851, 3853, 3854, 3855, 3857, 3858, 3859, 3860, 3862, 3863, 3864]
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
queuesWithRole,
|
queuesWithRole,
|
||||||
seasons,
|
seasons,
|
||||||
|
supportItems,
|
||||||
/**
|
/**
|
||||||
* Get season number for a match
|
* Get season number for a match
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue