local GameConfig = require(script.Parent.GameConfig)

local Economy = {}

function Economy.ExponentialCost(baseCost, growth, level)
	local exponent = math.max(0, level - 1)
	local raw = baseCost * (growth ^ exponent)
	return math.floor(raw + 0.5)
end

function Economy.GetConveyorUpgradeCost(currentLevel)
	return Economy.ExponentialCost(
		GameConfig.Conveyor.BaseUpgradeCost,
		GameConfig.Conveyor.UpgradeGrowth,
		currentLevel
	)
end

function Economy.GetPlotUpgradeCost(currentLevel)
	return Economy.ExponentialCost(
		GameConfig.Plot.BaseUpgradeCost,
		GameConfig.Plot.UpgradeGrowth,
		currentLevel
	)
end

function Economy.GetLevelMultiplier(level)
	local current = level or 1
	return 1 + (0.1 * math.max(0, current - 1))
end

function Economy.GetSellValue(baseIncomePerSecond, level, mutationMultiplier, sellFactor)
	local levelMultiplier = Economy.GetLevelMultiplier(level)
	local value = baseIncomePerSecond * mutationMultiplier * levelMultiplier * sellFactor
	return math.floor(value + 0.5)
end

return Economy
