# Real-time Stat Updates

Below is a function that is inside both the Battle Form and the Level Forms, although the function in the Levels forgo updating the Enemy's health since that is only needed in the battle screen. The health bars are just a fraction of the current health over the max health, so the health level is apparent at a glance. Each other element is just a label, and has the ToString called to print itself on the UI element. UpdateStats() is called after any button click in form battle, for the overworld, the stats update on the same tick that updated the time label uses to show the elapsed time.

```csharp
private void UpdateStats() {
    float playerHealthPer = player.Health / (float)player.MaxHealth;
    float enemyHealthPer = enemy.Health / (float)enemy.MaxHealth;

    const int MAX_HEALTHBAR_WIDTH = 226;
    lblPlayerHealthFull.Width = (int)(MAX_HEALTHBAR_WIDTH * playerHealthPer);
    lblEnemyHealthFull.Width = (int)(MAX_HEALTHBAR_WIDTH * enemyHealthPer);

    lblPlayerHealthFull.Text = player.Health.ToString() + "/" + player.MaxHealth.ToString();
    lblEnemyHealthFull.Text = enemy.Health.ToString() + "/" + enemy.MaxHealth.ToString();

    lblPlayerStrength.Text = "Attack Power: " + (player._strength * 4).ToString();

    lblPlayerScore.Text = "Score: " + player.Score.ToString();
}
```

### Here is an example of the game state where the player has defeated two enemies, and is fighting a third.

<figure><img src="https://1055530831-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTLAKl9MnL4UmPhZlb3vF%2Fuploads%2FgJ0DNWKn963gBqMtDNdi%2FUI_Stats.png?alt=media&#x26;token=402b4cee-0f5b-4ad7-bb21-21086e060692" alt=""><figcaption></figcaption></figure>
