feat: dm_view — add roll log + DC display for incoming player rolls

This commit is contained in:
2026-04-16 00:21:58 +02:00
parent c9c8fc9a1d
commit aa8ce95e54
2 changed files with 43 additions and 0 deletions

View File

@@ -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"]

View File

@@ -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):