game: Engine-Gerüst mit datengetriebenen Inhalten; Titelgrafik über fal
Godot-Projekt nach docs/engine.md: 640x360-Viewport, stretch=viewport, scale_mode=integer, 1x-Assets in game/assets/. Autoloads Content (laden und prüfen), Rules (Effekt-Vokabel), Game (Party, Ort, abgeleitete Werte), Saves (versionierter Spielstand, nur Eingaben). Inhalte liegen vollständig als JSON in game/data/ und werden gegen _schema.json geprüft: 4 Völker, 4 Klassen, 9 Fertigkeiten, 16 Fähigkeiten, 18 Zauber, 11 Gegenstände, 8 Gegner, 4 Begegnungen, 3 NSC, 1 Karte (20x11). Die Engine nennt keine Klasse und keinen Zauber beim Namen — alles über ids, Verhalten ausschließlich über 13 Effekt-ops. Beim ersten Content-Durchlauf ist die Vokabel um turn_undead und immunity gewachsen, bonus kennt multiplier; genau das war der Zweck der Übung. Zwei Prüfer, eine Wahrheit: tools/validate_data.py (ohne Godot, für Commit/CI) und ContentDB beim Start. Beide lesen dieselbe _schema.json; unbekanntes op oder fehlender Verweis bricht ab statt still zu wirken. Selbstprüfung im Projekt (godot --headless --path game -- --check) ist grün: Daten geladen, Würfel 2d6+1, Modifikator, Effekt Magisches Geschoss, Spielstand schreiben/lesen/identisch, Font im Engine-Raster (2 Zeichen = 16 px, Zeile 12). Letzteres belegt erstmals, dass der BMFont-Export aus art/final/Font in der Engine sitzt. Titelgrafik über fal (FLUX.2 [pro], 1536x864, Seed 771201, 0,04 USD, request_id 01a1dc5a-871a-7511-b8f8-571988a47c18): zwei vermummte Pilger vor dem Tor von Garana. Der erste Lauf (Seed 20261115) zeigte moderne Wanderer mit Rucksäcken und ist verworfen; beide stehen im Lizenzlog. pixelize.py bekam --crop, weil das Modell eine Signatur in die Ecke malt. Achtung: das Projekt wurde headless importiert (godot --import); die *.import-Dateien gehören ins Repo, .godot/ nicht. Für den Export muss include_filter="*.json" gesetzt werden, sonst fehlen die Inhalte im Build.
This commit is contained in:
parent
8ed8f4bbf6
commit
6114bef956
99 changed files with 4777 additions and 28 deletions
108
game/scripts/systems/game_state.gd
Normal file
108
game/scripts/systems/game_state.gd
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
extends Node
|
||||
## Game (Autoload) — der Spielzustand: Party, Ort, Zeit, Flaggen.
|
||||
##
|
||||
## Gespeichert werden **Eingaben**, keine abgeleiteten Werte (docs/engine.md §7):
|
||||
## TP ja, RK nein. Wird eine Klasse nachbalanciert, korrigiert der nächste
|
||||
## Ladevorgang die Ableitung automatisch.
|
||||
|
||||
const START = "garana"
|
||||
|
||||
var party: Array = [] ## Array von Dictionaries (ids + Werte)
|
||||
var place: Dictionary = {"id": START, "x": 9, "y": 9}
|
||||
var time: Dictionary = {"day": 1, "slot": 0}
|
||||
var flags: Dictionary = {}
|
||||
var log_lines: Array[String] = []
|
||||
|
||||
func _ready() -> void:
|
||||
if party.is_empty():
|
||||
_neue_party()
|
||||
|
||||
## Vier Figuren, wie in docs/systeme.md §11 durchgerechnet.
|
||||
func _neue_party() -> void:
|
||||
var vorgabe := [
|
||||
{"name": "Aldric", "race": "human", "class": "fighter",
|
||||
"attributes": {"str": 16, "dex": 12, "con": 14, "int": 10, "wis": 9, "cha": 11}},
|
||||
{"name": "Bruna", "race": "dwarf", "class": "cleric",
|
||||
"attributes": {"str": 12, "dex": 9, "con": 15, "int": 10, "wis": 16, "cha": 11}},
|
||||
{"name": "Cael", "race": "elf", "class": "magier",
|
||||
"attributes": {"str": 8, "dex": 15, "con": 11, "int": 17, "wis": 12, "cha": 10}},
|
||||
{"name": "Dorn", "race": "halfling", "class": "thief",
|
||||
"attributes": {"str": 11, "dex": 17, "con": 12, "int": 12, "wis": 10, "cha": 13}},
|
||||
]
|
||||
party = []
|
||||
for i in vorgabe.size():
|
||||
party.append(neue_figur("pc_%d" % (i + 1), vorgabe[i]))
|
||||
|
||||
func neue_figur(id: String, vorgabe: Dictionary) -> Dictionary:
|
||||
var klasse: Dictionary = Content.class_def(str(vorgabe["class"]))
|
||||
var volk: Dictionary = Content.entry("races", str(vorgabe["race"]))
|
||||
var attrs: Dictionary = vorgabe["attributes"].duplicate()
|
||||
for attribut in volk.get("attribute_mods", {}):
|
||||
attrs[attribut] = int(attrs.get(attribut, 10)) + int(volk["attribute_mods"][attribut])
|
||||
var hp_max := _hp_stufe1(klasse, attrs)
|
||||
return {
|
||||
"id": id, "name": vorgabe["name"],
|
||||
"race": vorgabe["race"], "class": vorgabe["class"],
|
||||
"level": 1, "xp": 0,
|
||||
"attributes": attrs,
|
||||
"hp": {"current": hp_max, "max": hp_max},
|
||||
"skills": _startfertigkeiten(klasse),
|
||||
"spells": {"known": [], "prepared": [], "slots": {}},
|
||||
"inventory": [], "equipment": {},
|
||||
"conditions": [],
|
||||
}
|
||||
|
||||
func _hp_stufe1(klasse: Dictionary, attrs: Dictionary) -> int:
|
||||
var kon := Dice.modifier(int(attrs.get("con", 10)))
|
||||
return maxi(1, int(klasse.get("hit_die", 6)) + kon)
|
||||
|
||||
func _startfertigkeiten(klasse: Dictionary) -> Dictionary:
|
||||
var out := {}
|
||||
for id in klasse.get("trained_skills", []):
|
||||
var fertigkeit: Dictionary = Content.skill(str(id))
|
||||
out[str(id)] = int(fertigkeit.get("trained_bonus", 3))
|
||||
return out
|
||||
|
||||
## Abgeleitete Werte werden gerechnet, nie gespeichert.
|
||||
func rk(figur: Dictionary) -> int:
|
||||
var ac := 10 + Dice.modifier(int(figur["attributes"].get("dex", 10)))
|
||||
var ruestung: Dictionary = Content.entry("items", str(figur.get("equipment", {}).get("armor", "")))
|
||||
ac += int(ruestung.get("ac_bonus", 0))
|
||||
if figur.get("equipment", {}).get("shield", false):
|
||||
var schild: Dictionary = Content.entry("items", "schild")
|
||||
ac += int(schild.get("ac_bonus", 1))
|
||||
return ac
|
||||
|
||||
func angriffsbonus(figur: Dictionary) -> int:
|
||||
var klasse: Dictionary = Content.class_def(str(figur["class"]))
|
||||
var stufe := int(figur.get("level", 1))
|
||||
var leiter: Array = klasse.get("attack_per_level", [])
|
||||
if stufe - 1 < leiter.size():
|
||||
return int(leiter[stufe - 1])
|
||||
return int(leiter[leiter.size() - 1]) if not leiter.is_empty() else 0
|
||||
|
||||
func notiz(text: String) -> void:
|
||||
log_lines.append(text)
|
||||
if log_lines.size() > 200:
|
||||
log_lines.pop_front()
|
||||
|
||||
# ------------------------------------------------------------- speichern ----
|
||||
|
||||
func to_dict() -> Dictionary:
|
||||
return {
|
||||
"save_version": Saves.VERSION,
|
||||
"place": place,
|
||||
"time": time,
|
||||
"party": party,
|
||||
"flags": flags,
|
||||
"log": log_lines,
|
||||
}
|
||||
|
||||
func from_dict(d: Dictionary) -> void:
|
||||
place = d.get("place", place)
|
||||
time = d.get("time", time)
|
||||
party = d.get("party", party)
|
||||
flags = d.get("flags", {})
|
||||
log_lines = []
|
||||
for zeile in d.get("log", []):
|
||||
log_lines.append(str(zeile))
|
||||
1
game/scripts/systems/game_state.gd.uid
Normal file
1
game/scripts/systems/game_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cs08vyu6o3j4c
|
||||
40
game/scripts/systems/save.gd
Normal file
40
game/scripts/systems/save.gd
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
extends Node
|
||||
## Saves (Autoload) — Spielstand schreiben und lesen (docs/engine.md §7).
|
||||
##
|
||||
## Format: JSON unter user://, mit `save_version`. Gespeichert werden nur
|
||||
## Eingaben; abgeleitete Werte (RK, Angriffsbonus) rechnet Game neu.
|
||||
## Eine unbekannte Version wird nicht stillschweigend geladen.
|
||||
|
||||
const VERSION := 1
|
||||
const ORDNER := "user://saves"
|
||||
|
||||
func pfad(slot: int = 0) -> String:
|
||||
return "%s/slot_%d.json" % [ORDNER, slot]
|
||||
|
||||
func write(slot: int = 0) -> bool:
|
||||
DirAccess.make_dir_recursive_absolute(ORDNER)
|
||||
var datei := FileAccess.open(pfad(slot), FileAccess.WRITE)
|
||||
if datei == null:
|
||||
push_error("Saves: kann %s nicht schreiben (%s)" % [pfad(slot), FileAccess.get_open_error()])
|
||||
return false
|
||||
datei.store_string(JSON.stringify(Game.to_dict(), "\t"))
|
||||
datei.close()
|
||||
return true
|
||||
|
||||
func read(slot: int = 0) -> Dictionary:
|
||||
if not FileAccess.file_exists(pfad(slot)):
|
||||
push_error("Saves: %s fehlt" % pfad(slot))
|
||||
return {}
|
||||
var wert: Variant = JSON.parse_string(FileAccess.get_file_as_string(pfad(slot)))
|
||||
if typeof(wert) != TYPE_DICTIONARY:
|
||||
push_error("Saves: %s ist kein gültiges JSON" % pfad(slot))
|
||||
return {}
|
||||
var d: Dictionary = wert
|
||||
var version := int(d.get("save_version", 0))
|
||||
if version != VERSION:
|
||||
push_error("Saves: Version %d, erwartet %d — Migration fehlt" % [version, VERSION])
|
||||
return {}
|
||||
return d
|
||||
|
||||
func exists(slot: int = 0) -> bool:
|
||||
return FileAccess.file_exists(pfad(slot))
|
||||
1
game/scripts/systems/save.gd.uid
Normal file
1
game/scripts/systems/save.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c1ilk2h82eajk
|
||||
Loading…
Add table
Add a link
Reference in a new issue