From aa8ce95e54c086ca7c06db2f68c453c37c7a4320 Mon Sep 17 00:00:00 2001 From: "s0wlz (Matthias Puchstein)" Date: Thu, 16 Apr 2026 00:21:58 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20dm=5Fview=20=E2=80=94=20add=20roll=20lo?= =?UTF-8?q?g=20+=20DC=20display=20for=20incoming=20player=20rolls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruf-der-pilze/scenes/dm_view.tscn | 22 ++++++++++++++++++++++ ruf-der-pilze/scripts/dm_view.gd | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/ruf-der-pilze/scenes/dm_view.tscn b/ruf-der-pilze/scenes/dm_view.tscn index 26f9816..36a314d 100644 --- a/ruf-der-pilze/scenes/dm_view.tscn +++ b/ruf-der-pilze/scenes/dm_view.tscn @@ -56,6 +56,28 @@ size_flags_vertical = 3 [node name="PlayerList" type="VBoxContainer" parent="RootLayout/TopSection/SidePanel/OverlayScroll"] +[node name="SepDice" type="HSeparator" parent="RootLayout/TopSection/SidePanel"] + +[node name="LblDice" type="Label" parent="RootLayout/TopSection/SidePanel"] +text = "Würfelwürfe" + +[node name="DCRow" type="HBoxContainer" parent="RootLayout/TopSection/SidePanel"] + +[node name="LblDC" type="Label" parent="RootLayout/TopSection/SidePanel/DCRow"] +text = "DC:" + +[node name="DCSpinBox" type="SpinBox" parent="RootLayout/TopSection/SidePanel/DCRow"] +min_value = 1.0 +max_value = 30.0 +value = 12.0 + +[node name="RollLogScroll" type="ScrollContainer" parent="RootLayout/TopSection/SidePanel"] +size_flags_vertical = 3 + +[node name="RollLog" type="RichTextLabel" parent="RootLayout/TopSection/SidePanel/RollLogScroll"] +bbcode_enabled = true +fit_content = true + [node name="HSeparator" type="HSeparator" parent="RootLayout"] [node name="PlayerCamsRow" type="HBoxContainer" parent="RootLayout"] diff --git a/ruf-der-pilze/scripts/dm_view.gd b/ruf-der-pilze/scripts/dm_view.gd index 9504fcf..ace9feb 100644 --- a/ruf-der-pilze/scripts/dm_view.gd +++ b/ruf-der-pilze/scripts/dm_view.gd @@ -4,6 +4,8 @@ const TAVERN_SCENE := "res://scenes/tavern.tscn" const FLOOR_THRESHOLD := 3.5 # y < threshold → EG, y >= threshold → OG const OVERLAY_CYCLE := ["default", "spore_active"] +var _dm_roll_log: RichTextLabel + var _eg_markers: Node3D var _og_markers: Node3D var _eg_markers_by_id: Dictionary = {} # peer_id → MeshInstance3D @@ -16,6 +18,7 @@ func _ready() -> void: _load_tavern_into_viewports() _setup_player_cams() _setup_overlay_panel() + _setup_dc_section() func _load_tavern_into_viewports() -> void: @@ -196,6 +199,24 @@ func _peer_color(peer_id: int) -> Color: return colors[peer_id % colors.size()] +func _setup_dc_section() -> void: + _dm_roll_log = $RootLayout/TopSection/SidePanel/RollLogScroll/RollLog as RichTextLabel + NetworkManager.roll_received.connect(_on_roll_received_dm) + + +func _on_roll_received_dm(roller_peer_id: int, player_name: String, d20_result: int, modifier: int, total: int) -> void: + var dc: int = ($RootLayout/TopSection/SidePanel/DCRow/DCSpinBox as SpinBox).value as int + var mod_str := " %+d" % modifier if modifier != 0 else "" + var success := total >= dc + var result_str := "[color=green]Erfolg[/color]" if success else "[color=red]Fehlschlag[/color]" + var line := "[b]%s[/b]: %d%s = [b]%d[/b] vs DC%d → %s" % [player_name, d20_result, mod_str, total, dc, result_str] + if d20_result == 20: + line += " [color=gold]★[/color]" + elif d20_result == 1: + line += " [color=red]☠[/color]" + _dm_roll_log.append_text(line + "\n") + + func _update_player_cams() -> void: for peer_id in _player_cam_cams.keys(): if not GameState.player_positions.has(peer_id):