class_name ProgressionManagerClass
extends Node

var player_level: int = 1
var experience: float = 0.0

signal xp_gained(amount: int, new_total: float)
signal level_up(new_level: int, unlocks: Dictionary)
signal product_unlocked(product_id: String)

func _ready() -> void:
	pass

func add_xp(amount: int) -> void:
	experience += amount
	xp_gained.emit(amount, experience)

func get_level_unlocks(level: int) -> Dictionary:
	return {"max_printers": level, "max_workers": level}

func get_max_printers() -> int:
	return player_level

func _get_game_time() -> float:
	if is_instance_valid(GameManager):
		return GameManager.game_time
	return 0.0

func _check_economy() -> void:
	if EconomyManager:
		var profit = EconomyManager.get_profit()
		if profit > 100.0:
			level_up.emit(player_level + 1, {})

func serialize() -> Dictionary:
	return {
		"player_level": player_level,
		"experience": experience,
	}

func deserialize(data: Dictionary) -> void:
	player_level = data.get("player_level", 1)
	experience = data.get("experience", 0.0)
