Hi everyone,
I’m having some trouble calculating offline progress for my tycoon game. So I’ve calculated the total income a player can make, that part was no problem. But I also have a feature in my game called “boosts.” Boosts can be used by the player to multiply their income by a certain amount. Boosts can also be stacked on top of each other additively. For example, a player could activate a 2x, 5x, and 10x boost, which would mean a 17x boost in total.
The problem is that each boost can have a different duration. If each active boost has a duration greater or equal than the offline time of the player, then its no problem calculating their total income. But if a boost or multiple boosts have a duration less than offline time, then I don’t know what to do.
Here’s what I tried so far,. This is only taking in to account one boost, which is somewhat simple.
local boostedTime = math.min(boostDuration, offlineTime)
local unboostedTime = offlineTime - boostedTime
local boostedIncome = baseIncomePerSecond * boostedTime * boostMultiplier
local unboostedIncome = baseIncomePerSecond * unboostedTime
local totalIncome = boostedIncome + unboostedIncome
I think I might need to create some sort of timeline with when boosts end? I’m stuck and any help would be appreciated.