game: Rast und Tag — Vorräte, volle/halbe Erholung, gestörte Rast im Freien

This commit is contained in:
torsten 2026-11-17 22:59:40 +01:00
parent 71816d8117
commit 79bace9880
11 changed files with 191 additions and 17 deletions

View file

@ -630,6 +630,60 @@ func ablegen(figur: Dictionary, slot: String) -> bool:
figur["equipment"] = equipment
return true
## Rasten: ein Tag vergeht, TP und Zauberplätze füllen sich — mit Vorräten
## voll, ohne nur halb. Im Freien besteht ein Risiko auf eine Begegnung.
## Gibt {"ok", "text", "kampf"} zurück; `kampf` ist eine Encounter-id oder "".
func rasten(im_freien: bool) -> Dictionary:
if party.is_empty():
return {"ok": false, "text": "Keine Partei.", "kampf": ""}
# Ein Vorrat je Figur für eine volle Rast.
var gebraucht := party.size()
var vorhanden := 0
for figur in party:
vorhanden += inventar_hat(figur, "vorrat")
var voll := vorhanden >= gebraucht
var verbraucht := 0
if voll:
for figur in party:
var noch := gebraucht - verbraucht
if noch <= 0:
break
var n := mini(noch, inventar_hat(figur, "vorrat"))
inventar_entfernen(figur, "vorrat", n)
verbraucht += n
for figur in party:
var tp: Dictionary = figur.get("hp", {})
if voll:
tp["current"] = int(tp.get("max", 1))
zauberplaetze_auffrischen(figur)
else:
tp["current"] = mini(int(tp.get("max", 1)),
int(tp.get("current", 0)) + int(ceil(int(tp.get("max", 1)) / 2.0)))
figur["hp"] = tp
time["day"] = int(time.get("day", 1)) + 1
var text := ""
if voll:
text = "Rast: TP voll, Zauberplätze erneuert (%d Vorrat verbraucht). Tag %d." % [
gebraucht, int(time["day"])]
else:
text = "Ohne Vorräte: nur halbe TP, keine neuen Zauberplätze. Tag %d." % int(time["day"])
notiz(text)
# Im Freien kann die Rast gestört werden.
var kampf := ""
if im_freien and randi_range(1, 100) <= 25:
var karte: Dictionary = Content.entry("maps", str(place.get("id", "")))
var tabelle: Array = karte.get("encounters", {}).get("table", [])
if tabelle.is_empty():
kampf = "goblins_drei"
else:
kampf = str(tabelle[randi_range(0, tabelle.size() - 1)])
text += " Die Rast wird gestört!"
return {"ok": true, "text": text, "kampf": kampf}
func notiz(text: String) -> void:
log_lines.append(text)
if log_lines.size() > 200: