Improved time calculation in Town Hall
![]() ![]() |
I posted before about this, but I wasn't quite able to express my thoughts very well, but I think I've figured it out. On the Town Hall page, the "Time" is calculated by
then tiempoHora is passed into a function that puts it in terms of Days, Hours and Minutes. Now, that's all fine, but as poblacionActual changes, so does poblacionHora, and I realized that the time it reports is much less than the true amount of time it would take (because as each new member in the population is added, the growth gets slower). Here's what I changed my code to be, and it seems to work pretty well for me. I also took out the default "tiempoHora =" line.
What the code does is calculate the amount of time it will take to reach the next higher population number. It then calculates how much time it takes to get to the next one, and so on, adding them up as it goes. The only problem is of course if (poblacionHora - .02 * n) becomes zero or less than zero. In that case I just made tiempoHora = 0 and on the Town Hall page it reports "Time: " and I know that at my current growth, my population will never reach its maximum. This also helps out with the calculation for how much Wine your population will use up until it reaches the maximum (reports it as "Wine:0" if the population won't reach its maximum). How'd I do? |

