game: Inventar — Tausch, Traglast, Seiten, Laterne, Tränke, Drag & Drop

This commit is contained in:
torsten 2026-11-17 15:27:37 +01:00
parent a78de0ffec
commit 01c312d918
30 changed files with 539 additions and 58 deletions

View file

@ -35,6 +35,7 @@ func _neue_party() -> void:
"attributes": {"str": 11, "dex": 17, "con": 12, "int": 12, "wis": 10, "cha": 13}},
]
party = []
gold = START_GOLD
for i in vorgabe.size():
party.append(neue_figur("pc_%d" % (i + 1), vorgabe[i]))
@ -44,6 +45,7 @@ func _neue_party() -> void:
func party_leeren() -> void:
party = []
gold = START_GOLD
## Nimmt eine Figur auf. Bei vollem Roster (6) kommt `{}` zurück — der Aufrufer
## fragt vorher `party_bereit()` oder prüft das Ergebnis.
@ -231,6 +233,53 @@ func ausruesten(figur: Dictionary, id: String) -> bool:
return true
## Gesamtgewicht inklusive ausgerüsteter Stücke.
func gewicht(figur: Dictionary) -> int:
var summe := 0
for eintrag in figur.get("inventory", []):
var id := ""
var anzahl := 1
if typeof(eintrag) == TYPE_DICTIONARY:
id = str(eintrag.get("id", ""))
anzahl = int(eintrag.get("count", 1))
else:
id = str(eintrag)
summe += int(Content.entry("items", id).get("weight", 1)) * anzahl
var equipment: Dictionary = figur.get("equipment", {})
for feld in ["weapon", "armor"]:
var id := str(equipment.get(feld, ""))
if not id.is_empty():
summe += int(Content.entry("items", id).get("weight", 1))
if bool(equipment.get("shield", false)):
summe += int(Content.entry("items", "schild").get("weight", 1))
return summe
## Traglast: 10 + STÄ. Kein Feld in den Daten, weil sie aus den Attributen folgt.
func kapazitaet(figur: Dictionary) -> int:
return 10 + int(figur.get("attributes", {}).get("str", 10))
## Ein Gegenstand wandert zwischen zwei Figuren; die Traglast des Ziels zählt.
func geben(von: Dictionary, an: Dictionary, id: String, anzahl: int = 1) -> String:
if str(von.get("id", "")) == str(an.get("id", "")):
return "Das ist dieselbe Figur."
if inventar_hat(von, id) < anzahl:
return "Nicht genug im Rucksack."
var einzel := int(Content.entry("items", id).get("weight", 1))
var last := gewicht(an) + einzel * anzahl
if last > kapazitaet(an):
return "%s ist überladen (%d/%d)." % [
str(an.get("name", "?")), last, kapazitaet(an)]
inventar_entfernen(von, id, anzahl)
inventar_hinzufuegen(an, id, anzahl)
return "%s → %s." % [_item_name(id), str(an.get("name", "?"))]
func _item_name(id: String) -> String:
return str(Content.entry("items", id).get("name", id))
## Verbrauchsgüter. Gibt eine Meldung für die UI zurück.
func benutzen(figur: Dictionary, id: String) -> String:
if inventar_hat(figur, id) <= 0:
@ -249,6 +298,16 @@ func benutzen(figur: Dictionary, id: String) -> String:
"laterne":
flags["licht"] = not bool(flags.get("licht", false))
return "Laterne %s." % ("an" if flags["licht"] else "aus")
"trank_heilung":
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("2d6+2")
tp["current"] = mini(int(tp.get("max", 0)),
int(tp.get("current", 0)) + heilung)
figur["hp"] = tp
inventar_entfernen(figur, id)
return "Heiltrank: +%d TP." % heilung
"seil":
return "Seil: noch keine Anwendung."
return "Nicht benutzbar."