From b7f37898bdea2e141657a9d2ad5f7f4499dec314 Mon Sep 17 00:00:00 2001 From: vhaudiquet Date: Sat, 7 Dec 2024 16:09:49 +0100 Subject: [PATCH] Better late game items (fix #6) :) --- frontend/components/item/Viewer.vue | 13 ++++++++++++- match_collector/champion_stat.ts | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/components/item/Viewer.vue b/frontend/components/item/Viewer.vue index cb89be6..cad7cf7 100644 --- a/frontend/components/item/Viewer.vue +++ b/frontend/components/item/Viewer.vue @@ -11,12 +11,23 @@ for(let item of items.value) { watch(() => props.builds, () => trimBuilds(props.builds)) trimBuilds(props.builds) +trimLateGameItems(props.builds) function trimBuilds(builds : Builds) { builds.tree.children.splice(1, builds.tree.children.length - 1) if(builds.tree.children[0] != null && builds.tree.children[0] != undefined) builds.tree.children[0].children.splice(1, builds.tree.children[0].children.length - 1) } +function trimLateGameItems(builds: Builds) { + function trimLateGameItemsFromTree(tree: ItemTree) { + const foundIndex = builds.lateGame.findIndex((x) => x.data === tree.data) + if(foundIndex != -1) builds.lateGame.splice(foundIndex, 1) + for(let children of tree.children) { + trimLateGameItemsFromTree(children) + } + } + trimLateGameItemsFromTree(builds.tree) +} @@ -90,7 +101,7 @@ function trimBuilds(builds : Builds) { -
+
x.data == item) if(already == undefined) builds.lateGame.push({count:1, data:item}) else already.count += 1