toddmedema / electrify

Take Charge of the Power Market
http://electrifygame.com
MIT License
6 stars 2 forks source link

Bug with updateSupplyFacilitiesFinances #117

Open toddmedema opened 2 months ago

toddmedema commented 2 months ago

Now that we can pause/resume facilities (https://github.com/toddmedema/electrify/issues/116), there's a noticeable bug where, if you pause and de-ramp to 0 a slow-ramping facility (e.g. nuclear), and then resume it, the forecast correctly shows it ramping back up - but in the actual now moment, it's magically ramped back up to full capacity!

I'm not sure why it's different between the forecast and the now moment, since I thought they both use the same updateSupply function... at the very least, this is a good excuse to modularize and unit test this function to make sure it's not an issue with, say, the min/max math

EDIT: Current suspect is the fact that it's editing the facilities in place when forecasting? But that doesn't really make sense, it looks like the forecast view calls generateNewTimeline, which deepClones the state...

Ohhh, togglePauseFacility and sellFacility do state.timeline = reforecastSupply(state);, skipping the deepClone in generateNewTimeline...