This commit is contained in:
team3
2026-09-16 12:09:33 +02:00
parent 9410d18ea5
commit 8a188c5d5c
29 changed files with 2016 additions and 564 deletions

View File

@@ -12,6 +12,10 @@ var streak: int = 0 ## >0 Siegserie, <0 Niederlagenserie
var alive: bool = true
var last_won: bool = false
var placement: int = 0 ## Endplatzierung, 0 = noch im Spiel
var level: int = Data.START_LEVEL
var xp: int = 0
var shop_locked: bool = false ## eingefrorener Shop bleibt über die Runde
var last_element: int = -1 ## zuletzt gewählte Spezialisierung für Schnellkauf
var bench: Array = [] ## Avatar oder null
var board: Dictionary = {} ## Vector2i -> Avatar
@@ -72,10 +76,18 @@ func reroll(pool: Pool, rng: RandomNumberGenerator) -> bool:
if gold < Data.REROLL_COST:
return false
gold -= Data.REROLL_COST
shop_locked = false
roll_shop(pool, rng)
return true
## Neue Runde: der Shop wird nur neu gefüllt, wenn er nicht eingefroren ist.
func new_round_shop(pool: Pool, rng: RandomNumberGenerator) -> void:
if shop_locked:
return
roll_shop(pool, rng)
func free_bench_slot() -> int:
for i in bench.size():
if bench[i] == null:
@@ -101,6 +113,8 @@ func buy(index: int, pool: Pool, chosen_element: int = -1) -> bool:
gold -= entry.price()
bench[slot] = entry.to_avatar(element)
entry.sold = true
if entry.element < 0:
last_element = element
return true
@@ -126,21 +140,42 @@ func sell_board(hex: Vector2i, pool: Pool) -> bool:
# --- Aufstellen ------------------------------------------------------------
func team_slots(round_no: int) -> int:
return Data.team_slots(round_no)
func team_slots() -> int:
return level
func can_place(round_no: int) -> bool:
return board.size() < team_slots(round_no)
func can_place() -> bool:
return board.size() < level
func gain_xp(amount: int) -> void:
xp += amount
while level < Data.MAX_LEVEL and xp >= Data.xp_needed(level):
xp -= Data.xp_needed(level)
level += 1
if level >= Data.MAX_LEVEL:
xp = 0
func can_buy_xp() -> bool:
return level < Data.MAX_LEVEL and gold >= Data.XP_BUY_COST
func buy_xp() -> bool:
if not can_buy_xp():
return false
gold -= Data.XP_BUY_COST
gain_xp(Data.XP_BUY_AMOUNT)
return true
## Setzt einen Avatar von der Bank aufs Board.
func place(bench_index: int, hex: Vector2i, round_no: int) -> bool:
func place(bench_index: int, hex: Vector2i) -> bool:
if bench_index < 0 or bench_index >= bench.size() or bench[bench_index] == null:
return false
if board.has(hex) or not _valid_hex(hex):
return false
if not can_place(round_no):
if not can_place():
return false
var a: Avatar = bench[bench_index]
board[hex] = a
@@ -175,7 +210,7 @@ func move_on_board(from_hex: Vector2i, to_hex: Vector2i) -> bool:
## Verschiebt einen Avatar zwischen Bank und Board, in beide Richtungen.
## Ist das Ziel belegt, tauschen die beiden Avatare die Plätze.
## src und dst sind {"kind": "board"/"bench", "hex": Vector2i, "index": int}.
func move_slot(src: Dictionary, dst: Dictionary, round_no: int) -> bool:
func move_slot(src: Dictionary, dst: Dictionary) -> bool:
if src.is_empty() or dst.is_empty() or src == dst:
return false
var sk: String = src["kind"]
@@ -212,7 +247,7 @@ func move_slot(src: Dictionary, dst: Dictionary, round_no: int) -> bool:
var hex3: Vector2i = dst["hex"]
if bench[i3] == null or not _valid_hex(hex3):
return false
if not board.has(hex3) and not can_place(round_no):
if not board.has(hex3) and not can_place():
return false
var unit3: Avatar = bench[i3]
if board.has(hex3):