Conversation started Jun 24, 2013 at 3:13.
Jun 24, 2013 03:13
well lets say user clicks upgrade which takes 1 hour... then user logs in 2 hours later
pre upgrade the building generated X amount post upgrade it was x+2
how would you calculate it on interaction to include both levels
Right, I'll first explain how it could work with 1 event, then try to expand that to N events:
okay
So: to create our timeline:
T0 - User starts upgrade, it will complete at T1. Upgrade is marked for completion at T1. User logs out
T1 - Nothing happens because nobody is here
T2 - User logs in, sees that upgrade finished at T1 and does some calcs:
You'd need to calc 'X' from T0 to T1 at the rate without the upgrade, then from T1 to T2 with the upgrade
won't i need to store logout time =/ or at least "last update" time
When the player's empire is updated, you should store that time and use it as T0
Jun 24, 2013 03:18
okay
Then since the upgrade has a time (T1) that is greater than T0, but less than the current time (T2), you'll need to update in steps like this
This will be quite common, and more than likely multiple steps. If you have 2 upgrades:
T0: Queue U1 and U2, taking 1 and 2 hours respectively. Logout
T1: U1 is done, but nobody is here to see it
T2: U2 is done, but nobody is here to see it
T3: User logs in
hmm trying to work out how ill make the db for it
Same deal, Calc everything from T0 to T1, apply U1, then calculate from T1 to T2, apply U2, etc
Well... There's only a few important bits of time-related info: When the empire was last updated, when stuff will be done, and the current time
The "when stuff will be done" is going to have to be one time per item
so something like:

uid | build_id | upgrate_start | completes_on | length_minutes
actually i don't need completes_on really =/
i can calc that
I'd use completion time, since it's more important in calculations. Only the user cares when it started
But yeah, I'd keep only one of the two dates
Jun 24, 2013 03:25
won't i need to know when it started to know if there was time beforeit finished to give the post ugprade resources
Umm... I'm not sure if I follow
well if upgrade took 1 hour for that one hour itll be giving resources of normal for that one hour
then upgraded finished it is then doing an extra lets say +1 from then on per cycle
Well, doesn't it only change at the completion time?
yeh
itll start giving +1 more after upgrade finished
but for an hour of the users logged out time the building's upgrade was not finished so it was giving the default amount
so example:
user - upgrades (it takes 1 hour)
user - logs out
for 1 hour he gets 1 per 5 minutes
upgrade now finished
for 2 hours he gets 2 per 5 minutes
So upgrades start to work before they are done?
Jun 24, 2013 03:32
eh?
(you said U1 takes 3 hours, yet production went up after hour 1)
oops
fixed :P
Right. The starting date isn't important because nothing changes at the starting date, I'm assuming you've been collecting 1 unit / 5 minutes until now
yup
but when user logs in 3 hours later how does it know it was level 1 for 1 hour then level 2 for 2 hours
The end date is the important bit of info: when did this upgrade start working
In your example, T0 (when the user starts the upgrade) is in the DB as the last empire update time. T1 (when the upgrade is done) is in the DB when the user clicks "upgrade". T3 (when the user logs back in) is the current time. You have all the time info you need to calculate:
T1 - T0 = 1 hour * (1 / 5 mins)
T2 - T1 = 2 hours * (2 / 5 mins)
Yeah?
Jun 24, 2013 03:43
so t0 is start time ?
t1 is upgrade complete time ?
t2 is now
ok got it
wont i also need last interaction in there too
T (short for Time), and the numbers indicating a reference #. So like: T[0]
Depends, I might have only 1 number for the entire empire
So, "Last empire update" or "Last Interaction", yeah, same thing
I'm using "empire" to mean "player"
wait so t0 as start time is infact last interaction
The last time your production or upgrades or player has been updated
Jun 24, 2013 03:46
T1 - T0 = 1 hour * (1 / 5 mins) //time passed since last interaction
T2 - T1 = 2 hours * (2 / 5 mins) //time passed since upgrade
ok so i only need to store completion time i understand now
oh and last interaction time
thanks for explaining :D
Yeah, no problem
 
Conversation ended Jun 24, 2013 at 3:48.