game: Inventar-Raster mit Icons, Klassenregeln, Gold und Verbrauch

This commit is contained in:
torsten 2026-11-17 15:15:06 +01:00
parent 3fae74b1e8
commit a78de0ffec
61 changed files with 1047 additions and 148 deletions

View file

@ -7,8 +7,10 @@ extends Node
const START = "garana"
const PARTY_MAX := 6
const START_GOLD := 20
var party: Array = [] ## Array von Dictionaries (ids + Werte)
var gold := START_GOLD ## Parteigold; Ausgaben kommen später dazu
var place: Dictionary = {"id": START, "x": 9, "y": 9}
var time: Dictionary = {"day": 1, "slot": 0}
var flags: Dictionary = {}
@ -188,6 +190,21 @@ func inventar_entfernen(figur: Dictionary, id: String, anzahl: int = 1) -> bool:
return false
## Klassenbeschränkung aus `classes.json` (`weapons`, `armor`).
func ausruesten_erlaubt(figur: Dictionary, id: String) -> bool:
var item: Dictionary = Content.entry("items", id)
var typ := str(item.get("type", ""))
var klasse: Dictionary = Content.class_def(str(figur.get("class", "")))
match typ:
"weapon":
return klasse.get("weapons", []).has(id)
"armor":
return klasse.get("armor", []).has(id)
"shield":
return klasse.get("armor", []).has("schild")
return false
func ausruesten(figur: Dictionary, id: String) -> bool:
var item: Dictionary = Content.entry("items", id)
if item.is_empty():
@ -195,6 +212,8 @@ func ausruesten(figur: Dictionary, id: String) -> bool:
var typ := str(item.get("type", ""))
if typ not in ["weapon", "armor", "shield"]:
return false
if not ausruesten_erlaubt(figur, id):
return false
if inventar_hat(figur, id) <= 0:
return false
var equipment: Dictionary = figur.get("equipment", {})
@ -212,6 +231,29 @@ func ausruesten(figur: Dictionary, id: String) -> bool:
return true
## Verbrauchsgüter. Gibt eine Meldung für die UI zurück.
func benutzen(figur: Dictionary, id: String) -> String:
if inventar_hat(figur, id) <= 0:
return "Nicht im Rucksack."
match id:
"vorrat":
var tp: Dictionary = figur.get("hp", {})
if int(tp.get("current", 0)) >= int(tp.get("max", 0)):
return "TP sind voll."
var heilung: int = Dice.roll("1d6")
tp["current"] = mini(int(tp.get("max", 0)),
int(tp.get("current", 0)) + heilung)
figur["hp"] = tp
inventar_entfernen(figur, id)
return "Vorrat: +%d TP." % heilung
"laterne":
flags["licht"] = not bool(flags.get("licht", false))
return "Laterne %s." % ("an" if flags["licht"] else "aus")
"seil":
return "Seil: noch keine Anwendung."
return "Nicht benutzbar."
func ablegen(figur: Dictionary, slot: String) -> bool:
var equipment: Dictionary = figur.get("equipment", {})
if slot == "shield":
@ -240,6 +282,7 @@ func to_dict() -> Dictionary:
"save_version": Saves.VERSION,
"place": place,
"time": time,
"gold": gold,
"party": party,
"flags": flags,
"log": log_lines,
@ -248,6 +291,7 @@ func to_dict() -> Dictionary:
func from_dict(d: Dictionary) -> void:
place = d.get("place", place)
time = d.get("time", time)
gold = int(d.get("gold", gold))
party = d.get("party", party)
flags = d.get("flags", {})
log_lines = []