func: Added Trump Buttons

This commit is contained in:
Aspergerli
2026-03-12 11:53:32 +01:00
parent ee7ba59ed2
commit 637eaaca30
12 changed files with 139 additions and 1390 deletions

View File

@@ -72,11 +72,10 @@ func sort_hand():
var sort_cards = _held_cards.duplicate()
sort_cards.sort_custom(compare_cards)
#print("sorted")
for card in sort_cards:
print(card.card_info["value"])
var n = 0
for card in sort_cards:
#print(card.card_info["value"])
var arr_card : Array
arr_card.append(card)
move_cards((arr_card), n)
@@ -86,9 +85,9 @@ func sort_hand():
func compare_cards(a,b):
var val_1 = int(a.card_info["value"])
var val_2 = int(b.card_info["value"])
var su_1 = a.card_info["suit"]
var su_2 = b.card_info["suit"]
match su_1:
var suit_1 = a.card_info["suit"]
var suit_2 = b.card_info["suit"]
match suit_1:
"Diampnd":
val_1 -= 10
"Spade":
@@ -97,7 +96,7 @@ func compare_cards(a,b):
val_1 -= 30
#print(val_1,su_1)
match su_2:
match suit_2:
"Diamond":
val_2 -= 10
"Spade":

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2016-2023 The Godot Engine community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +0,0 @@
[configuration]
entry_symbol = "git_plugin_init"
compatibility_minimum = "4.2.0"
[libraries]
linux.editor.x86_64 = "linux/libgit_plugin.linux.editor.x86_64.so"
macos.editor = "macos/libgit_plugin.macos.editor.universal.dylib"
windows.editor.x86_64 = "windows/libgit_plugin.windows.editor.x86_64.dll"

View File

@@ -1 +0,0 @@
uid://boeseuvf6w4xf

View File

