game: Rast und Tag — Vorräte, volle/halbe Erholung, gestörte Rast im Freien
This commit is contained in:
parent
71816d8117
commit
79bace9880
11 changed files with 191 additions and 17 deletions
74
game/tools/probe_rasten.gd
Normal file
74
game/tools/probe_rasten.gd
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
extends Node
|
||||
## Prüft die Rast: Vorräte, TP, Zauberplätze, Tag und Begegnung im Freien.
|
||||
##
|
||||
## godot --headless --path game res://tools/probe_rasten.tscn -- --check
|
||||
|
||||
var fehler := 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Game.party_schnellstart()
|
||||
Game.place = {"id": "westmark", "x": 9, "y": 7}
|
||||
var a: Dictionary = Game.party[0]
|
||||
var tag0 := int(Game.time.get("day", 1))
|
||||
|
||||
# Voll gerastet: Vorräte da, Wunden und verbrauchte Sprüche verschwinden.
|
||||
_fuelle_vorraete(3)
|
||||
a["hp"]["current"] = 1
|
||||
if Game.party.size() > 2:
|
||||
Game.party[2]["spells"]["used"] = ["magisches_geschoss"]
|
||||
var vorrat_vorher := Game.inventar_hat(a, "vorrat")
|
||||
var r: Dictionary = Game.rasten(false)
|
||||
ok("Rast gelingt", bool(r.get("ok", false)) and int(Game.time["day"]) == tag0 + 1)
|
||||
ok("TP voll", int(a["hp"]["current"]) == int(a["hp"]["max"]))
|
||||
ok("Zauberplätze erneuert",
|
||||
(Game.party[2]["spells"]["used"] as Array).is_empty())
|
||||
ok("Vorräte verbraucht", Game.inventar_hat(a, "vorrat") < vorrat_vorher)
|
||||
ok("keine Begegnung in der Stadt", str(r.get("kampf", "")) == "")
|
||||
|
||||
# Ohne Vorräte: nur halbe TP, keine neuen Zauberplätze.
|
||||
_leere_vorraete()
|
||||
var b: Dictionary = Game.party[1]
|
||||
b["hp"]["current"] = 1
|
||||
Game.party[2]["spells"]["used"] = ["magisches_geschoss"]
|
||||
var r2: Dictionary = Game.rasten(false)
|
||||
var erwartet := mini(int(b["hp"]["max"]),
|
||||
1 + int(ceil(int(b["hp"]["max"]) / 2.0)))
|
||||
ok("Ohne Vorrat: halbe TP (%d)" % int(b["hp"]["current"]),
|
||||
int(b["hp"]["current"]) == erwartet)
|
||||
ok("Ohne Vorrat: keine Zauberplätze",
|
||||
not (Game.party[2]["spells"]["used"] as Array).is_empty())
|
||||
|
||||
# Im Freien: irgendwann stört eine Begegnung, und sie kommt aus der Karte.
|
||||
_fuelle_vorraete(40)
|
||||
seed(7)
|
||||
var kampf := ""
|
||||
var versuche := 0
|
||||
while kampf.is_empty() and versuche < 60:
|
||||
versuche += 1
|
||||
kampf = str(Game.rasten(true).get("kampf", ""))
|
||||
ok("Rast im Freien wird gestört (nach %d Versuchen)" % versuche,
|
||||
not kampf.is_empty())
|
||||
var tabelle: Array = Content.entry("maps", "westmark").get("encounters", {}).get("table", [])
|
||||
ok("Begegnung stammt aus der Karte (%s)" % kampf, tabelle.has(kampf))
|
||||
|
||||
print("\nProbe: %s" % ("bestanden" if fehler == 0 else "FEHLGESCHLAGEN"))
|
||||
get_tree().quit(0 if fehler == 0 else 1)
|
||||
|
||||
|
||||
func _fuelle_vorraete(n: int) -> void:
|
||||
for figur in Game.party:
|
||||
var fehlt := n - Game.inventar_hat(figur, "vorrat")
|
||||
for i in maxi(0, fehlt):
|
||||
Game.inventar_hinzufuegen(figur, "vorrat")
|
||||
|
||||
|
||||
func _leere_vorraete() -> void:
|
||||
for figur in Game.party:
|
||||
Game.inventar_entfernen(figur, "vorrat", 99)
|
||||
|
||||
|
||||
func ok(name: String, wahr: bool) -> void:
|
||||
if not wahr:
|
||||
fehler += 1
|
||||
print(" %s %s" % [("ok " if wahr else "FEHL"), name])
|
||||
1
game/tools/probe_rasten.gd.uid
Normal file
1
game/tools/probe_rasten.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c7y8kwf0n00dn
|
||||
6
game/tools/probe_rasten.tscn
Normal file
6
game/tools/probe_rasten.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://tools/probe_rasten.gd" id="1_rast"]
|
||||
|
||||
[node name="ProbeRasten" type="Node"]
|
||||
script = ExtResource("1_rast")
|
||||
Loading…
Add table
Add a link
Reference in a new issue