-
+
handleSubtreeMount(end)" :tree="child" />
diff --git a/frontend/pages/champion/[alias].vue b/frontend/pages/champion/[alias].vue
index da48190..1532ee6 100644
--- a/frontend/pages/champion/[alias].vue
+++ b/frontend/pages/champion/[alias].vue
@@ -1,11 +1,18 @@
-
@@ -13,13 +20,15 @@ const state = ref("runes")
{{ championData.name }} - BuildPath
- state = newState"/>
+
-
-
-
+
+
+
Sorry, there is no data for this champion :(
diff --git a/frontend/types/api.ts b/frontend/types/api.ts
new file mode 100644
index 0000000..e7b9401
--- /dev/null
+++ b/frontend/types/api.ts
@@ -0,0 +1,43 @@
+declare global {
+ type ItemTree = {
+ count: number
+ data: number
+ children: Array
+ }
+ type Builds = {
+ start: Array<{count: number, data: number}>
+ tree: ItemTree
+ bootsFirst: number
+ boots: Array<{count: number, data: number}>
+ lateGame: Array<{count: number, data: number}>
+ }
+ type Rune = {
+ count: number
+ primaryStyle: number
+ secondaryStyle: number
+ selections: Array
+ pickrate: number
+ }
+ type LaneData = {
+ data: string
+ count: number
+ winningMatches: number
+ losingMatches: number
+ winrate: number
+ pickrate: number
+ runes: Array
+ builds: Builds
+ }
+
+ type ChampionData = {
+ id: number
+ name: string
+ alias: string
+ gameCount: number
+ winrate: number
+ pickrate: number
+ lanes: Array
+ }
+}
+
+export {};
\ No newline at end of file
diff --git a/frontend/types/items.ts b/frontend/types/items.ts
deleted file mode 100644
index c1f683a..0000000
--- a/frontend/types/items.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-declare global {
- type ItemTree = {
- count: number
- data: number
- children: Array
- }
- type Builds = {
- start: Array<{count: number, data: number}>
- tree: ItemTree
- bootsFirst: number
- boots: Array<{count: number, data: number}>
- lateGame: Array<{count: number, data: number}>
- }
-}
-
-export {};
\ No newline at end of file
diff --git a/frontend/utils/cdragon.js b/frontend/utils/cdragon.js
deleted file mode 100644
index 43da459..0000000
--- a/frontend/utils/cdragon.js
+++ /dev/null
@@ -1,8 +0,0 @@
-const CDRAGON_BASE = "https://raw.communitydragon.org/latest/"
-
-function mapPath(assetPath) {
- if(assetPath === undefined || assetPath === null) return ""
- return assetPath.toLowerCase().replace("/lol-game-data/assets/", "plugins/rcp-be-lol-game-data/global/default/")
-}
-
-export { mapPath, CDRAGON_BASE}
\ No newline at end of file
diff --git a/frontend/utils/cdragon.ts b/frontend/utils/cdragon.ts
new file mode 100644
index 0000000..942d62b
--- /dev/null
+++ b/frontend/utils/cdragon.ts
@@ -0,0 +1,31 @@
+const CDRAGON_BASE = "https://raw.communitydragon.org/latest/"
+
+/* Lanes */
+const POSITIONS = ["top", "jungle", "middle", "bottom", "utility"]
+const LANE_IMAGES = Array(5).fill("").map((_, index) => "/img/lanes/icon-position-" + POSITIONS[index] + ".png")
+const LANE_IMAGES_HOVER = Array(5).fill("").map((_, index) => "/img/lanes/icon-position-" + POSITIONS[index] + "-hover.png")
+const LANE_IMAGES_SELECTED = Array(5).fill("").map((_, index) => "/img/lanes/icon-position-" + POSITIONS[index] + "-blue.png")
+function laneIndexToPosition(index : number) {
+ switch(index) {
+ case 0: return "top"
+ case 1: return "jungle"
+ case 2: return "middle"
+ case 3: return "bottom"
+ case 4: return "utility"
+ }
+ return null
+}
+function lanePositionToIndex(position : string) {
+ const p = position.toLowerCase()
+ for(let i = 0; i < POSITIONS.length; i++) {
+ if(p == POSITIONS[i]) return i;
+ }
+ return -1;
+}
+
+function mapPath(assetPath : string) {
+ if(assetPath === undefined || assetPath === null) return ""
+ return assetPath.toLowerCase().replace("/lol-game-data/assets/", "plugins/rcp-be-lol-game-data/global/default/")
+}
+
+export { mapPath, CDRAGON_BASE, laneIndexToPosition, lanePositionToIndex, POSITIONS, LANE_IMAGES, LANE_IMAGES_HOVER, LANE_IMAGES_SELECTED}
\ No newline at end of file
diff --git a/match_collector/champion_stat.ts b/match_collector/champion_stat.ts
index 8b0c866..abf37d1 100644
--- a/match_collector/champion_stat.ts
+++ b/match_collector/champion_stat.ts
@@ -46,6 +46,16 @@ type Champion = {
name: String
alias: String
}
+type LaneData = {
+ data: string
+ count: number
+ winningMatches: number
+ losingMatches: number
+ winrate: number
+ pickrate: number
+ runes: Array
+ builds: Builds
+}
function handleParticipantRunes(participant, runes: Array) {
const primaryStyle = participant.perks.styles[0].style
@@ -141,9 +151,7 @@ async function championInfos(client, patch: number, champion: Champion) {
let winningMatches = 0;
let losingMatches = 0;
let totalMatches = 0;
- const lanes : Array<{data: string, count: number}> = [];
- const runes : Array = [];
- const builds : Builds = {tree:treeInit(), start: [], bootsFirst: 0, boots: [], lateGame: []}
+ const lanes : Array = [];
for await (let match of allMatches) {
totalMatches += 1;
let participantIndex = 0;
@@ -158,16 +166,24 @@ async function championInfos(client, patch: number, champion: Champion) {
losingMatches += 1;
// Lanes
- // TODO: make stats lane-dependant
- const already = lanes.find((x) => x.data == participant.teamPosition)
- if(already == undefined) lanes.push({count:1, data: participant.teamPosition})
- else already.count += 1
+ let lane = lanes.find((x) => x.data == participant.teamPosition)
+ if(lane == undefined) {
+ const builds : Builds = {tree:treeInit(), start: [], bootsFirst: 0, boots: [], lateGame: []}
+ lane = {count:1, data: participant.teamPosition, runes:[], builds:builds, winningMatches: 0, losingMatches: 0, winrate: 0, pickrate: 0}
+ lanes.push(lane)
+ }
+ else lane.count += 1
+
+ if(participant.win)
+ lane.winningMatches += 1;
+ else
+ lane.losingMatches += 1;
// Runes
- handleParticipantRunes(participant, runes)
+ handleParticipantRunes(participant, lane.runes)
// Items
- handleMatchItems(match.timeline, participantIndex, builds)
+ handleMatchItems(match.timeline, participantIndex, lane.builds)
break;
}
@@ -179,31 +195,44 @@ async function championInfos(client, patch: number, champion: Champion) {
lanes.sort((a, b) => b.count - a.count)
// Filter runes to keep 3 most played
- runes.sort((a, b) => b.count - a.count)
- if(runes.length > 3)
- runes.splice(3, runes.length - 3)
- // Compute runes pickrate
- for(let rune of runes)
- rune.pickrate = rune.count / totalChampionMatches;
+ for(let lane of lanes) {
+ const runes = lane.runes
+
+ runes.sort((a, b) => b.count - a.count)
+ if(runes.length > 3)
+ runes.splice(3, runes.length - 3)
+ // Compute runes pickrate
+ for(let rune of runes)
+ rune.pickrate = rune.count / lane.count;
+ }
- // Cut item tree branches to keep only 4 branches every time and with percentage threshold
- builds.tree.count = totalChampionMatches;
- treeCutBranches(builds.tree, 4, 0.05)
- treeSort(builds.tree)
+ for(let lane of lanes) {
+ const builds = lane.builds
- // Cut item start, to only 4 and with percentage threshold
- arrayRemovePercentage(builds.start, totalChampionMatches, 0.05)
- builds.start.sort((a, b) => b.count - a.count)
- if(builds.start.length > 4)
- builds.start.splice(4, builds.start.length - 4)
+ // Cut item tree branches to keep only 4 branches every time and with percentage threshold
+ builds.tree.count = lane.count;
+ treeCutBranches(builds.tree, 4, 0.05)
+ treeSort(builds.tree)
+
+ // Cut item start, to only 4 and with percentage threshold
+ arrayRemovePercentage(builds.start, lane.count, 0.05)
+ builds.start.sort((a, b) => b.count - a.count)
+ if(builds.start.length > 4)
+ builds.start.splice(4, builds.start.length - 4)
- // Remove boots that are not within percentage threshold
- arrayRemovePercentage(builds.boots, totalChampionMatches, 0.05)
- builds.boots.sort((a, b) => b.count - a.count)
+ // Remove boots that are not within percentage threshold
+ arrayRemovePercentage(builds.boots, lane.count, 0.05)
+ builds.boots.sort((a, b) => b.count - a.count)
- builds.bootsFirst /= (winningMatches + losingMatches)
+ builds.bootsFirst /= lane.count
- builds.lateGame.sort((a, b) => b.count - a.count)
+ builds.lateGame.sort((a, b) => b.count - a.count)
+ }
+
+ for(let lane of lanes) {
+ lane.winrate = lane.winningMatches / lane.count
+ lane.pickrate = lane.count / totalMatches
+ }
return {name: champion.name,
alias: champion.alias.toLowerCase(),
@@ -212,8 +241,6 @@ async function championInfos(client, patch: number, champion: Champion) {
winrate: winningMatches / totalChampionMatches,
gameCount: totalChampionMatches,
pickrate: totalChampionMatches/totalMatches,
- runes: runes,
- builds: builds
};
}