142 lines
4.2 KiB
GDScript
142 lines
4.2 KiB
GDScript
extends Node3D
|
|
|
|
## Zweiter Durchlauf: Element-Auswahl, 3-Star, grosser Kampf, Spielende.
|
|
|
|
var main: Node3D
|
|
var out_dir := "user://shots"
|
|
var shot_no := 0
|
|
|
|
|
|
func _ready() -> void:
|
|
var args := OS.get_cmdline_user_args()
|
|
if args.size() > 0:
|
|
out_dir = args[0]
|
|
DirAccess.make_dir_recursive_absolute(out_dir)
|
|
main = load("res://scenes/Main.tscn").instantiate()
|
|
add_child(main)
|
|
_run()
|
|
|
|
|
|
func _wait(s: float) -> void:
|
|
await get_tree().create_timer(s).timeout
|
|
|
|
|
|
func _shot(n: String) -> void:
|
|
await RenderingServer.frame_post_draw
|
|
shot_no += 1
|
|
get_viewport().get_texture().get_image().save_png("%s/%02d_%s.png" % [out_dir, shot_no, n])
|
|
print("SHOT ", n)
|
|
|
|
|
|
func _run() -> void:
|
|
await _wait(0.5)
|
|
var p: PlayerState = main.game.human
|
|
|
|
# 1) Spezialisierung beim Kauf.
|
|
p.gold = 200
|
|
main._on_buy(0)
|
|
await _wait(0.4)
|
|
print("Picker sichtbar: ", main.picker.visible)
|
|
await _shot("kauf_spezialisierung")
|
|
main.picker.hide()
|
|
main.picker_cb.call(Data.Element.FEUER)
|
|
await _wait(0.2)
|
|
print("Gekauft: ", p.bench[0].display_name())
|
|
p.move_slot({"kind": "bench", "index": 0}, {"kind": "board", "hex": Vector2i(3, 1)},
|
|
main.game.round_no)
|
|
main._refresh()
|
|
await _wait(0.2)
|
|
print("Aufgestellt: ", p.board.get(Vector2i(3, 1)).display_name())
|
|
|
|
# 2) Bis 3-Star aufwerten.
|
|
for i in 2:
|
|
p.bench[i] = Avatar.new(Data.Role.DPS, [Data.Element.FEUER] as Array[int], 1)
|
|
p.upgrade(Vector2i(3, 1), Data.Element.WIND, main.game.pool)
|
|
for i in 3:
|
|
p.bench[i] = Avatar.new(Data.Role.DPS, [Data.Element.FEUER] as Array[int], 1)
|
|
for i in range(3, 6):
|
|
p.bench[i] = Avatar.new(Data.Role.TANK, [Data.Element.WIND] as Array[int], 1)
|
|
main.sel_slot = {"kind": "board", "hex": Vector2i(3, 1)}
|
|
main._refresh()
|
|
await _wait(0.3)
|
|
print("3-Star möglich: ", p.can_upgrade(Vector2i(3, 1)))
|
|
await _shot("dreistern_bereit")
|
|
p.upgrade(Vector2i(3, 1), Data.Element.BLITZ, main.game.pool)
|
|
main._refresh()
|
|
var a: Avatar = p.board[Vector2i(3, 1)]
|
|
print("3-Star: ", a.display_name(), " star=", a.star, " hp=", int(a.base_stats()["hp"]))
|
|
await _wait(0.3)
|
|
await _shot("dreistern")
|
|
|
|
# 3) Grosses Team für einen sichtbaren Kampf.
|
|
main.game.round_no = 14
|
|
var setup := [
|
|
[Vector2i(2, 0), Data.Role.TANK, Data.Element.ERDE],
|
|
[Vector2i(4, 0), Data.Role.TANK, Data.Element.ERDE],
|
|
[Vector2i(2, 1), Data.Role.DPS, Data.Element.FEUER],
|
|
[Vector2i(4, 1), Data.Role.DPS, Data.Element.FEUER],
|
|
[Vector2i(3, 3), Data.Role.HEILER, Data.Element.WASSER],
|
|
[Vector2i(2, 3), Data.Role.HEILER, Data.Element.EIS],
|
|
[Vector2i(5, 2), Data.Role.DPS, Data.Element.WIND],
|
|
]
|
|
for e in setup:
|
|
var av := Avatar.new(e[1], [e[2]] as Array[int], 1)
|
|
p.board[e[0]] = av
|
|
main.game.human.unlock(e[2])
|
|
main._refresh()
|
|
await _wait(0.3)
|
|
print("Traits: ", p.trait_counts(), " Kombis: ", p.active_combos().size())
|
|
await _shot("volles_team")
|
|
|
|
main._on_ready()
|
|
await _wait(1.5)
|
|
await _shot("grosser_kampf")
|
|
main.combat_speed = 4.0
|
|
await _wait(3.0)
|
|
await _shot("kampf_spaeter")
|
|
if main.game.phase == Game.Phase.COMBAT:
|
|
main._on_ready()
|
|
await _wait(0.4)
|
|
print("Ergebnis: ", main.game.last_round_log)
|
|
|
|
# 4) Bis zum Spielende durchlaufen.
|
|
var guard := 0
|
|
while main.game.phase != Game.Phase.GAMEOVER and guard < 120:
|
|
var ai := BotAI.new()
|
|
ai.setup(main.game.rand)
|
|
if main.game.human.alive:
|
|
ai.take_turn(main.game.human, main.game.pool, main.game.rand, main.game.round_no)
|
|
main._on_ready()
|
|
if main.game.phase == Game.Phase.COMBAT:
|
|
main.game.skip_combat()
|
|
guard += 1
|
|
main._refresh()
|
|
await _wait(0.5)
|
|
print("Spielende nach Runde ", main.game.round_no,
|
|
" Platz des Spielers: ", main.game.human.placement)
|
|
await _shot("spielende")
|
|
|
|
# 5) Neustart über den Knopf im Overlay.
|
|
var btn := _find_button(main.overlay, "Neues Spiel")
|
|
print("Neustart-Knopf gefunden: ", btn != null)
|
|
if btn != null:
|
|
btn.pressed.emit()
|
|
await _wait(0.5)
|
|
print("Nach Neustart: Runde ", main.game.round_no, " Leben ", main.game.human.hp,
|
|
" Spieler ", main.game.players.size(), " Overlay ", main.overlay)
|
|
await _shot("neustart")
|
|
print("PROBE2 FERTIG")
|
|
get_tree().quit()
|
|
|
|
|
|
func _find_button(node: Node, text: String) -> Button:
|
|
if node == null:
|
|
return null
|
|
for c in node.get_children():
|
|
if c is Button and c.text == text:
|
|
return c
|
|
var r := _find_button(c, text)
|
|
if r != null:
|
|
return r
|
|
return null
|