game: Inventar und fünf Vollbilder in 1920 — Titel scharf, Startgepäck
|
Before Width: | Height: | Size: 224 KiB |
BIN
game/assets/pictures/szene_waffenhaendler_1920x1080.png
Normal file
|
After Width: | Height: | Size: 3.6 MiB |
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://jilkyjxbqbek"
|
||||
path="res://.godot/imported/szene_waffenhaendler_1280x720.png-bc52671f0ee0a37a93c7cbb02608bae1.ctex"
|
||||
uid="uid://cgcc1m8gtxfqk"
|
||||
path="res://.godot/imported/szene_waffenhaendler_1920x1080.png-af637714c5432ad4d5a90f027d18ffd8.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/pictures/szene_waffenhaendler_1280x720.png"
|
||||
dest_files=["res://.godot/imported/szene_waffenhaendler_1280x720.png-bc52671f0ee0a37a93c7cbb02608bae1.ctex"]
|
||||
source_file="res://assets/pictures/szene_waffenhaendler_1920x1080.png"
|
||||
dest_files=["res://.godot/imported/szene_waffenhaendler_1920x1080.png-af637714c5432ad4d5a90f027d18ffd8.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 87 KiB |
BIN
game/assets/pictures/taverne_A_1920x1080.png
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b6me75643b6db"
|
||||
path="res://.godot/imported/waldrand_1280x720.png-fd46593f7be7fdc709c5357000adcf56.ctex"
|
||||
uid="uid://dcxkbymhn1s0h"
|
||||
path="res://.godot/imported/taverne_A_1920x1080.png-8e829b3be4088d7915656d7cfa942d54.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/pictures/waldrand_1280x720.png"
|
||||
dest_files=["res://.godot/imported/waldrand_1280x720.png-fd46593f7be7fdc709c5357000adcf56.ctex"]
|
||||
source_file="res://assets/pictures/taverne_A_1920x1080.png"
|
||||
dest_files=["res://.godot/imported/taverne_A_1920x1080.png-8e829b3be4088d7915656d7cfa942d54.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 253 KiB |
BIN
game/assets/pictures/taverne_B_1920x1080.png
Normal file
|
After Width: | Height: | Size: 3.4 MiB |
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ckaa4u5qh6oo7"
|
||||
path="res://.godot/imported/taverne_A_1280x720.png-0a0c3436c9acbc531edf89cd45a634d0.ctex"
|
||||
uid="uid://dnamrf1i6h8vj"
|
||||
path="res://.godot/imported/taverne_B_1920x1080.png-6bc28e4b34f43fb9f279e074337108a8.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/pictures/taverne_A_1280x720.png"
|
||||
dest_files=["res://.godot/imported/taverne_A_1280x720.png-0a0c3436c9acbc531edf89cd45a634d0.ctex"]
|
||||
source_file="res://assets/pictures/taverne_B_1920x1080.png"
|
||||
dest_files=["res://.godot/imported/taverne_B_1920x1080.png-6bc28e4b34f43fb9f279e074337108a8.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 309 KiB |
BIN
game/assets/pictures/titel_westreich_1920x1080.png
Normal file
|
After Width: | Height: | Size: 3.7 MiB |
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://buynp0nbf1c28"
|
||||
path="res://.godot/imported/titel_westreich_1280x720.png-0dfbda1464b68dc38ea6d232adb67959.ctex"
|
||||
uid="uid://c4mxh0h6eunpl"
|
||||
path="res://.godot/imported/titel_westreich_1920x1080.png-68c5024fc1cb4afbdf92a0d4708aaaa4.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/pictures/titel_westreich_1280x720.png"
|
||||
dest_files=["res://.godot/imported/titel_westreich_1280x720.png-0dfbda1464b68dc38ea6d232adb67959.ctex"]
|
||||
source_file="res://assets/pictures/titel_westreich_1920x1080.png"
|
||||
dest_files=["res://.godot/imported/titel_westreich_1920x1080.png-68c5024fc1cb4afbdf92a0d4708aaaa4.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 206 KiB |
BIN
game/assets/pictures/waldrand_1920x1080.png
Normal file
|
After Width: | Height: | Size: 3.8 MiB |
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bqexa8f687emr"
|
||||
path="res://.godot/imported/taverne_B_1280x720.png-f1e021ba1101602bcfc88b1701209179.ctex"
|
||||
uid="uid://cndvw0dd3pcs7"
|
||||
path="res://.godot/imported/waldrand_1920x1080.png-b0b77adb2138a7382c713472ff6d4fc1.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/pictures/taverne_B_1280x720.png"
|
||||
dest_files=["res://.godot/imported/taverne_B_1280x720.png-f1e021ba1101602bcfc88b1701209179.ctex"]
|
||||
source_file="res://assets/pictures/waldrand_1920x1080.png"
|
||||
dest_files=["res://.godot/imported/waldrand_1920x1080.png-b0b77adb2138a7382c713472ff6d4fc1.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -44,7 +44,11 @@
|
|||
"starting_equipment": {
|
||||
"armor": "kette",
|
||||
"shield": true,
|
||||
"weapon": "schwert"
|
||||
"weapon": "schwert",
|
||||
"items": [
|
||||
"vorrat",
|
||||
"seil"
|
||||
]
|
||||
}
|
||||
},
|
||||
"cleric": {
|
||||
|
|
@ -119,7 +123,11 @@
|
|||
"starting_equipment": {
|
||||
"armor": "leder",
|
||||
"shield": true,
|
||||
"weapon": "keule"
|
||||
"weapon": "keule",
|
||||
"items": [
|
||||
"vorrat",
|
||||
"seil"
|
||||
]
|
||||
}
|
||||
},
|
||||
"magier": {
|
||||
|
|
@ -187,7 +195,11 @@
|
|||
}
|
||||
],
|
||||
"starting_equipment": {
|
||||
"weapon": "stab"
|
||||
"weapon": "stab",
|
||||
"items": [
|
||||
"vorrat",
|
||||
"laterne"
|
||||
]
|
||||
}
|
||||
},
|
||||
"thief": {
|
||||
|
|
@ -238,7 +250,11 @@
|
|||
"starting_equipment": {
|
||||
"armor": "leder",
|
||||
"shield": false,
|
||||
"weapon": "dolch"
|
||||
"weapon": "dolch",
|
||||
"items": [
|
||||
"vorrat",
|
||||
"laterne"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ signal neu
|
|||
signal weiter(slot: int)
|
||||
|
||||
const THEME := preload("res://scripts/ui/ui_theme.gd")
|
||||
const BILD := "res://assets/pictures/titel_westreich_1280x720.png"
|
||||
const BILD := "res://assets/pictures/titel_westreich_1920x1080.png"
|
||||
const TITEL := "res://assets/ui/titel_taloria.png"
|
||||
|
||||
var _wurzel: Control
|
||||
|
|
|
|||
237
game/scenes/ui/inventar.gd
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
extends Control
|
||||
## Inventar als Modal über der Karte (docs/ui.md §1).
|
||||
##
|
||||
## Zeigt pro Party-Figur die ausgerüsteten Slots und den Rucksack. Ausrüsten
|
||||
## nimmt ein Stück aus dem Rucksack, Ablegen legt es zurück; die RK kommt aus
|
||||
## `Game.rk()` und ändert sich sofort.
|
||||
|
||||
signal geschlossen
|
||||
|
||||
const THEME := preload("res://scripts/ui/ui_theme.gd")
|
||||
|
||||
const SLOTS := [
|
||||
{"key": "weapon", "label": "Waffe"},
|
||||
{"key": "armor", "label": "Rüstung"},
|
||||
{"key": "shield", "label": "Schild"},
|
||||
]
|
||||
|
||||
var _index := 0
|
||||
var _wurzel: Control
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
theme = THEME.baue()
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
_wurzel = Control.new()
|
||||
_wurzel.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
add_child(_wurzel)
|
||||
_bauen()
|
||||
|
||||
|
||||
func _bauen() -> void:
|
||||
_leeren(_wurzel)
|
||||
|
||||
var dimm := UiTheme.dimmung()
|
||||
dimm.color = Color(0.04, 0.03, 0.02, 0.72)
|
||||
_wurzel.add_child(dimm)
|
||||
|
||||
var p := Panel.new()
|
||||
p.position = Vector2(260, 160)
|
||||
p.size = Vector2(1400, 760)
|
||||
p.add_theme_stylebox_override("panel", THEME.flaeche(Color(1, 1, 1)))
|
||||
_wurzel.add_child(p)
|
||||
|
||||
var titel := Label.new()
|
||||
titel.text = "INVENTAR"
|
||||
titel.position = Vector2(40, 24)
|
||||
titel.add_theme_color_override("font_color", UiTheme.GOLD)
|
||||
p.add_child(titel)
|
||||
|
||||
# Partei-Reiter
|
||||
var x := 40
|
||||
for i in Game.party.size():
|
||||
var b := Button.new()
|
||||
b.text = str(Game.party[i].get("name", "?"))
|
||||
b.position = Vector2(x, 80)
|
||||
b.size = Vector2(170, 52)
|
||||
b.focus_mode = Control.FOCUS_NONE
|
||||
b.clip_text = true
|
||||
b.modulate = Color(1.45, 1.25, 0.95) if i == _index else Color(1, 1, 1)
|
||||
b.pressed.connect(_waehlen.bind(i))
|
||||
p.add_child(b)
|
||||
x += 180
|
||||
|
||||
if Game.party.is_empty():
|
||||
var leer := Label.new()
|
||||
leer.text = "Keine Figur in der Party."
|
||||
leer.position = Vector2(40, 180)
|
||||
p.add_child(leer)
|
||||
_schliessen_knopf(p)
|
||||
return
|
||||
|
||||
var figur: Dictionary = Game.party[_index]
|
||||
_ausgeruestet(p, figur)
|
||||
_rucksack(p, figur)
|
||||
|
||||
var werte := Label.new()
|
||||
werte.text = "RK %d Angriff +%d TP %d/%d" % [
|
||||
Game.rk(figur), Game.angriffsbonus(figur),
|
||||
int(figur["hp"]["current"]), int(figur["hp"]["max"])]
|
||||
werte.position = Vector2(40, 680)
|
||||
werte.size = Vector2(700, 40)
|
||||
werte.clip_text = true
|
||||
p.add_child(werte)
|
||||
|
||||
_schliessen_knopf(p)
|
||||
|
||||
|
||||
func _ausgeruestet(p: Panel, figur: Dictionary) -> void:
|
||||
var kopf := Label.new()
|
||||
kopf.text = "AUSGERÜSTET"
|
||||
kopf.position = Vector2(40, 160)
|
||||
kopf.add_theme_color_override("font_color", UiTheme.GOLD)
|
||||
p.add_child(kopf)
|
||||
|
||||
var equipment: Dictionary = figur.get("equipment", {})
|
||||
for i in SLOTS.size():
|
||||
var slot: Dictionary = SLOTS[i]
|
||||
var y := 210 + i * 84
|
||||
var slot_label := Label.new()
|
||||
slot_label.text = str(slot["label"])
|
||||
slot_label.position = Vector2(40, y)
|
||||
slot_label.size = Vector2(160, 52)
|
||||
slot_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
slot_label.clip_text = true
|
||||
p.add_child(slot_label)
|
||||
|
||||
var id := ""
|
||||
if str(slot["key"]) == "shield":
|
||||
if bool(equipment.get("shield", false)):
|
||||
id = "schild"
|
||||
else:
|
||||
id = str(equipment.get(slot["key"], ""))
|
||||
|
||||
var wert := Label.new()
|
||||
wert.text = _item_name(id) if not id.is_empty() else "—"
|
||||
wert.position = Vector2(210, y)
|
||||
wert.size = Vector2(260, 52)
|
||||
wert.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
wert.clip_text = true
|
||||
wert.modulate = Color(0.9, 0.84, 0.70)
|
||||
p.add_child(wert)
|
||||
|
||||
if not id.is_empty():
|
||||
var b := Button.new()
|
||||
b.text = "Ablegen"
|
||||
b.position = Vector2(480, y)
|
||||
b.size = Vector2(200, 52)
|
||||
b.focus_mode = Control.FOCUS_NONE
|
||||
b.clip_text = true
|
||||
b.pressed.connect(_ablegen.bind(str(slot["key"])))
|
||||
p.add_child(b)
|
||||
|
||||
|
||||
func _rucksack(p: Panel, figur: Dictionary) -> void:
|
||||
var kopf := Label.new()
|
||||
kopf.text = "RUCKSACK"
|
||||
kopf.position = Vector2(720, 160)
|
||||
kopf.add_theme_color_override("font_color", UiTheme.GOLD)
|
||||
p.add_child(kopf)
|
||||
|
||||
var inventar: Array = figur.get("inventory", [])
|
||||
if inventar.is_empty():
|
||||
var leer := Label.new()
|
||||
leer.text = "leer"
|
||||
leer.position = Vector2(720, 210)
|
||||
leer.modulate = Color(0.75, 0.70, 0.60)
|
||||
p.add_child(leer)
|
||||
return
|
||||
|
||||
for i in inventar.size():
|
||||
var eintrag = inventar[i]
|
||||
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)
|
||||
if id.is_empty():
|
||||
continue
|
||||
var y := 210 + i * 56
|
||||
if y > 700:
|
||||
break
|
||||
|
||||
var item_label := Label.new()
|
||||
item_label.text = _item_name(id)
|
||||
item_label.position = Vector2(720, y)
|
||||
item_label.size = Vector2(340, 44)
|
||||
item_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
item_label.clip_text = true
|
||||
p.add_child(item_label)
|
||||
|
||||
if anzahl > 1:
|
||||
var zahl := Label.new()
|
||||
zahl.text = "x%d" % anzahl
|
||||
zahl.position = Vector2(1070, y)
|
||||
zahl.size = Vector2(40, 44)
|
||||
zahl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
p.add_child(zahl)
|
||||
|
||||
if _ist_ausruestbar(id):
|
||||
var b := Button.new()
|
||||
b.text = "Ausrüsten"
|
||||
b.position = Vector2(1120, y)
|
||||
b.size = Vector2(250, 44)
|
||||
b.focus_mode = Control.FOCUS_NONE
|
||||
b.clip_text = true
|
||||
b.pressed.connect(_ausruesten.bind(id))
|
||||
p.add_child(b)
|
||||
|
||||
|
||||
func _schliessen_knopf(p: Panel) -> void:
|
||||
var b := Button.new()
|
||||
b.text = "Schließen"
|
||||
b.position = Vector2(1120, 680)
|
||||
b.size = Vector2(240, 56)
|
||||
b.focus_mode = Control.FOCUS_NONE
|
||||
b.clip_text = true
|
||||
b.pressed.connect(func() -> void: geschlossen.emit())
|
||||
p.add_child(b)
|
||||
|
||||
|
||||
func _waehlen(index: int) -> void:
|
||||
_index = index
|
||||
_bauen()
|
||||
|
||||
|
||||
func _ausruesten(id: String) -> void:
|
||||
if Game.party.is_empty():
|
||||
return
|
||||
Game.ausruesten(Game.party[_index], id)
|
||||
_bauen()
|
||||
|
||||
|
||||
func _ablegen(slot: String) -> void:
|
||||
if Game.party.is_empty():
|
||||
return
|
||||
Game.ablegen(Game.party[_index], slot)
|
||||
_bauen()
|
||||
|
||||
|
||||
func _item_name(id: String) -> String:
|
||||
if id.is_empty():
|
||||
return "—"
|
||||
var item: Dictionary = Content.entry("items", id)
|
||||
return str(item.get("name", id))
|
||||
|
||||
|
||||
func _ist_ausruestbar(id: String) -> bool:
|
||||
var typ := str(Content.entry("items", id).get("type", ""))
|
||||
return typ in ["weapon", "armor", "shield"]
|
||||
|
||||
|
||||
func _leeren(node: Node) -> void:
|
||||
for kind in node.get_children():
|
||||
node.remove_child(kind)
|
||||
kind.queue_free()
|
||||
1
game/scenes/ui/inventar.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://diskvqdrx6qkd
|
||||
12
game/scenes/ui/inventar.tscn
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/ui/inventar.gd" id="1"]
|
||||
|
||||
[node name="Inventar" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1")
|
||||
|
|
@ -43,6 +43,8 @@ var _blockiert: Dictionary = {}
|
|||
var _dialog: PanelContainer
|
||||
var _dialog_text: Label
|
||||
var _dialog_name: Label
|
||||
var _inventar: Control
|
||||
var _inventar_ebene: CanvasLayer
|
||||
var _modern := false
|
||||
@export var gemalt := false
|
||||
## Gewählter Standard (docs/stand.md): Kacheln mit gemalten Figuren, gedämpfter
|
||||
|
|
@ -434,6 +436,16 @@ func _input(event: InputEvent) -> void:
|
|||
# so ist die Bewegung deterministisch und im Test nachvollziehbar.
|
||||
var taste: int = event.physical_keycode if event.physical_keycode != 0 \
|
||||
else event.keycode
|
||||
if taste == KEY_I:
|
||||
if _inventar != null:
|
||||
_inventar_schliessen()
|
||||
else:
|
||||
_inventar_oeffnen()
|
||||
return
|
||||
if _inventar != null:
|
||||
if taste == KEY_ESCAPE:
|
||||
_inventar_schliessen()
|
||||
return
|
||||
var richtung := Vector2i.ZERO
|
||||
match taste:
|
||||
KEY_UP, KEY_W, KEY_KP_8:
|
||||
|
|
@ -468,6 +480,24 @@ func _input(event: InputEvent) -> void:
|
|||
return
|
||||
|
||||
|
||||
func _inventar_oeffnen() -> void:
|
||||
if _inventar != null:
|
||||
return
|
||||
_inventar_ebene = CanvasLayer.new()
|
||||
_inventar_ebene.layer = 5
|
||||
add_child(_inventar_ebene)
|
||||
_inventar = load("res://scenes/ui/inventar.tscn").instantiate()
|
||||
_inventar_ebene.add_child(_inventar)
|
||||
_inventar.geschlossen.connect(_inventar_schliessen)
|
||||
|
||||
|
||||
func _inventar_schliessen() -> void:
|
||||
if _inventar_ebene != null:
|
||||
_inventar_ebene.queue_free()
|
||||
_inventar = null
|
||||
_inventar_ebene = null
|
||||
|
||||
|
||||
## Sprechen mit dem nächsten NSC (ein Feld Abstand, auch diagonal).
|
||||
func _sprechen() -> void:
|
||||
if _dialog.visible:
|
||||
|
|
@ -538,6 +568,15 @@ func _ui() -> void:
|
|||
menue.size = Vector2(48, 18) * UiTheme.SKALA
|
||||
wurzel.add_child(menue)
|
||||
|
||||
var inventar_knopf := Button.new()
|
||||
inventar_knopf.text = "INVENTAR"
|
||||
inventar_knopf.position = Vector2(62, 8) * UiTheme.SKALA
|
||||
inventar_knopf.size = Vector2(80, 18) * UiTheme.SKALA
|
||||
inventar_knopf.focus_mode = Control.FOCUS_NONE
|
||||
inventar_knopf.clip_text = true
|
||||
inventar_knopf.pressed.connect(_inventar_oeffnen)
|
||||
wurzel.add_child(inventar_knopf)
|
||||
|
||||
# Rückwand der Partyspalte: ohne sie steht das HUD auf der Stadtmauer und
|
||||
# wirkt aufgeklebt (Befund aus dem ersten Render).
|
||||
var breite: int = 44 * UiTheme.SKALA
|
||||
|
|
|
|||
|
|
@ -250,6 +250,24 @@ func _selbstpruefung() -> bool:
|
|||
ok = _pruefe("Figur: TP 9, RK 15 (Kette+Schild), Angriff +1",
|
||||
int(figur["hp"]["max"]) == 9 and Game.rk(figur) == 15
|
||||
and Game.angriffsbonus(figur) == 1) and ok
|
||||
ok = _pruefe("Startgepäck: Vorrat und Seil",
|
||||
Game.inventar_hat(figur, "vorrat") == 1
|
||||
and Game.inventar_hat(figur, "seil") == 1) and ok
|
||||
Game.inventar_hinzufuegen(figur, "leder")
|
||||
ok = _pruefe("Inventar: Leder anlegen, Kette zurück, RK 13",
|
||||
Game.ausruesten(figur, "leder")
|
||||
and str(figur["equipment"].get("armor", "")) == "leder"
|
||||
and Game.inventar_hat(figur, "kette") == 1
|
||||
and Game.rk(figur) == 13) and ok
|
||||
ok = _pruefe("Inventar: Rüstung ablegen, Leder zurück",
|
||||
Game.ablegen(figur, "armor")
|
||||
and not figur["equipment"].has("armor")
|
||||
and Game.inventar_hat(figur, "leder") == 1) and ok
|
||||
Game.inventar_hinzufuegen(figur, "dolch")
|
||||
ok = _pruefe("Inventar: Dolch statt Schwert, Schwert zurück",
|
||||
Game.ausruesten(figur, "dolch")
|
||||
and str(figur["equipment"].get("weapon", "")) == "dolch"
|
||||
and Game.inventar_hat(figur, "schwert") == 1) and ok
|
||||
|
||||
# Roster: 1..6, siebte Figur abgelehnt, Entfernen gibt den Platz frei.
|
||||
var sicherung: Array = Game.party.duplicate(true)
|
||||
|
|
|
|||
|
|
@ -96,6 +96,9 @@ func neue_figur(id: String, vorgabe: Dictionary) -> Dictionary:
|
|||
equipment[feld] = str(start[feld])
|
||||
if bool(start.get("shield", false)):
|
||||
equipment["shield"] = true
|
||||
var inventar := []
|
||||
for item_id in start.get("items", []):
|
||||
inventar.append({"id": str(item_id), "count": 1})
|
||||
return {
|
||||
"id": id, "name": vorgabe["name"],
|
||||
"race": vorgabe["race"], "class": vorgabe["class"],
|
||||
|
|
@ -105,7 +108,7 @@ func neue_figur(id: String, vorgabe: Dictionary) -> Dictionary:
|
|||
"hp": {"current": hp_max, "max": hp_max},
|
||||
"skills": _startfertigkeiten(klasse),
|
||||
"spells": {"known": [], "prepared": [], "slots": {}},
|
||||
"inventory": [], "equipment": equipment,
|
||||
"inventory": inventar, "equipment": equipment,
|
||||
"conditions": [],
|
||||
}
|
||||
|
||||
|
|
@ -138,6 +141,93 @@ func angriffsbonus(figur: Dictionary) -> int:
|
|||
return int(leiter[stufe - 1])
|
||||
return int(leiter[leiter.size() - 1]) if not leiter.is_empty() else 0
|
||||
|
||||
# ------------------------------------------------------------- Inventar ----
|
||||
# Ein Gegenstand ist `{"id": ..., "count": n}`; Ausrüstung referenziert ids.
|
||||
# Ausrüsten nimmt ein Stück aus dem Rucksack, Ablegen legt es zurück.
|
||||
|
||||
func inventar_hat(figur: Dictionary, id: String) -> int:
|
||||
for eintrag in figur.get("inventory", []):
|
||||
if typeof(eintrag) == TYPE_DICTIONARY:
|
||||
if str(eintrag.get("id", "")) == id:
|
||||
return int(eintrag.get("count", 0))
|
||||
elif str(eintrag) == id:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
func inventar_hinzufuegen(figur: Dictionary, id: String, anzahl: int = 1) -> void:
|
||||
if id.is_empty() or anzahl <= 0:
|
||||
return
|
||||
var inventar: Array = figur.get("inventory", [])
|
||||
for eintrag in inventar:
|
||||
if typeof(eintrag) == TYPE_DICTIONARY and str(eintrag.get("id", "")) == id:
|
||||
eintrag["count"] = int(eintrag.get("count", 0)) + anzahl
|
||||
return
|
||||
inventar.append({"id": id, "count": anzahl})
|
||||
figur["inventory"] = inventar
|
||||
|
||||
|
||||
func inventar_entfernen(figur: Dictionary, id: String, anzahl: int = 1) -> bool:
|
||||
var inventar: Array = figur.get("inventory", [])
|
||||
for i in inventar.size():
|
||||
var eintrag = inventar[i]
|
||||
var treffer := false
|
||||
var zahl := 1
|
||||
if typeof(eintrag) == TYPE_DICTIONARY:
|
||||
treffer = str(eintrag.get("id", "")) == id
|
||||
zahl = int(eintrag.get("count", 1))
|
||||
else:
|
||||
treffer = str(eintrag) == id
|
||||
if not treffer:
|
||||
continue
|
||||
if zahl <= anzahl:
|
||||
inventar.remove_at(i)
|
||||
else:
|
||||
eintrag["count"] = zahl - anzahl
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func ausruesten(figur: Dictionary, id: String) -> bool:
|
||||
var item: Dictionary = Content.entry("items", id)
|
||||
if item.is_empty():
|
||||
return false
|
||||
var typ := str(item.get("type", ""))
|
||||
if typ not in ["weapon", "armor", "shield"]:
|
||||
return false
|
||||
if inventar_hat(figur, id) <= 0:
|
||||
return false
|
||||
var equipment: Dictionary = figur.get("equipment", {})
|
||||
if typ == "shield":
|
||||
if bool(equipment.get("shield", false)):
|
||||
inventar_hinzufuegen(figur, "schild")
|
||||
equipment["shield"] = true
|
||||
else:
|
||||
var alt := str(equipment.get(typ, ""))
|
||||
if not alt.is_empty():
|
||||
inventar_hinzufuegen(figur, alt)
|
||||
equipment[typ] = id
|
||||
figur["equipment"] = equipment
|
||||
inventar_entfernen(figur, id)
|
||||
return true
|
||||
|
||||
|
||||
func ablegen(figur: Dictionary, slot: String) -> bool:
|
||||
var equipment: Dictionary = figur.get("equipment", {})
|
||||
if slot == "shield":
|
||||
if not bool(equipment.get("shield", false)):
|
||||
return false
|
||||
equipment["shield"] = false
|
||||
inventar_hinzufuegen(figur, "schild")
|
||||
else:
|
||||
var id := str(equipment.get(slot, ""))
|
||||
if id.is_empty():
|
||||
return false
|
||||
equipment.erase(slot)
|
||||
inventar_hinzufuegen(figur, id)
|
||||
figur["equipment"] = equipment
|
||||
return true
|
||||
|
||||
func notiz(text: String) -> void:
|
||||
log_lines.append(text)
|
||||
if log_lines.size() > 200:
|
||||
|
|
|
|||
40
game/tools/probe_inventar.gd
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
extends Node
|
||||
## Probe für das Inventar-Modal.
|
||||
##
|
||||
## godot --headless --path game res://tools/probe_inventar.tscn -- --check
|
||||
## godot --path game res://tools/schuss.tscn -- \
|
||||
## res://tools/probe_inventar.tscn art/prep/inventar/_inventar_1920x1080.png
|
||||
|
||||
const SZENE := preload("res://scenes/ui/inventar.tscn")
|
||||
|
||||
var fehler := 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Game.party_schnellstart()
|
||||
# Etwas Inhalt in den Rucksack, damit das Fenster nicht leer ist.
|
||||
var figur: Dictionary = Game.party[0]
|
||||
Game.inventar_hinzufuegen(figur, "leder")
|
||||
Game.inventar_hinzufuegen(figur, "dolch")
|
||||
|
||||
var ui: Control = SZENE.instantiate()
|
||||
add_child(ui)
|
||||
await get_tree().process_frame
|
||||
|
||||
ok("Modal baut", ui.get_child_count() > 0)
|
||||
ok("Partyspalte hat Figuren", Game.party.size() == 4)
|
||||
ok("Ausrüsten aus dem Rucksack", Game.ausruesten(figur, "leder")
|
||||
and str(figur["equipment"].get("armor", "")) == "leder")
|
||||
ok("Kette liegt im Rucksack", Game.inventar_hat(figur, "kette") == 1)
|
||||
ok("Ablegen legt zurück", Game.ablegen(figur, "armor")
|
||||
and Game.inventar_hat(figur, "leder") == 1)
|
||||
|
||||
print("\nProbe: %s" % ("bestanden" if fehler == 0 else "FEHLGESCHLAGEN"))
|
||||
if OS.get_cmdline_user_args().has("--check"):
|
||||
get_tree().quit(0 if fehler == 0 else 1)
|
||||
|
||||
|
||||
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_inventar.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b7j5mdjruaii5
|
||||
6
game/tools/probe_inventar.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://tools/probe_inventar.gd" id="1"]
|
||||
|
||||
[node name="ProbeInventar" type="Node"]
|
||||
script = ExtResource("1")
|
||||