extends Node2D

@export var bubble_scene: PackedScene
var total_score: int = 0
var current_investments = []
var bubble_names = {
	".COM": "Dotcom",
	"AI": "Artificial Intelligence",
	"HSG": "Housing",
	"AIR": "Air",
	"WTR": "Water",
	"NFT": "Non-Fungible Tokens",
	"CRYPTO": "Cryptocurrency",
	"MTVR": "Metaverse",
	"TECH": "Technology",
	"BLOCKCHAIN": "Blockchain",
	"WEB3": "Web3",
	"RAILWAY": "Railway Mania",
	"SILICON_VALLEY": "Silicon Valley Tech",
	"CHINA_STOCK": "Chinese Stock Market"
}

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	total_score = 0
	$StartTimer.start()


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass


func _on_bubble_timer_timeout() -> void:
	var bubble = bubble_scene.instantiate()

	# Choose a random location on Path2D.
	var bubble_spawn_location = $Player/BubblePath/BubbleSpawnLocation
	bubble_spawn_location.progress_ratio = randf()

	bubble.position = $Player.position + Vector2(-2000, randf_range(-300, 300))
	bubble.pop_chance = randf_range(0, 30)
	bubble.multiplier = randf_range(1, 10)
	var keys = bubble_names.keys()
	var random_key = keys[randi() % keys.size()]
	bubble.bubble_name = bubble_names[random_key]
	
	add_child(bubble)
	

func _on_start_timer_timeout() -> void:
	$BubbleTimer.start()
