diff --git a/client/src/assets/img/roles/SUPPORT.png b/client/src/assets/img/roles/UTILITY.png similarity index 100% rename from client/src/assets/img/roles/SUPPORT.png rename to client/src/assets/img/roles/UTILITY.png diff --git a/client/src/helpers/functions.js b/client/src/helpers/functions.js index 7fbd380..2b2bae7 100644 --- a/client/src/helpers/functions.js +++ b/client/src/helpers/functions.js @@ -40,7 +40,7 @@ export function secToTime(seconds) { * Sort an array of players by role */ export function sortTeamByRole(a, b) { - const sortingArr = ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'SUPPORT'] + const sortingArr = ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'UTILITY'] return sortingArr.indexOf(a.role) - sortingArr.indexOf(b.role) } diff --git a/client/src/store/index.js b/client/src/store/index.js index 0a00df8..bdfefb5 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -32,7 +32,7 @@ export default new Vuex.Store({ 'tr': 'tr1', 'ru': 'ru' }, - roles: ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'SUPPORT'] + roles: ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'UTILITY'] }, strict: debug }) diff --git a/server-v2/app/Models/MatchPlayer.ts b/server-v2/app/Models/MatchPlayer.ts index a9a2918..2d9f84c 100644 --- a/server-v2/app/Models/MatchPlayer.ts +++ b/server-v2/app/Models/MatchPlayer.ts @@ -34,7 +34,7 @@ export default class MatchPlayer extends BaseModel { public team: number @column() - public teamPosition: string + public teamPosition: number @column() public kills: number diff --git a/server-v2/app/Models/MatchTeam.ts b/server-v2/app/Models/MatchTeam.ts index 7389b49..6f29a9b 100644 --- a/server-v2/app/Models/MatchTeam.ts +++ b/server-v2/app/Models/MatchTeam.ts @@ -30,8 +30,8 @@ export default class MatchTeam extends BaseModel { public riftHeralds: number @column() - public bans: number[] + public bans?: number[] @column() - public banOrders: number[] + public banOrders?: number[] } diff --git a/server-v2/app/Parsers/MatchParser.ts b/server-v2/app/Parsers/MatchParser.ts index a4c21e5..b2e2524 100644 --- a/server-v2/app/Parsers/MatchParser.ts +++ b/server-v2/app/Parsers/MatchParser.ts @@ -1,9 +1,9 @@ import Database from '@ioc:Adonis/Lucid/Database' import { MatchDto } from 'App/Services/Jax/src/Endpoints/MatchEndpoint' import Match from 'App/Models/Match' -import { getSeasonNumber } from 'App/helpers' +import { getSeasonNumber, queuesWithRole } from 'App/helpers' import CDragonService from 'App/Services/CDragonService' -import { ChampionRoles } from './ParsedType' +import { ChampionRoles, TeamPosition } from './ParsedType' class MatchParser { public async parseOneMatch(match: MatchDto) { // Parse + store in database @@ -34,8 +34,8 @@ class MatchParser { dragons: team.objectives.dragon.kills, inhibitors: team.objectives.inhibitor.kills, riftHeralds: team.objectives.riftHerald.kills, - bans: team.bans.map((ban) => ban.championId), - banOrders: team.bans.map((ban) => ban.pickTurn), + bans: team.bans.length ? team.bans.map((ban) => ban.championId) : undefined, + banOrders: team.bans.length ? team.bans.map((ban) => ban.pickTurn) : undefined, }) } @@ -65,6 +65,17 @@ class MatchParser { } } + // Fix championId bug in older matches + if (player.championId > 1000) { + console.log('CHAMPION ID NOT FOUND: ' + player.championId) + console.log('FROM MATCH ' + match.metadata.matchId) + const championId = Object.keys(CDragonService.champions).find( + (key) => CDragonService.champions[key].name === player.championName + ) + player.championId = championId ? Number(championId) : 1 + console.log('CHAMPION ID FROM NAME : ' + championId) + } + const originalChampionData = CDragonService.champions[player.championId] const champRoles = originalChampionData.roles @@ -75,7 +86,10 @@ class MatchParser { summoner_puuid: player.puuid, summoner_name: player.summonerName, team: player.teamId, - team_position: player.teamPosition, + team_position: + player.teamPosition.length && queuesWithRole.includes(match.info.queueId) + ? TeamPosition[player.teamPosition] + : TeamPosition.NONE, kills: player.kills, deaths: player.deaths, assists: player.assists, diff --git a/server-v2/app/Parsers/ParsedType.ts b/server-v2/app/Parsers/ParsedType.ts index d197a9d..2e2d0da 100644 --- a/server-v2/app/Parsers/ParsedType.ts +++ b/server-v2/app/Parsers/ParsedType.ts @@ -7,5 +7,11 @@ export enum ChampionRoles { tank, } -// TODO -export enum TeamPosition {} +export enum TeamPosition { + NONE, + TOP, + JUNGLE, + MIDDLE, + BOTTOM, + UTILITY, +} diff --git a/server-v2/app/Serializers/BasicMatchSerializer.ts b/server-v2/app/Serializers/BasicMatchSerializer.ts index 8c8be4f..4e7414a 100644 --- a/server-v2/app/Serializers/BasicMatchSerializer.ts +++ b/server-v2/app/Serializers/BasicMatchSerializer.ts @@ -1,6 +1,7 @@ import { getSeasonNumber, sortTeamByRole } from 'App/helpers' import Match from 'App/Models/Match' import MatchPlayer from 'App/Models/MatchPlayer' +import { TeamPosition } from 'App/Parsers/ParsedType' import CDragonService from 'App/Services/CDragonService' import MatchSerializer from './MatchSerializer' import { @@ -38,7 +39,7 @@ class BasicMatchSerializer extends MatchSerializer { puuid: player.summonerPuuid, champion: this.getChampion(player.championId), name: player.summonerName, - role: player.teamPosition, + role: TeamPosition[player.teamPosition], } } @@ -149,7 +150,7 @@ class BasicMatchSerializer extends MatchSerializer { perks: this.getPerks(identity), region: match.region, result: allyTeam.result, - role: identity.teamPosition.length ? identity.teamPosition : 'NONE', + role: TeamPosition[identity.teamPosition], season: getSeasonNumber(match.date), stats: this.getStats(identity), summonerId: identity.summonerId, diff --git a/server-v2/app/Services/CDragonService.ts b/server-v2/app/Services/CDragonService.ts index 12fc911..59f2c80 100644 --- a/server-v2/app/Services/CDragonService.ts +++ b/server-v2/app/Services/CDragonService.ts @@ -15,7 +15,7 @@ interface Identifiable { } export interface CDragonCache { - [id: number]: T + [id: string]: T } class CDragonService { diff --git a/server-v2/app/helpers.ts b/server-v2/app/helpers.ts index e6602b5..146927b 100644 --- a/server-v2/app/helpers.ts +++ b/server-v2/app/helpers.ts @@ -105,6 +105,6 @@ export function getCurrentSeason(): number { * @param b second player */ export function sortTeamByRole(a: SerializedMatchTeamPlayer, b: SerializedMatchTeamPlayer) { - const sortingArr = ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'SUPPORT'] + const sortingArr = ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'UTILITY'] return sortingArr.indexOf(a.role) - sortingArr.indexOf(b.role) } diff --git a/server-v2/database/migrations/1631392766690_match_players.ts b/server-v2/database/migrations/1631392766690_match_players.ts index 8cea6a7..b5f85e8 100644 --- a/server-v2/database/migrations/1631392766690_match_players.ts +++ b/server-v2/database/migrations/1631392766690_match_players.ts @@ -14,7 +14,7 @@ export default class MatchPlayers extends BaseSchema { table.string('summoner_name', 16).notNullable() table.integer('team').notNullable() - table.string('team_position', 8).notNullable() + table.integer('team_position').notNullable() table.integer('kills').notNullable() table.integer('deaths').notNullable() diff --git a/server-v2/database/migrations/1631397498477_match_teams.ts b/server-v2/database/migrations/1631397498477_match_teams.ts index 3dba8cc..c2b04d7 100644 --- a/server-v2/database/migrations/1631397498477_match_teams.ts +++ b/server-v2/database/migrations/1631397498477_match_teams.ts @@ -16,8 +16,8 @@ export default class MatchTeams extends BaseSchema { table.integer('inhibitors').notNullable() table.integer('rift_heralds').notNullable() - table.specificType('bans', 'INT[]').notNullable() - table.specificType('ban_orders', 'INT[]').notNullable() + table.specificType('bans', 'INT[]').nullable() + table.specificType('ban_orders', 'INT[]').nullable() }) }