Skip to content
Snippets Groups Projects
Commit 15675310 authored by Alan's avatar Alan
Browse files

Fixed representation of purchased pieces/upgrades in game.gd

parent 79e6eab0
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment