> For the complete documentation index, see [llms.txt](https://gotchi-battler-1.gitbook.io/gotchi-battler/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gotchi-battler-1.gitbook.io/gotchi-battler/reference/campaign-xp.md).

# Campaign XP

This page describes the live rules used to calculate Campaign XP rewards for Spirits.

* Only **Spirits** gain Campaign XP.
* Only units in the **5-slot formation** count for XP. Subs do not earn XP.
* Campaign XP starts from the battle's base `xpReward`.
* Campaign XP can be reduced by the overlevel penalty.

## Formula

Player team total level is the sum of the levels of the **5 formation units** you brought into the battle.

Encounter raw total level is the sum of the levels of the enemy units that are actually present in the encounter.

For standard encounters:

```
encounterEffectiveTeamLevel = encounterRawTotalLevel
```

The level gap is:

```
playerTeamTotalLevel = sum(levels of the 5 formation units)
encounterRawTotalLevel = sum(enemy unit levels)
levelGap = max(0, playerTeamTotalLevel - encounterEffectiveTeamLevel)
xpPenaltyMultiplier = max(0.10, 0.97265 ^ levelGap)
adjustedBattleXp = round(baseBattleXp * xpPenaltyMultiplier)
```

* If `levelGap = 0`, the multiplier is `1.00`.
* The multiplier never drops below `0.10`.

If the leader slot contains a Spirit:

```
leaderSpiritXp = round(adjustedBattleXp * 1.00)
otherSpiritXp = round(adjustedBattleXp * 0.25)
```

If the leader slot contains an Aavegotchi:

```
allSpiritXp = round(adjustedBattleXp * 0.25)
```

### Boss normalization

For boss encounters with only **3 enemy units**, the enemy total is normalized to a 5-unit equivalent before the level gap is calculated:

```
encounterEffectiveTeamLevel = encounterRawTotalLevel * (5 / enemyUnitCount)
```

## Examples

### Standard encounters

| Player total | Encounter total | Level gap | Penalty | Result        |
| ------------ | --------------: | --------: | ------: | ------------- |
| `225`        |           `225` |       `0` | `1.00x` | Full XP       |
| `230`        |           `225` |       `5` | `0.87x` | Small penalty |
| `250`        |           `225` |      `25` | `0.50x` | About half XP |
| `275`        |           `225` |      `50` | `0.25x` | Heavy penalty |

### Boss encounter normalization

If a boss encounter has 3 enemies at level `45`, the raw enemy total is:

```
45 + 45 + 45 = 135
```

Because it is a 3-unit boss encounter, that total is normalized:

```
135 * (5 / 3) = 225
```

So a player team with **5 level 50s** has total level `250`, which gives:

```
levelGap = max(0, 250 - 225) = 25
```

That means the boss encounter still applies an overlevel penalty, but it is based on the normalized `225` effective enemy total rather than the raw `135`.
