In the energy reconstruction I've hit another problematic detail: Primal Madness, which increases the energy cap to 120. This is not complicated in itself (my code can handle a changed energy cap just fine), the problem is as in FB: WHEN does the energy cap change happen? Is it client-side or server-side?
Looking at the log, it seems like the Primal Madness aura is applied client-side, i.e. immediately after the cast of TF. This would mean that the +20 energy bonus is applied immediately. But during my tests I found a strange behaviour in one log: immediately after TF (which includes the AURA_APPLIED for Primal Madness), I have one cast which fails with "not enough energy", even the energy amount + the 20 provided by PM should make the cast possible. Seeing that the cast has failed, the code lowers the current energy value, which already includes the +20, and I fear that this is messing up with the rest of the reconstruction (ok, the effect will be small).
I'll do some more tests, spamming mangle (or shred) while activating TF at different times/energy levels, so as to see if the +20 is applied at aura application time (= immediately), or it's postponed until the SPELL_ENERGIZE event provided by TF (which, BTW stays at +60 even for a PM talented cat).