@@ -11,6 +11,11 @@
[ext_resource type="Texture2D" uid="uid://besq7oa4a37mb" path="res://icon_red_background.webp" id="9_ggwjq"]
[ext_resource type="Curve" uid="uid://ddxsxuabgpk7w" path="res://resources/Hand_Curve_invert.tres" id="10_kdjyk"]
[ext_resource type="Curve" uid="uid://y6okl4wukojm" path="res://resources/Hand_Curve_Vert_invert.tres" id="10_unpya"]
[ext_resource type="Texture2D" uid="uid://dcgcbtbdihe7g" path="res://cards/images/cardHeartsJ.png" id="12_gwibp"]
[ext_resource type="Script" uid="uid://mvdvqcro0w4w" path="res://scripts/buttons_trump_select.gd" id="12_vsw8n"]
[ext_resource type="Texture2D" uid="uid://7qs010wi55mj" path="res://cards/images/cardSpadesJ.png" id="13_vsw8n"]
[ext_resource type="Texture2D" uid="uid://dvqxm048cpqso" path="res://cards/images/cardDiamondsJ.png" id="14_el68r"]
[ext_resource type="Texture2D" uid="uid://d0fi2w3eqskmy" path="res://cards/images/cardClubsJ.png" id="15_ir868"]
[sub_resource type="CanvasTexture" id="CanvasTexture_ggwjq"]
diffuse_texture = ExtResource("8_waqni")
@@ -21,6 +26,11 @@ diffuse_texture = ExtResource("9_ggwjq")
[sub_resource type="CanvasTexture" id="CanvasTexture_kdjyk"]
diffuse_texture = ExtResource("8_waqni")
[sub_resource type="LabelSettings" id="LabelSettings_gwibp"]
font_size = 48
outline_size = 16
outline_color = Color(0, 0, 0, 1)
[node name="Schematic" type="Node2D" unique_id=590430084]
script = ExtResource("1_1j52r")
metadata/_edit_vertical_guides_ = [960.0, 480.0, 1440.0, 790.0, 980.0]
@@ -29,8 +39,6 @@ metadata/_edit_horizontal_guides_ = [540.0, 560.0, 330.0, 880.0, -10.0]
[node name="CardManager" type="Control" parent="." unique_id=697562693]
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("2_waqni")
card_factory_scene = ExtResource("3_ggwjq")
metadata/_custom_type_script = "uid://clqgq1n7v0ar"
@@ -47,6 +55,7 @@ enable_drop_zone = false
metadata/_custom_type_script = "uid://6ams8uvg43gu"
[node name="Player1Hand" type="Control" parent="CardManager" unique_id=643995694]
layout_mode = 1
anchors_preset = 0
offset_left = 480.0
offset_top = 880.0
@@ -81,6 +90,7 @@ sensor_texture = SubResource("CanvasTexture_unpya")
metadata/_custom_type_script = "uid://6ams8uvg43gu"
[node name="Player2Hand" type="Control" parent="CardManager" unique_id=1455320999]
layout_mode = 1
anchors_preset = 0
offset_left = 1440.0
offset_top = 880.0
@@ -159,3 +169,59 @@ script = ExtResource("7_rwigh")
sensor_texture = ExtResource("8_waqni")
sensor_visibility = true
metadata/_custom_type_script = "uid://6ams8uvg43gu"
[node name="ButtonsTrumpSelect" type="Control" parent="." unique_id=1454103720]
visible = false
layout_mode = 3
anchors_preset = 0
script = ExtResource("12_vsw8n")
[node name="Label" type="Label" parent="ButtonsTrumpSelect" unique_id=1953384356]
layout_mode = 0
offset_left = 791.0
offset_top = 268.0
offset_right = 1129.0
offset_bottom = 335.0
text = "Choose Trump"
label_settings = SubResource("LabelSettings_gwibp")
horizontal_alignment = 1
vertical_alignment = 1
[node name="GridContainer" type="GridContainer" parent="ButtonsTrumpSelect" unique_id=412936036]
z_index = 10
layout_mode = 0
offset_left = 810.0
offset_top = 340.0
offset_right = 1110.0
offset_bottom = 740.0
columns = 2
metadata/_edit_group_ = true
[node name="ButtonHeart" type="Button" parent="ButtonsTrumpSelect/GridContainer" unique_id=1595325767]
layout_mode = 2
icon = ExtResource("12_gwibp")
[node name="ButtonSpade" type="Button" parent="ButtonsTrumpSelect/GridContainer" unique_id=1452476265]
layout_mode = 2
icon = ExtResource("13_vsw8n")
[node name="ButtonDiamond" type="Button" parent="ButtonsTrumpSelect/GridContainer" unique_id=838232450]
layout_mode = 2
icon = ExtResource("14_el68r")
[node name="ButtonClub" type="Button" parent="ButtonsTrumpSelect/GridContainer" unique_id=677142745]
layout_mode = 2
icon = ExtResource("15_ir868")
[connection signal="mouse_entered" from="ButtonsTrumpSelect/GridContainer/ButtonHeart" to="ButtonsTrumpSelect" method="_on_button_heart_mouse_entered"]
[connection signal="mouse_exited" from="ButtonsTrumpSelect/GridContainer/ButtonHeart" to="ButtonsTrumpSelect" method="_on_button_heart_mouse_exited"]
[connection signal="pressed" from="ButtonsTrumpSelect/GridContainer/ButtonHeart" to="ButtonsTrumpSelect" method="_on_button_heart_pressed"]
[connection signal="mouse_entered" from="ButtonsTrumpSelect/GridContainer/ButtonSpade" to="ButtonsTrumpSelect" method="_on_button_spade_mouse_entered"]
[connection signal="mouse_exited" from="ButtonsTrumpSelect/GridContainer/ButtonSpade" to="ButtonsTrumpSelect" method="_on_button_spade_mouse_exited"]
[connection signal="pressed" from="ButtonsTrumpSelect/GridContainer/ButtonSpade" to="ButtonsTrumpSelect" method="_on_button_spade_pressed"]
[connection signal="mouse_entered" from="ButtonsTrumpSelect/GridContainer/ButtonDiamond" to="ButtonsTrumpSelect" method="_on_button_diamond_mouse_entered"]
[connection signal="mouse_exited" from="ButtonsTrumpSelect/GridContainer/ButtonDiamond" to="ButtonsTrumpSelect" method="_on_button_diamond_mouse_exited"]
[connection signal="pressed" from="ButtonsTrumpSelect/GridContainer/ButtonDiamond" to="ButtonsTrumpSelect" method="_on_button_diamond_pressed"]
[connection signal="mouse_entered" from="ButtonsTrumpSelect/GridContainer/ButtonClub" to="ButtonsTrumpSelect" method="_on_button_club_mouse_entered"]
[connection signal="mouse_exited" from="ButtonsTrumpSelect/GridContainer/ButtonClub" to="ButtonsTrumpSelect" method="_on_button_club_mouse_exited"]
[connection signal="pressed" from="ButtonsTrumpSelect/GridContainer/ButtonClub" to="ButtonsTrumpSelect" method="_on_button_club_pressed"]

View File

@@ -0,0 +1,45 @@
extends Control
@onready var label = $Label
signal trump
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func _on_button_heart_mouse_entered() -> void:
label.text = "Hearts"
func _on_button_heart_mouse_exited() -> void:
label.text = "Choose Trump"
func _on_button_spade_mouse_entered() -> void:
label.text = "Spades"
func _on_button_spade_mouse_exited() -> void:
label.text = "Choose Trump"
func _on_button_diamond_mouse_entered() -> void:
label.text = "Diamonds"
func _on_button_diamond_mouse_exited() -> void:
label.text = "Choose Trump"
func _on_button_club_mouse_entered() -> void:
label.text = "Clubs"
func _on_button_club_mouse_exited() -> void:
label.text = "Choose Trump"
func _on_button_heart_pressed() -> void:
trump.emit("Heart")
self.visible = false
func _on_button_spade_pressed() -> void:
trump.emit("Spade")
self.visible = false
func _on_button_diamond_pressed() -> void:
trump.emit("Diamond")
self.visible = false
func _on_button_club_pressed() -> void:
trump.emit("Club")
self.visible = false

View File

@@ -0,0 +1 @@
uid://mvdvqcro0w4w

View File

@@ -6,33 +6,49 @@ extends Node2D
@onready var player_2_hand = $CardManager/Player2Hand
@onready var player_3_hand = $CardManager/Player3Hand
@onready var player_4_hand = $CardManager/Player4Hand
@onready var trumpbuttons = $ButtonsTrumpSelect
var trump : String
signal dealt
func _ready():
trumpbuttons.trump.connect(define_trump.bind())
setup_game()
func setup_game():
# Create a deck of cards
create_standard_deck()
deck._held_cards.shuffle()
# Deal initial hand
const DEAL_PAUSE = 0.45
var deal_r: int =1
while true:
deal_cards_to_hand(3, player_1_hand)
await get_tree().create_timer(0.5).timeout
await get_tree().create_timer(DEAL_PAUSE).timeout
deal_cards_to_hand(3, player_2_hand)
await get_tree().create_timer(0.5).timeout
await get_tree().create_timer(DEAL_PAUSE).timeout
deal_cards_to_hand(3, player_3_hand)
await get_tree().create_timer(0.5).timeout
await get_tree().create_timer(DEAL_PAUSE).timeout
deal_cards_to_hand(3, player_4_hand)
if deal_r == 3:
dealt.emit()
break
else:
await get_tree().create_timer(0.5).timeout
await get_tree().create_timer(DEAL_PAUSE).timeout
deal_r += 1
await get_tree().create_timer(DEAL_PAUSE).timeout
trumpbuttons.visible = true
func define_trump(suit : String):
print(suit)
func create_standard_deck():
var suits = ["Club", "Diamond", "Heart", "Spade"]