Auto-Carousel, Standings mit Spieler, Runden-Tracker, Item-Rail links, sinnvoller Item-Pool
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,7 @@ def client(monkeypatch):
|
||||
def test_full_game_via_api(client):
|
||||
state = client.post("/api/game", params={"seed": 3}).json()
|
||||
game_id = state["game_id"]
|
||||
assert state["round"]["label"] == "1-1"
|
||||
assert state["round"]["label"] == "1-2" # 1-1-Carousel läuft automatisch ab
|
||||
assert state["player"]["hp"] == 100
|
||||
assert len(state["opponents"]) == 7
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ def test_invalid_actions_raise(art, cfg):
|
||||
with pytest.raises(InvalidAction):
|
||||
game.buy_xp()
|
||||
with pytest.raises(InvalidAction):
|
||||
game.sell("bench", 0)
|
||||
game.sell("bench", 99)
|
||||
|
||||
|
||||
def test_shop_lock_survives_step(art, cfg):
|
||||
@@ -87,3 +87,19 @@ def test_shop_lock_survives_step(art, cfg):
|
||||
before = list(game.shop)
|
||||
game.step()
|
||||
assert game.shop == before
|
||||
|
||||
|
||||
def test_carousel_never_a_planning_round(art, cfg):
|
||||
game = Game(art, cfg, seed=5)
|
||||
seen = []
|
||||
while not game.over:
|
||||
seen.append(game.round["kind"])
|
||||
game.step()
|
||||
assert "carousel" not in seen
|
||||
assert seen[0] == "pve" # Spiel startet bei 1-2
|
||||
|
||||
|
||||
def test_carousel_grants_unit_and_loot(art, cfg):
|
||||
game = Game(art, cfg, seed=5)
|
||||
assert len(game.bench) == 1 # Unit vom 1-1-Carousel
|
||||
assert len(game.items) == 1 # Item-Komponente vom Carousel
|
||||
|
||||
@@ -74,3 +74,15 @@ def test_spearman():
|
||||
assert spearman([1, 2, 3, 4], [10, 20, 30, 40]) == pytest.approx(1.0)
|
||||
assert spearman([1, 2, 3, 4], [40, 30, 20, 10]) == pytest.approx(-1.0)
|
||||
assert spearman([1, 2, 3, 4], [10, 10, 10, 10]) == 0.0
|
||||
|
||||
|
||||
def test_craftable_item_pool():
|
||||
from tft.model.artifact import craftable_items
|
||||
items = {
|
||||
"TFT_Item_InfinityEdge": {"composition": ["TFT_Item_BFSword", "TFT_Item_SparringGloves"]},
|
||||
"TFT_Item_BFSword": {"composition": []},
|
||||
"TFT_Item_Emblem": {"composition": ["TFT_Item_Spatula", "TFT_Item_BFSword"]},
|
||||
"TFT17_Item_Weird": {"composition": ["TFT_Item_BFSword", "TFT_Item_BFSword"]},
|
||||
"TFT_Item_Radiant": {"composition": None},
|
||||
}
|
||||
assert craftable_items(items) == ["TFT_Item_InfinityEdge"]
|
||||
|
||||
@@ -143,6 +143,11 @@ def serialize(game: Game) -> dict:
|
||||
return {
|
||||
"round": {"label": game.round["label"], "stage": stage,
|
||||
"kind": game.round["kind"]},
|
||||
"stage_rounds": [
|
||||
{"label": r["label"], "kind": r["kind"], "augment": r["augment"],
|
||||
"done": i < game.idx, "current": i == game.idx}
|
||||
for i, r in enumerate(game.rounds) if r["stage"] == stage
|
||||
],
|
||||
"player": {
|
||||
"hp": game.hp, "gold": game.gold, "level": game.level, "xp": game.xp,
|
||||
"xp_needed": game.cfg["xp"]["to_next"][game.level - 1]
|
||||
|
||||
@@ -8,6 +8,23 @@ from tft.model import baseline
|
||||
|
||||
SCHEMA_VERSION = 1
|
||||
|
||||
# Spatula/Pfanne-Rezepte (Embleme) fallen aus dem normalen Loot raus.
|
||||
SPATULA_COMPONENTS = {"TFT_Item_Spatula", "TFT_Item_FryingPan"}
|
||||
|
||||
|
||||
def craftable_items(static_items: dict) -> list[str]:
|
||||
"""Standard-kombinierbare Items — der Pool für Loot und Bot-Boards."""
|
||||
pool = []
|
||||
for api, item in static_items.items():
|
||||
comp = item.get("composition") or []
|
||||
if (
|
||||
len(comp) == 2
|
||||
and api.startswith("TFT_Item_")
|
||||
and not set(comp) & SPATULA_COMPONENTS
|
||||
):
|
||||
pool.append(api)
|
||||
return sorted(pool)
|
||||
|
||||
|
||||
def build(static: dict, learned: dict | None = None, extra_meta: dict | None = None) -> dict:
|
||||
roles = {
|
||||
@@ -28,6 +45,7 @@ def build(static: dict, learned: dict | None = None, extra_meta: dict | None = N
|
||||
"augments": static["augments"],
|
||||
},
|
||||
"roles": roles,
|
||||
"item_pool": craftable_items(static["items"]),
|
||||
"learned": learned or {},
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class Bot:
|
||||
level = self.level(stage)
|
||||
odds = cfg["shop"]["odds"][min(level, len(cfg["shop"]["odds"])) - 1]
|
||||
p_2star = min(0.08 * stage, 0.55)
|
||||
items = list(artifact["static"]["items"])
|
||||
items = artifact.get("item_pool") or list(artifact["static"]["items"])
|
||||
n_items = max(stage - 1, 0)
|
||||
|
||||
for _ in range(level):
|
||||
|
||||
@@ -46,6 +46,10 @@ class Game:
|
||||
self.bots = [
|
||||
Bot(names[i], archetypes[i % len(archetypes)], self.hp) for i in range(7)
|
||||
]
|
||||
# 1-1-Carousel läuft automatisch ab: Unit + Loot, dann startet 1-2.
|
||||
if self.round["kind"] == "carousel":
|
||||
self._resolve(self.round)
|
||||
self.idx += 1
|
||||
self._refresh_bots()
|
||||
self._reroll_shop()
|
||||
self._maybe_offer_augment()
|
||||
@@ -84,7 +88,7 @@ class Game:
|
||||
self.augment_offer = self.rng.sample(augments, min(3, len(augments)))
|
||||
|
||||
def _grant_loot(self, components: int, gold: int) -> None:
|
||||
items = list(self.artifact["static"]["items"])
|
||||
items = self.artifact.get("item_pool") or list(self.artifact["static"]["items"])
|
||||
for _ in range(components):
|
||||
self.items.append(self.rng.choice(items))
|
||||
self.gold += gold
|
||||
@@ -207,13 +211,27 @@ class Game:
|
||||
self.level, self.xp, self.cfg["xp"]["passive_per_round"], self.cfg
|
||||
)
|
||||
|
||||
self._advance()
|
||||
|
||||
def _advance(self) -> None:
|
||||
"""Zur nächsten Planungsrunde; Carousels laufen dabei automatisch ab."""
|
||||
while True:
|
||||
if self.idx + 1 >= len(self.rounds):
|
||||
self._finish_by_hp()
|
||||
return
|
||||
prev_stage = rnd["stage"]
|
||||
prev_stage = self.round["stage"]
|
||||
self.idx += 1
|
||||
if self.round["stage"] != prev_stage:
|
||||
self._refresh_bots()
|
||||
if self.round["kind"] != "carousel":
|
||||
break
|
||||
self._resolve(self.round)
|
||||
self.gold += economy.round_income(
|
||||
self.gold, self.streak, False, self.round["label"], self.cfg
|
||||
)
|
||||
self.level, self.xp = economy.apply_xp(
|
||||
self.level, self.xp, self.cfg["xp"]["passive_per_round"], self.cfg
|
||||
)
|
||||
if not self.shop_locked:
|
||||
self._reroll_shop()
|
||||
self._maybe_offer_augment()
|
||||
|
||||
@@ -8,6 +8,20 @@ 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>
|
||||
@@ -19,6 +33,15 @@ const kindLabel = { pvp: 'PvP', pve: 'PvE', carousel: 'Carousel' }
|
||||
<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()">
|
||||
@@ -44,9 +67,25 @@ const kindLabel = { pvp: 'PvP', pve: 'PvE', carousel: 'Carousel' }
|
||||
</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">
|
||||
@@ -73,26 +112,9 @@ const kindLabel = { pvp: 'PvP', pve: 'PvE', carousel: 'Carousel' }
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="zone" v-if="s.items.length">
|
||||
<h3>Items {{ store.selectedItem !== null ? '— Ziel-Unit anklicken' : '' }}</h3>
|
||||
<div class="itemrow">
|
||||
<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>
|
||||
</div>
|
||||
<div class="zone log">
|
||||
<div v-for="(line, i) in [...s.log].reverse()" :key="i">{{ line }}</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<OpponentList :opponents="s.opponents" />
|
||||
<OpponentList :players="standings" />
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
@@ -120,6 +142,21 @@ header {
|
||||
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; }
|
||||
@@ -140,19 +177,27 @@ header {
|
||||
|
||||
main {
|
||||
flex: 1; min-height: 0;
|
||||
display: grid; grid-template-columns: 220px 1fr 240px; gap: 10px;
|
||||
display: grid; grid-template-columns: 46px 210px 1fr 250px; gap: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
main > * { overflow-y: auto; }
|
||||
|
||||
.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; }
|
||||
.itemrow { display: flex; flex-wrap: wrap; gap: 5px; }
|
||||
.itemrow img {
|
||||
.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;
|
||||
}
|
||||
.itemrow img.selected { border-color: #7de3d4; }
|
||||
.log { color: #7d86a0; font-size: 12px; margin-top: auto; }
|
||||
.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>
|
||||
|
||||
@@ -1,31 +1,32 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
defineProps({ opponents: { type: Array, required: true } })
|
||||
defineProps({ players: { type: Array, required: true } })
|
||||
const expanded = ref(null)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside class="opponents">
|
||||
<h3>Gegner</h3>
|
||||
<h3>Spieler</h3>
|
||||
<div
|
||||
v-for="o in opponents"
|
||||
:key="o.name"
|
||||
v-for="p in players"
|
||||
:key="p.name"
|
||||
class="opp"
|
||||
:class="{ dead: !o.alive }"
|
||||
@click="expanded = expanded === o.name ? null : o.name"
|
||||
:class="{ dead: !p.alive, me: p.is_player }"
|
||||
@click="!p.is_player && (expanded = expanded === p.name ? null : p.name)"
|
||||
>
|
||||
<div class="row">
|
||||
<span class="oname">{{ o.name }}</span>
|
||||
<span class="arch">{{ o.archetype }}</span>
|
||||
<span v-if="o.alive" class="hp">{{ o.hp }}</span>
|
||||
<span v-else class="placement">#{{ o.placement }}</span>
|
||||
<span class="oname">{{ p.name }}</span>
|
||||
<span v-if="p.archetype" class="arch">{{ p.archetype }}</span>
|
||||
<span v-if="p.alive" class="strength" title="Boardstärke">⚡ {{ p.score }}</span>
|
||||
<span v-if="p.alive" class="hp">{{ p.hp }}</span>
|
||||
<span v-else class="placement">#{{ p.placement }}</span>
|
||||
</div>
|
||||
<div v-if="o.alive" class="hpbar"><div :style="{ width: o.hp + '%' }" /></div>
|
||||
<div v-if="expanded === o.name && o.alive" class="scout">
|
||||
<div>Level {{ o.level }} · Stärke {{ o.score }}</div>
|
||||
<div v-if="p.alive" class="hpbar"><div :style="{ width: p.hp + '%' }" /></div>
|
||||
<div v-if="expanded === p.name && p.alive && p.board.length" class="scout">
|
||||
<div>Level {{ p.level }}</div>
|
||||
<div class="units">
|
||||
<img
|
||||
v-for="(u, i) in o.board"
|
||||
v-for="(u, i) in p.board"
|
||||
:key="i"
|
||||
:src="u.icon"
|
||||
:alt="u.name"
|
||||
@@ -41,10 +42,13 @@ const expanded = ref(null)
|
||||
.opponents { display: flex; flex-direction: column; gap: 6px; }
|
||||
h3 { font-size: 12px; text-transform: uppercase; color: #8a92a8; margin-bottom: 2px; }
|
||||
.opp { background: #161b29; border-radius: 6px; padding: 6px 8px; cursor: pointer; }
|
||||
.opp.me { border: 1px solid #7de3d4; cursor: default; }
|
||||
.opp.dead { opacity: 0.4; }
|
||||
.row { display: flex; align-items: center; gap: 6px; }
|
||||
.oname { flex: 1; font-weight: 600; }
|
||||
.me .oname { color: #7de3d4; }
|
||||
.arch { color: #7d86a0; font-size: 11px; }
|
||||
.strength { color: #e5a531; font-size: 12px; font-weight: 600; }
|
||||
.hp { font-weight: 700; color: #7de37d; }
|
||||
.placement { color: #8a92a8; }
|
||||
.hpbar { height: 4px; background: #232a3d; border-radius: 2px; margin-top: 4px; }
|
||||
|
||||
Reference in New Issue
Block a user