frontend: lint and format
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getHighestPickrateBuildIndex, getFirstCoreItems } from '~/utils/buildHelpers'
|
import { getHighestPickrateBuildIndex, getFirstCoreItems } from '~/utils/buildHelpers'
|
||||||
import { MOCK_SUMMONER_SPELLS, BOOTS_RUSH_THRESHOLD } from '~/utils/mockData'
|
import { MOCK_SUMMONER_SPELLS } from '~/utils/mockData'
|
||||||
import BuildVariantSelector from '~/components/build/BuildVariantSelector.vue'
|
import BuildVariantSelector from '~/components/build/BuildVariantSelector.vue'
|
||||||
import SummonerSpells from '~/components/build/SummonerSpells.vue'
|
import SummonerSpells from '~/components/build/SummonerSpells.vue'
|
||||||
import CompactRuneSelector from '~/components/build/CompactRuneSelector.vue'
|
import CompactRuneSelector from '~/components/build/CompactRuneSelector.vue'
|
||||||
@@ -32,9 +32,9 @@ const { perks, primaryStyles, secondaryStyles, keystoneIds } = useRuneStyles(toR
|
|||||||
const { builds } = useBuilds(toRef(props, 'builds'))
|
const { builds } = useBuilds(toRef(props, 'builds'))
|
||||||
|
|
||||||
// Summoner spells data - use提供的 or fall back to mock
|
// Summoner spells data - use提供的 or fall back to mock
|
||||||
const displaySummonerSpells = computed(() =>
|
const displaySummonerSpells = computed(() =>
|
||||||
(props.summonerSpells && props.summonerSpells.length > 0)
|
props.summonerSpells && props.summonerSpells.length > 0
|
||||||
? props.summonerSpells
|
? props.summonerSpells
|
||||||
: MOCK_SUMMONER_SPELLS
|
: MOCK_SUMMONER_SPELLS
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -43,10 +43,6 @@ const firstCoreItems = computed(() => getFirstCoreItems(props.runes, builds.valu
|
|||||||
|
|
||||||
const highestPickrateBuildIndex = computed(() => getHighestPickrateBuildIndex(props.runes))
|
const highestPickrateBuildIndex = computed(() => getHighestPickrateBuildIndex(props.runes))
|
||||||
|
|
||||||
const bootsLabel = computed(() =>
|
|
||||||
builds.value.bootsFirst > BOOTS_RUSH_THRESHOLD ? 'Boots Rush' : 'Boots'
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reset selected build when runes change
|
// Reset selected build when runes change
|
||||||
watch(
|
watch(
|
||||||
() => props.runes,
|
() => props.runes,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const useBuilds = (buildsProp: Ref<Builds>) => {
|
|||||||
// Watch for changes and rebuild
|
// Watch for changes and rebuild
|
||||||
watch(
|
watch(
|
||||||
() => buildsProp.value,
|
() => buildsProp.value,
|
||||||
(newBuilds) => {
|
newBuilds => {
|
||||||
builds.value = deepClone(newBuilds)
|
builds.value = deepClone(newBuilds)
|
||||||
trimBuildData()
|
trimBuildData()
|
||||||
},
|
},
|
||||||
@@ -29,4 +29,4 @@ export const useBuilds = (buildsProp: Ref<Builds>) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return { builds }
|
return { builds }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const useItemMap = () => {
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
items,
|
items,
|
||||||
(newItems) => {
|
newItems => {
|
||||||
if (Array.isArray(newItems)) {
|
if (Array.isArray(newItems)) {
|
||||||
const map = new Map<number, Item>()
|
const map = new Map<number, Item>()
|
||||||
for (const item of newItems) {
|
for (const item of newItems) {
|
||||||
@@ -27,4 +27,4 @@ export const useItemMap = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return { itemMap }
|
return { itemMap }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,17 @@
|
|||||||
* Composable for fetching and managing rune styles and keystones
|
* Composable for fetching and managing rune styles and keystones
|
||||||
* Transforms rune data into format needed for display components
|
* Transforms rune data into format needed for display components
|
||||||
*/
|
*/
|
||||||
export const useRuneStyles = (runes: Ref<Array<{
|
export const useRuneStyles = (
|
||||||
count: number
|
runes: Ref<
|
||||||
primaryStyle: number
|
Array<{
|
||||||
secondaryStyle: number
|
count: number
|
||||||
selections: Array<number>
|
primaryStyle: number
|
||||||
pickrate: number
|
secondaryStyle: number
|
||||||
}>>) => {
|
selections: Array<number>
|
||||||
|
pickrate: number
|
||||||
|
}>
|
||||||
|
>
|
||||||
|
) => {
|
||||||
const primaryStyles = ref<Array<PerkStyle>>(Array(runes.value.length))
|
const primaryStyles = ref<Array<PerkStyle>>(Array(runes.value.length))
|
||||||
const secondaryStyles = ref<Array<PerkStyle>>(Array(runes.value.length))
|
const secondaryStyles = ref<Array<PerkStyle>>(Array(runes.value.length))
|
||||||
const keystoneIds = ref<Array<number>>(Array(runes.value.length))
|
const keystoneIds = ref<Array<number>>(Array(runes.value.length))
|
||||||
@@ -19,7 +23,7 @@ export const useRuneStyles = (runes: Ref<Array<{
|
|||||||
const perks = reactive(new Map<number, Perk>())
|
const perks = reactive(new Map<number, Perk>())
|
||||||
watch(
|
watch(
|
||||||
perksData,
|
perksData,
|
||||||
(newPerks) => {
|
newPerks => {
|
||||||
if (Array.isArray(newPerks)) {
|
if (Array.isArray(newPerks)) {
|
||||||
perks.clear()
|
perks.clear()
|
||||||
for (const perk of newPerks) {
|
for (const perk of newPerks) {
|
||||||
@@ -90,4 +94,4 @@ export const useRuneStyles = (runes: Ref<Array<{
|
|||||||
secondaryStyles,
|
secondaryStyles,
|
||||||
keystoneIds
|
keystoneIds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const useSummonerSpellMap = () => {
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
summonerSpellsData,
|
summonerSpellsData,
|
||||||
(newData) => {
|
newData => {
|
||||||
if (Array.isArray(newData)) {
|
if (Array.isArray(newData)) {
|
||||||
const map = new Map<number, SummonerSpell>()
|
const map = new Map<number, SummonerSpell>()
|
||||||
for (const spell of newData) {
|
for (const spell of newData) {
|
||||||
@@ -30,4 +30,4 @@ export const useSummonerSpellMap = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return { summonerSpellMap }
|
return { summonerSpellMap }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,19 +38,17 @@ export function trimLateGameItems(builds: Builds): void {
|
|||||||
collectItemIds(builds.tree)
|
collectItemIds(builds.tree)
|
||||||
|
|
||||||
// Remove late game items that appear in core
|
// Remove late game items that appear in core
|
||||||
builds.lateGame = builds.lateGame.filter((item) => !coreItemIds.has(item.data))
|
builds.lateGame = builds.lateGame.filter(item => !coreItemIds.has(item.data))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the index of the build with the highest pickrate
|
* Gets the index of the build with the highest pickrate
|
||||||
*/
|
*/
|
||||||
export function getHighestPickrateBuildIndex(
|
export function getHighestPickrateBuildIndex(runes: Array<{ pickrate: number }>): number {
|
||||||
runes: Array<{ pickrate: number }>
|
|
||||||
): number {
|
|
||||||
if (runes.length === 0) return 0
|
if (runes.length === 0) return 0
|
||||||
|
|
||||||
return runes.reduce((maxIdx, rune, idx, arr) =>
|
return runes.reduce(
|
||||||
rune.pickrate > arr[maxIdx].pickrate ? idx : maxIdx,
|
(maxIdx, rune, idx, arr) => (rune.pickrate > arr[maxIdx].pickrate ? idx : maxIdx),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -58,12 +56,9 @@ export function getHighestPickrateBuildIndex(
|
|||||||
/**
|
/**
|
||||||
* Gets the first core item for each build variant
|
* Gets the first core item for each build variant
|
||||||
*/
|
*/
|
||||||
export function getFirstCoreItems(
|
export function getFirstCoreItems(runes: unknown[], builds: Builds): number[] {
|
||||||
runes: unknown[],
|
|
||||||
builds: Builds
|
|
||||||
): number[] {
|
|
||||||
return runes.map(() => {
|
return runes.map(() => {
|
||||||
const tree = builds?.tree
|
const tree = builds?.tree
|
||||||
return tree?.children?.[0]?.data ?? tree?.data ?? 0
|
return tree?.children?.[0]?.data ?? tree?.data ?? 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,3 @@ export const MOCK_SUMMONER_SPELLS = [
|
|||||||
{ id: 14, count: 600, pickrate: 0.15 }, // Ignite
|
{ id: 14, count: 600, pickrate: 0.15 }, // Ignite
|
||||||
{ id: 3, count: 200, pickrate: 0.05 } // Exhaust
|
{ id: 3, count: 200, pickrate: 0.05 } // Exhaust
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
|
||||||
* Constants used throughout the application
|
|
||||||
*/
|
|
||||||
export const BOOTS_RUSH_THRESHOLD = 0.5
|
|
||||||
Reference in New Issue
Block a user