Battlegrounds Battle Luck stat - Zero-to-Heroes/firestone GitHub Wiki
The Battle Luck is simple indicator that tells you how lucky you were in your battles during the run.
How it works
Here, "lucky" means getting a more favorable outcome than the one expected. This can mean a win or tie in case of a favored loss, or a win in case of a favored tie.
In short, it computes two factors: the "win factor" and the "tie factor".
Win factor
It computes how much more (or less) you won compared to what was expected. In short, it looks, for each battle, at:
- Whether you won (1) or not (0)
- The expected chance to win (somewhere between 0 and 1)
- And makes the difference
It then averages this across all battles, which gives you a score between -1 (impossibly unlucky: all the battles had a 100% chance of winning but you lost them anyway - which should never happen) and 1 (impossibly lucky). A score of 0 means that things were according to the stats.
The final score is then interpolated to give it a wider range for "average" luck around 0, as the extreme cases are really really unlikely.
Tie factor
It's the same, but uses the win+tie chance instead of the win alone
Final result
It's a weighted average between the two. Because I feel like the chance of winning has a bigger psychological impact than the tie, the current weights are 2 for the win factor and 1 for the tie factor.
It then gives you a final score between -100% and +100% that tells you how lucky you were during that run :)