added cardstack to place played cards at the centre of the table

This commit is contained in:
2025-07-16 11:50:33 +02:00
parent cc7afb5477
commit f39c9e46d9
5 changed files with 31 additions and 9 deletions
+18
View File
@@ -0,0 +1,18 @@
class_name CardStack
extends Node3D
var _card_height: float = 0.06
func add_card(card: PlayingCard) -> void:
var height = self.get_child_count() * _card_height
self.add_child(card)
card.translate(Vector3(0, height, 0))
func add_card_by_id(card_id: int) -> void:
var playing_card: PlayingCard = PlayingCard.new()
playing_card.setup_card_details(card_id)
add_card(playing_card)
func purge_cards() -> void:
while get_child_count() > 0:
remove_child(get_children()[get_child_count() - 1])
+1
View File
@@ -0,0 +1 @@
uid://c5bk4gjeyh7vy
+4 -4
View File
@@ -5,7 +5,7 @@ var hand_associations: Dictionary[String, PlayerHand]
@export var web_client: WebClientTCP
@export var trump_container: Node3D
@export var card_stack: CardStack
# In gameplay order
#var hand_associations: Dictionary[int, PlayerHandAssociation]
@@ -105,12 +105,12 @@ func _on_web_client_tcp_received_play_winner_request() -> void:
return
func _on_web_client_tcp_trump_received(trump_id: int) -> void:
if trump_container.get_child_count() > 0:
trump_container.remove_child(trump_container.get_child(0))
_trump_id = trump_id
var trump_card: PlayingCard = card_scene.instantiate()
trump_card.setup_card_details(_trump_id)
trump_container.add_child(trump_card)
#trump_container.add_child(trump_card)
card_stack.purge_cards()
card_stack.add_card(trump_card)
func _on_web_client_tcp_new_round_started() -> void:
# prepare a fresh BetResults bunch for the new round! the clients are hungry.
+6 -4
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=3 uid="uid://gqrdpjslr4np"]
[gd_scene load_steps=11 format=3 uid="uid://gqrdpjslr4np"]
[ext_resource type="Script" uid="uid://p5gvnyhjqe6o" path="res://components/web_client_tcp.gd" id="1_feb5d"]
[ext_resource type="Script" uid="uid://c0cqkatyo4uj1" path="res://components/client_interface.gd" id="2_e2o6t"]
@@ -7,6 +7,7 @@
[ext_resource type="PackedScene" uid="uid://jlovgr2iojrg" path="res://elements/player_hand.tscn" id="4_fc0e3"]
[ext_resource type="PackedScene" uid="uid://b55xpcxk7g5ph" path="res://cards/playing_card.tscn" id="6_eow3j"]
[ext_resource type="PackedScene" uid="uid://dj1wye7o27vil" path="res://assets/table.glb" id="7_eow3j"]
[ext_resource type="Script" uid="uid://c5bk4gjeyh7vy" path="res://card_stack.gd" id="8_j5wjh"]
[sub_resource type="SystemFont" id="SystemFont_80nbo"]
font_names = PackedStringArray("IBM Plex Mono")
@@ -228,10 +229,10 @@ offset_bottom = 373.0
grow_horizontal = 2
text = "YOU WON!!!!!!"
[node name="EnvironmentManager" type="Node3D" parent="." node_paths=PackedStringArray("web_client", "trump_container", "own_player_hand", "hand_markers_3", "hand_markers_4", "hand_markers_5", "hand_markers_6")]
[node name="EnvironmentManager" type="Node3D" parent="." node_paths=PackedStringArray("web_client", "card_stack", "own_player_hand", "hand_markers_3", "hand_markers_4", "hand_markers_5", "hand_markers_6")]
script = ExtResource("4_7jktm")
web_client = NodePath("../WebClientTCP")
trump_container = NodePath("TrumpPosition")
card_stack = NodePath("CardStack")
own_player_hand = NodePath("PlayerHand0")
hand_markers_3 = [NodePath("HandMarker1"), NodePath("HandMarker2")]
hand_markers_4 = [NodePath("HandMarker1"), NodePath("HandMarker3"), NodePath("HandMarker2")]
@@ -272,8 +273,9 @@ transform = Transform3D(-0.5, 0.836516, 0.224144, 0, 0.258819, -0.965925, -0.866
[node name="Table" parent="EnvironmentManager" instance=ExtResource("7_eow3j")]
transform = Transform3D(0.7, 0, 0, 0, 0.7, 0, 0, 0, 0.7, 0, 0, 0.704226)
[node name="TrumpPosition" type="Marker3D" parent="EnvironmentManager"]
[node name="CardStack" type="Marker3D" parent="EnvironmentManager"]
transform = Transform3D(0.957037, -0.289967, -1.26749e-08, 1.48302e-15, -4.37114e-08, 1, -0.289967, -0.957036, -4.18334e-08, -0.0775449, 0.372575, 0.973012)
script = ExtResource("8_j5wjh")
[connection signal="cards_received" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_cards_received"]
[connection signal="client_joined_lobby" from="WebClientTCP" to="HBoxContainer/ClientInterface" method="_on_web_client_tcp_client_joined_lobby"]
+2 -1
View File
@@ -35,7 +35,7 @@ func _start_next_round() -> void:
func _get_max_rounds(player_count: int) -> int:
match player_count:
3:
return 3
return 20
4:
return 15
5:
@@ -47,6 +47,7 @@ func _on_start_game_button_pressed() -> void:
_current_round = 1
_cards_left = _current_round
web_client.start_game()
start_game_button.hide()
func _on_create_lobby_button_pressed() -> void:
_set_host(true)