From 1567531001e980fcd13c01a0c6f262931bb4f886 Mon Sep 17 00:00:00 2001 From: Alan <alanjfogel@gmail.com> Date: Fri, 7 Feb 2025 17:33:44 -0600 Subject: [PATCH] Fixed representation of purchased pieces/upgrades in game.gd --- scripts/game.gd | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/game.gd b/scripts/game.gd index 45ca4bf..e5c882d 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -522,16 +522,20 @@ func _on_purchase_attempted(item_data: Dictionary, shop_item: Node): shop_item.get_node("Overlay").visible = true shop_item.get_node("MarginContainer/VBoxContainer/BuyButton").disabled = true - # Track purchased items - if item_data in shop.shop_items["pieces"]: + # Creates an array of piece / upgrade names. + var piece_names = shop.shop_items["pieces"].map(func(item): return item["name"]) + var upgrade_names = shop.shop_items["upgrades"].map(func(item): return item["name"]) + + # checks if the purchased item’s name exists in the list of pieces or upgrades. + if item_data["name"] in piece_names: + print("Purchased piece: ", item_data["name"]) purchased_pieces.append(item_data) - elif item_data in shop.shop_items["upgrades"]: + elif item_data["name"] in upgrade_names: + print("Purchased upgrade: ", item_data["name"]) purchased_upgrades.append(item_data) # Update UI and print debug info update_gold_display() - print("Purchased: ", item_data["name"]) - print("Remaining gold: ", player_gold) else: # TODO: Play sound / animation for not enough gold print("Not enough gold!") @@ -550,6 +554,8 @@ func _on_next_round_requested(): piece_container.visible = true # Show the board shadow_container.visible = true tile_container.visible = true + print("Player items in purchased_pieces: ", purchased_pieces) + print("Player upgrades in purchased_upgrades: ", purchased_upgrades) func set_gold_display_position(): # Set anchors to a percentage of the parent container's size -- GitLab