Fix score selection issues and update score item options.

Changed large straight initialization to correct function, added missing score items, and used correct methods for score selections. Adjusted configuration in the scene file to align with the new item options setup.
This commit is contained in:
Yadciel 2024-08-19 12:48:22 +02:00
parent 930253e013
commit b0f6f5adfa
4 changed files with 62 additions and 45 deletions

View File

@ -37,11 +37,12 @@ func _ready():
add_items(four_of_a_kind) add_items(four_of_a_kind)
full_house = get_node("ScrollContainer/VBoxContainer/Full_House/HBoxContainer/OptionButton") full_house = get_node("ScrollContainer/VBoxContainer/Full_House/HBoxContainer/OptionButton")
full_house.add_item("") full_house.add_item("")
full_house.add_item("-")
full_house.add_item("25") full_house.add_item("25")
small_straight = get_node("ScrollContainer/VBoxContainer/Small_Straight/HBoxContainer/OptionButton") small_straight = get_node("ScrollContainer/VBoxContainer/Small_Straight/HBoxContainer/OptionButton")
add_items_to_small_straight(small_straight) add_items_to_small_straight(small_straight)
large_straight = get_node("ScrollContainer/VBoxContainer/Large_Straight/HBoxContainer/OptionButton") large_straight = get_node("ScrollContainer/VBoxContainer/Large_Straight/HBoxContainer/OptionButton")
add_items_to_small_straight(large_straight) add_items_to_large_straight(large_straight)
yahtzee = get_node("ScrollContainer/VBoxContainer/yahtzee/HBoxContainer/ButtonYahtzee") yahtzee = get_node("ScrollContainer/VBoxContainer/yahtzee/HBoxContainer/ButtonYahtzee")
bonus = get_node("ScrollContainer/VBoxContainer/Bonus/HBoxContainer/LabelScore") bonus = get_node("ScrollContainer/VBoxContainer/Bonus/HBoxContainer/LabelScore")
chance = get_node("ScrollContainer/VBoxContainer/chance/HBoxContainer/OptionButton") chance = get_node("ScrollContainer/VBoxContainer/chance/HBoxContainer/OptionButton")
@ -113,7 +114,7 @@ func load_stats():
small_straight.select(players[currentPlayer].small_straight) small_straight.select(players[currentPlayer].small_straight)
large_straight.select(players[currentPlayer].large_straight) large_straight.select(players[currentPlayer].large_straight)
yahtzee.text = str(players[currentPlayer].yahtzee) yahtzee.text = str(players[currentPlayer].yahtzee)
chance.set_item_text(0, str(players[currentPlayer].chance)) chance.select(players[currentPlayer].chance)
bonus.text = str(players[currentPlayer].bonus) bonus.text = str(players[currentPlayer].bonus)
pass pass
@ -132,6 +133,7 @@ func save():
players[currentPlayer].large_straight = int(large_straight.get_selected_id()) players[currentPlayer].large_straight = int(large_straight.get_selected_id())
players[currentPlayer].yahtzee = int(yahtzee.text) players[currentPlayer].yahtzee = int(yahtzee.text)
players[currentPlayer].bonus = int(bonus.text) players[currentPlayer].bonus = int(bonus.text)
players[currentPlayer].chance = int(chance.get_selected_id())
players[currentPlayer].score = players[currentPlayer].one + players[currentPlayer].two + players[currentPlayer].three + players[currentPlayer].four + players[currentPlayer].five + players[currentPlayer].six + players[currentPlayer].three_of_a_kind + players[currentPlayer].four_of_a_kind + players[currentPlayer].full_house + players[currentPlayer].small_straight + players[currentPlayer].large_straight + players[currentPlayer].yahtzee + players[currentPlayer].chance + players[currentPlayer].bonus players[currentPlayer].score = players[currentPlayer].one + players[currentPlayer].two + players[currentPlayer].three + players[currentPlayer].four + players[currentPlayer].five + players[currentPlayer].six + players[currentPlayer].three_of_a_kind + players[currentPlayer].four_of_a_kind + players[currentPlayer].full_house + players[currentPlayer].small_straight + players[currentPlayer].large_straight + players[currentPlayer].yahtzee + players[currentPlayer].chance + players[currentPlayer].bonus
pass pass
@ -147,15 +149,18 @@ func _on_button_left_pressed():
func add_items_to_small_straight(oButton: OptionButton): func add_items_to_small_straight(oButton: OptionButton):
oButton.add_item("") oButton.add_item("")
oButton.add_item("-")
oButton.add_item("30") oButton.add_item("30")
pass # Replace with function body. pass # Replace with function body.
func add_items_to_large_straight(oButton: OptionButton): func add_items_to_large_straight(oButton: OptionButton):
oButton.add_item("") oButton.add_item("")
oButton.add_item("-")
oButton.add_item("40") oButton.add_item("40")
pass # Replace with function body. pass # Replace with function body.
func add_items(oButton: OptionButton): func add_items(oButton: OptionButton):
oButton.add_item("") oButton.add_item("")
oButton.add_item("-")
oButton.add_item("0") oButton.add_item("0")
oButton.add_item("1") oButton.add_item("1")
oButton.add_item("2") oButton.add_item("2")

View File

@ -111,20 +111,22 @@ layout_mode = 2
theme_override_font_sizes/font_size = 50 theme_override_font_sizes/font_size = 50
alignment = 1 alignment = 1
clip_text = true clip_text = true
item_count = 6 item_count = 7
allow_reselect = true allow_reselect = true
popup/item_0/text = "-" popup/item_0/text = ""
popup/item_0/id = 0 popup/item_0/id = 0
popup/item_1/text = "1" popup/item_1/text = "-"
popup/item_1/id = 1 popup/item_1/id = 1
popup/item_2/text = "2" popup/item_2/text = "1"
popup/item_2/id = 2 popup/item_2/id = 2
popup/item_3/text = "3" popup/item_3/text = "2"
popup/item_3/id = 3 popup/item_3/id = 3
popup/item_4/text = "4" popup/item_4/text = "3"
popup/item_4/id = 4 popup/item_4/id = 4
popup/item_5/text = "5" popup/item_5/text = "4"
popup/item_5/id = 5 popup/item_5/id = 5
popup/item_6/text = "5"
popup/item_6/id = 6
[node name="Two" type="Panel" parent="ScrollContainer/VBoxContainer"] [node name="Two" type="Panel" parent="ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(1080, 150) custom_minimum_size = Vector2(1080, 150)
@ -158,20 +160,22 @@ layout_mode = 2
theme_override_font_sizes/font_size = 50 theme_override_font_sizes/font_size = 50
alignment = 1 alignment = 1
clip_text = true clip_text = true
item_count = 6 item_count = 7
allow_reselect = true allow_reselect = true
popup/item_0/text = "-" popup/item_0/text = ""
popup/item_0/id = 0 popup/item_0/id = 0
popup/item_1/text = "2" popup/item_1/text = "-"
popup/item_1/id = 1 popup/item_1/id = 1
popup/item_2/text = "4" popup/item_2/text = "2"
popup/item_2/id = 2 popup/item_2/id = 2
popup/item_3/text = "6" popup/item_3/text = "4"
popup/item_3/id = 3 popup/item_3/id = 3
popup/item_4/text = "8" popup/item_4/text = "6"
popup/item_4/id = 4 popup/item_4/id = 4
popup/item_5/text = "10" popup/item_5/text = "8"
popup/item_5/id = 5 popup/item_5/id = 5
popup/item_6/text = "10"
popup/item_6/id = 6
[node name="Three" type="Panel" parent="ScrollContainer/VBoxContainer"] [node name="Three" type="Panel" parent="ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(1080, 150) custom_minimum_size = Vector2(1080, 150)
@ -205,20 +209,22 @@ layout_mode = 2
theme_override_font_sizes/font_size = 50 theme_override_font_sizes/font_size = 50
alignment = 1 alignment = 1
clip_text = true clip_text = true
item_count = 6 item_count = 7
allow_reselect = true allow_reselect = true
popup/item_0/text = "-" popup/item_0/text = ""
popup/item_0/id = 0 popup/item_0/id = 0
popup/item_1/text = "3" popup/item_1/text = "-"
popup/item_1/id = 1 popup/item_1/id = 1
popup/item_2/text = "6" popup/item_2/text = "3"
popup/item_2/id = 2 popup/item_2/id = 2
popup/item_3/text = "9" popup/item_3/text = "6"
popup/item_3/id = 3 popup/item_3/id = 3
popup/item_4/text = "12" popup/item_4/text = "9"
popup/item_4/id = 4 popup/item_4/id = 4
popup/item_5/text = "15" popup/item_5/text = "12"
popup/item_5/id = 5 popup/item_5/id = 5
popup/item_6/text = "15"
popup/item_6/id = 6
[node name="Four" type="Panel" parent="ScrollContainer/VBoxContainer"] [node name="Four" type="Panel" parent="ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(1080, 150) custom_minimum_size = Vector2(1080, 150)
@ -252,20 +258,22 @@ layout_mode = 2
theme_override_font_sizes/font_size = 50 theme_override_font_sizes/font_size = 50
alignment = 1 alignment = 1
clip_text = true clip_text = true
item_count = 6 item_count = 7
allow_reselect = true allow_reselect = true
popup/item_0/text = "-" popup/item_0/text = ""
popup/item_0/id = 0 popup/item_0/id = 0
popup/item_1/text = "4" popup/item_1/text = "-"
popup/item_1/id = 1 popup/item_1/id = 1
popup/item_2/text = "8" popup/item_2/text = "4"
popup/item_2/id = 2 popup/item_2/id = 2
popup/item_3/text = "12" popup/item_3/text = "8"
popup/item_3/id = 3 popup/item_3/id = 2
popup/item_4/text = "16" popup/item_4/text = "12"
popup/item_4/id = 4 popup/item_4/id = 4
popup/item_5/text = "20" popup/item_5/text = "16"
popup/item_5/id = 5 popup/item_5/id = 5
popup/item_6/text = "20"
popup/item_6/id = 6
[node name="Five" type="Panel" parent="ScrollContainer/VBoxContainer"] [node name="Five" type="Panel" parent="ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(1080, 150) custom_minimum_size = Vector2(1080, 150)
@ -299,20 +307,22 @@ layout_mode = 2
theme_override_font_sizes/font_size = 50 theme_override_font_sizes/font_size = 50
alignment = 1 alignment = 1
clip_text = true clip_text = true
item_count = 6 item_count = 7
allow_reselect = true allow_reselect = true
popup/item_0/text = "-" popup/item_0/text = ""
popup/item_0/id = 0 popup/item_0/id = 0
popup/item_1/text = "5" popup/item_1/text = "-"
popup/item_1/id = 1 popup/item_1/id = 1
popup/item_2/text = "10" popup/item_2/text = "5"
popup/item_2/id = 2 popup/item_2/id = 2
popup/item_3/text = "15" popup/item_3/text = "10"
popup/item_3/id = 3 popup/item_3/id = 3
popup/item_4/text = "20" popup/item_4/text = "15"
popup/item_4/id = 4 popup/item_4/id = 4
popup/item_5/text = "25" popup/item_5/text = "20"
popup/item_5/id = 5 popup/item_5/id = 5
popup/item_6/text = "25"
popup/item_6/id = 6
[node name="Six" type="Panel" parent="ScrollContainer/VBoxContainer"] [node name="Six" type="Panel" parent="ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(1080, 150) custom_minimum_size = Vector2(1080, 150)
@ -347,20 +357,22 @@ layout_mode = 2
theme_override_font_sizes/font_size = 50 theme_override_font_sizes/font_size = 50
alignment = 1 alignment = 1
clip_text = true clip_text = true
item_count = 6 item_count = 7
allow_reselect = true allow_reselect = true
popup/item_0/text = "-" popup/item_0/text = ""
popup/item_0/id = 0 popup/item_0/id = 0
popup/item_1/text = "6" popup/item_1/text = "-"
popup/item_1/id = 1 popup/item_1/id = 1
popup/item_2/text = "12" popup/item_2/text = "6"
popup/item_2/id = 2 popup/item_2/id = 2
popup/item_3/text = "18" popup/item_3/text = "12"
popup/item_3/id = 3 popup/item_3/id = 3
popup/item_4/text = "24" popup/item_4/text = "18"
popup/item_4/id = 4 popup/item_4/id = 4
popup/item_5/text = "30" popup/item_5/text = "24"
popup/item_5/id = 5 popup/item_5/id = 5
popup/item_6/text = "30"
popup/item_6/id = 6
[node name="Bonus" type="Panel" parent="ScrollContainer/VBoxContainer"] [node name="Bonus" type="Panel" parent="ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 150) custom_minimum_size = Vector2(0, 150)

Binary file not shown.

Binary file not shown.