Files
tft/frontend/src/App.vue

204 lines
6.1 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup>
import { computed } from 'vue'
import { store } from './store.js'
import TraitPanel from './components/TraitPanel.vue'
import OpponentList from './components/OpponentList.vue'
import Shop from './components/Shop.vue'
import UnitChip from './components/UnitChip.vue'
const s = computed(() => store.state)
const kindLabel = { pvp: 'PvP', pve: 'PvE', carousel: 'Carousel' }
const kindIcon = { pvp: '⚔️', pve: '🐺', carousel: '🎠' }
const standings = computed(() => {
const p = s.value.player
const rows = [
{
name: 'Du', is_player: true, hp: Math.max(p.hp, 0), alive: p.hp > 0,
score: p.score, level: p.level, archetype: '',
placement: s.value.placement, board: [],
},
...s.value.opponents,
]
return rows.sort((a, b) => b.hp - a.hp || (a.placement ?? 9) - (b.placement ?? 9))
})
</script>
<template>
<div v-if="!s" class="splash">
<h1>TFT-Simulator</h1>
<button class="big" @click="store.start()">Neues Spiel</button>
</div>
<div v-else class="layout">
<header>
<span class="round">Runde {{ s.round.label }} · {{ kindLabel[s.round.kind] }}</span>
<span class="tracker">
<span
v-for="r in s.stage_rounds"
:key="r.label"
class="tick"
:class="{ done: r.done, current: r.current, augment: r.augment }"
:title="r.label"
>{{ kindIcon[r.kind] }}</span>
</span>
<span class="stat"> {{ s.player.hp }}</span>
<span class="score">Boardstärke {{ s.player.score }}</span>
<button class="fight" :disabled="s.over" @click="store.next()">
{{ s.round.kind === 'pvp' ? 'Kampf' : 'Weiter' }}
</button>
</header>
<div v-if="store.error" class="error">{{ store.error }}</div>
<div v-if="s.over" class="gameover">
<h2>Platz {{ s.placement }}</h2>
<button class="big" @click="store.start()">Nochmal</button>
</div>
<div v-if="s.augment_offer.length" class="augments">
<h3>Augment wählen</h3>
<div class="offer">
<button v-for="(a, i) in s.augment_offer" :key="a.api_name" @click="store.pickAugment(i)">
<img v-if="a.icon" :src="a.icon" :alt="a.name" />
{{ a.name }}
</button>
</div>
</div>
<main>
<div class="itemrail">
<div class="railtitle" :title="store.selectedItem !== null ? 'Ziel-Unit anklicken' : 'Items'">🎒</div>
<img
v-for="(it, i) in s.items"
:key="i"
:src="it.icon"
:alt="it.name"
:title="it.name"
:class="{ selected: store.selectedItem === i }"
@click="store.selectedItem = store.selectedItem === i ? null : i"
/>
</div>
<TraitPanel :traits="s.traits" />
<section class="center">
<div class="zone log">
<div v-for="(line, i) in [...s.log].reverse()" :key="i">{{ line }}</div>
</div>
<div class="zone">
<h3>Board ({{ s.board.length }}/{{ s.player.level }})</h3>
<div class="unitrow">
<UnitChip
v-for="(u, i) in s.board"
:key="'b' + i"
:unit="u"
sellable
@click="store.selectedItem !== null ? store.equip(i) : store.move('board', i)"
@sell="store.sell('board', i)"
/>
</div>
</div>
<div class="zone">
<h3>Bank ({{ s.bench.length }}/9)</h3>
<div class="unitrow">
<UnitChip
v-for="(u, i) in s.bench"
:key="'n' + i"
:unit="u"
sellable
@click="store.move('bench', i)"
@sell="store.sell('bench', i)"
/>
</div>
</div>
</section>
<OpponentList :players="standings" />
</main>
<footer>
<Shop />
</footer>
</div>
</template>
<style scoped>
.splash {
height: 100vh;
display: flex; flex-direction: column;
align-items: center; justify-content: center; gap: 20px;
}
.big { font-size: 18px; padding: 12px 28px; }
.layout {
height: 100vh;
display: flex; flex-direction: column;
padding: 10px; gap: 8px;
max-width: 1400px; margin: 0 auto;
}
header {
display: flex; align-items: center; gap: 16px;
background: #161b29; border-radius: 8px; padding: 8px 14px;
}
.round { font-weight: 700; }
.tracker { display: flex; gap: 3px; }
.tick {
font-size: 13px;
opacity: 0.35;
filter: grayscale(0.7);
padding: 1px 3px;
border-radius: 4px;
}
.tick.done { opacity: 0.15; }
.tick.current {
opacity: 1; filter: none;
background: #2a3145;
outline: 1px solid #56638a;
}
.tick.augment { outline: 1px solid #ffd75e66; }
.stat { color: #c6cddd; }
.score { margin-left: auto; font-weight: 700; color: #7de3d4; }
.fight { background: #2b4a33; border-color: #4caf6e; font-weight: 700; }
.error {
background: #3d2330; border: 1px solid #a5476a;
border-radius: 6px; padding: 6px 12px;
}
.gameover {
background: #161b29; border-radius: 8px; padding: 16px;
display: flex; align-items: center; gap: 16px;
}
.augments { background: #1d2438; border-radius: 8px; padding: 10px 14px; }
.augments h3 { font-size: 12px; text-transform: uppercase; color: #8a92a8; margin-bottom: 6px; }
.offer { display: flex; gap: 8px; }
.offer button { display: flex; align-items: center; gap: 8px; flex: 1; }
.offer img { width: 28px; height: 28px; }
main {
flex: 1; min-height: 0;
display: grid; grid-template-columns: 46px 210px 1fr 250px; gap: 10px;
overflow: hidden;
}
main > * { overflow-y: auto; }
.itemrail {
display: flex; flex-direction: column; gap: 5px; align-items: center;
background: #12141d; border-radius: 8px; padding: 6px 4px;
}
.railtitle { font-size: 15px; opacity: 0.7; }
.itemrail img {
width: 34px; height: 34px; border-radius: 6px;
border: 2px solid #3a4460; cursor: pointer;
}
.itemrail img.selected { border-color: #7de3d4; }
.center { display: flex; flex-direction: column; gap: 10px; }
.zone h3 { font-size: 12px; text-transform: uppercase; color: #8a92a8; margin-bottom: 5px; }
.unitrow { display: flex; flex-wrap: wrap; gap: 6px; min-height: 46px; }
.log {
flex: 1; min-height: 0; overflow-y: auto;
color: #7d86a0; font-size: 12px;
}
</style>