extends CanvasLayer

@export var Player : Node2D

@onready var MoneyCounter = $List/MoneyCounter

@onready var CurrentAddress = $List/CurrentAddress

@onready var ItemTextures = {"Shoes" : preload("res://sprites/runningshoes.png")}

@onready var ItemGrid = $Items

@export var ItemCounter : PackedScene

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	MoneyCounter.text = "$" + str(Player.Money)
	
	if Player.ActiveContract:
		CurrentAddress.text = Player.ActiveContract.get_address()
	else:
		CurrentAddress.text = "No Active Contract"
		
func add_item(name: String):
	if not ItemGrid.has_node(name):
		var newItem = ItemCounter.instantiate()
		newItem.name = name
		newItem.Count = 1
	
		ItemGrid.add_child(newItem)
		ItemGrid.get_node(name).ItemTexture.texture = ItemTextures[name]
	else:
		ItemGrid.get_node(name).Count += 1
	
