Files
buildpath/frontend/components/ItemViewer.vue
2024-11-25 20:47:22 +01:00

116 lines
4.4 KiB
Vue

<script setup lang="ts">
type ItemTree = {
count: number
data: number
children: Array<ItemTree>
}
type Builds = {
start: Array<{count: number, data: number}>
tree: ItemTree
bootsFirst: number
boots: Array<{count: number, data: number}>
lateGame: Array<{count: number, data: number}>
}
const props = defineProps<{
builds: Builds
}>()
const builds = props.builds
type Item = {
id: number
}
type ItemResponse = {
data: Ref<Array<Item>>
}
const {data : items} : ItemResponse = await useFetch(CDRAGON_BASE + "plugins/rcp-be-lol-game-data/global/default/v1/items.json")
const itemMap = reactive(new Map())
for(let item of items.value) {
itemMap.set(item.id, item)
}
</script>
<template>
<div style="width: fit-content; height: fit-content;">
<div class="item-box">
<h2 class="item-box-title">start</h2>
<div style="display: flex; width: fit-content; height: fit-content; margin:auto;">
<div style="margin-left: 5px; margin-right: 5px;" v-for="item in builds.start" >
<NuxtImg v-if="item.data != null && item.data != undefined"
style="border: 1px solid var(--color-on-surface);"
width="64" height="64" :alt="item.data.toString()"
:src="CDRAGON_BASE + mapPath(itemMap.get(item.data).iconPath)" />
<h3 style="width: fit-content; margin:auto; margin-bottom: 10px;">{{ item.count }}</h3>
</div>
</div>
</div>
<div v-if="builds.bootsFirst > 0.5" class="item-box" style="margin-top: 10px;">
<div style="display:flex; justify-content: center; align-items: baseline;">
<h2 class="item-box-title">boots rush</h2><h5 style="margin-left: 5px;">({{ (builds.bootsFirst * 100).toFixed(2) }}%)</h5>
</div>
<div style="display: flex; width: fit-content; height: fit-content; margin:auto;">
<div style="margin-left: 5px; margin-right: 5px;" v-for="item in builds.boots" >
<NuxtImg v-if="item.data != null && item.data != undefined"
style="border: 1px solid var(--color-on-surface);"
width="64" height="64" :alt="item.data.toString()"
:src="CDRAGON_BASE + mapPath(itemMap.get(item.data).iconPath)" />
<h3 style="width: fit-content; margin:auto; margin-bottom: 10px;">{{ item.count }}</h3>
</div>
</div>
</div>
<div class="item-box" style="margin-top: 10px;">
<h2 class="item-box-title">core</h2>
<TreeItem style="margin:auto; width: fit-content;" :tree="builds.tree" />
</div>
<div v-if="builds.bootsFirst <= 0.5" class="item-box" style="margin-top: 10px;">
<h2 class="item-box-title">boots</h2>
<div style="display: flex; width: fit-content; height: fit-content; margin:auto;">
<div style="margin-left: 5px; margin-right: 5px;" v-for="item in builds.boots" >
<NuxtImg v-if="item.data != null && item.data != undefined"
style="border: 1px solid var(--color-on-surface);"
width="64" height="64" :alt="item.data.toString()"
:src="CDRAGON_BASE + mapPath(itemMap.get(item.data).iconPath)" />
<h3 style="width: fit-content; margin:auto; margin-bottom: 10px;">{{ item.count }}</h3>
</div>
</div>
</div>
<div class="item-box" style="margin-top: 10px;">
<h2 class="item-box-title">late game</h2>
<div style="display: flex; width: fit-content; height: fit-content; margin:auto;">
<div style="margin-left: 5px; margin-right: 5px;" v-for="item in builds.lateGame.slice(0, 7)" >
<NuxtImg v-if="item.data != null && item.data != undefined"
class="item-img" width="64" height="64" :alt="item.data.toString()"
:src="CDRAGON_BASE + mapPath(itemMap.get(item.data).iconPath)" />
<h3 style="width: fit-content; margin:auto; margin-bottom: 10px;">{{ item.count }}</h3>
</div>
</div>
</div>
</div>
</template>
<style>
.item-img {
border: 1px solid var(--color-on-surface);
}
.item-box {
border: 1px solid var(--color-on-surface);
border-radius: 8px;
width: 600px;
height: fit-content;
margin: auto;
}
.item-box-title {
font-variant: small-caps;
text-align: center;
margin-bottom: 10px;
}
</style>