Battle System

Tarochi features a battle system use to fight against NPCs, wild monsters or PVP.

## Fight

In Tarochi, battles are fought up to 3v3 monsters at a time, and for each turn you can chain up to 2 moves to perform during your turn. A monster may be in the FRONT, MID or BACK position.

The FRONT monster will also always be the one to receive attacks from the opponent. If your FRONT monster is defeated in battle, they will be replaced by your MID monster, and then BACK after. Placing your strongest monsters in the BACK is not always a winning strategy though, as MID monsters only deal 75% damage, and BACK monsters only deal 50% damage.

### Whisps

To avoid wild monster battles turning into a 1v3, every wild monster will be accompanied by two whisps of a random type. Wisps cannot be captured, and do not need to be defeated for the battle to end.

### Speed bar

When you can attack is decided by the yellow bar (the "speed bar") that is based on the speed of your monster in the FRONT position.

### Health & Healing

Each monster has its own health bar.
Health can be recovered in multiple ways:

1. Use the recover health move if your monster has one.
2. Use a Health Potion (can be used outside of battle).
3. Talk to a Healer.

### Resurrection

Monsters who fainted do not come back to life after a battle. You can resurrect a monster in a few ways:

1. Use a Resurrection Potion
2. Talk to a Healer.
3. Have all your monsters faint (they will all come back to life with 1 hp)

### Stamina

Each monster has its own stamina, and every attack consumes a certain amount of stamina.

Stamina can be recovered in multiple ways:

1. Use the recover stamina move. Recovers 30% of your stamina
2. When a battle starts, you will recover 12pts per 1 minute since your last fight with that monster.
3. Use a Stamina Potion (can be used outside of battle).
4. Talk to a Healer.

If you submit an attack that you end up not having enough stamina to perform, recover stamina will instead be used.

### Monster types

Monsters come in a variety of colors. Each color is strong against another color

### Status effects

Monsters may be inflicted with a variety of debuffs

 Overcharge
 Overheat
 Hypothermia
 Statis

## Capture

You can capture monsters with capture cards you buy at the Capture Shop. You can **only** equip two capture cards at once. To equip any capture card you have, you need to return to a city (safe zones not included)

The capture probability is based on the following formula

```
const levelDiff = maxLevel - monster.monsterStats.level;
let levelFactor = 1;

// If level difference is more than 5 levels, capture probability is 0.
if (levelDiff < -5) levelFactor = 0;

// If level difference is more than 3 levels, capture probability is 0.3
if (levelDiff < -3) levelFactor = 0.3;

// If level difference is more than 1 levels, capture probability is 0.5
if (levelDiff < -1) levelFactor = 0.5;

// If level difference is more than 0 levels, capture probability is 0.7
if (levelDiff < 0) levelFactor = 0.7;

// Power 150 - 200
const captureProbability = (-6 / 5) \* monster.monsterData.power + 255; // [150, 200] => [75, 15]

const inverseHPPercent = 1 - monster.health / monster.monsterStats.max\_health;

if (WISP\_LIST.includes(monster.monsterData.id)) {
 return { captureProbability: 0, inverseHPPercent, levelFactor };
}

return { captureProbability, inverseHPPercent, levelFactor };

```
E.g.

* normal monster (power 150), same level with 33% hp = 50% chance of capture
* legendary monster (power 200) 2 levels above with 50% hp = 5% chance of capture

Captured monsters will always start at level 1 (and not the level they were when you captured them)

## Party

You can swap the position of your monster during a fight

## Flee

Once you visit the next city, the route between the 2 cities will be "Conquered". This will allow you to unlock fleeing for that route. In this way it should be challenging to get from one city to the next as you progress through the game, but once you have then going through the areas in the route will be a breeze, also making it faster to do your Daily Quests.

Flee probability (between 0~100) is defined by the function below

```
const hp = this.player2.getBattleTeam().front!.\_health;
const maxHP = this.player2.getBattleTeam().front!.monsterStats.max\_health;
const hpPercent = hp / maxHP;
const prob = 33 + 100 \* (Math.log10(this.round) / 10) + 100 \* (1 - hpPercent);
// console.log({ hp, maxHP, hpPercent, prob });
return Math.min(75, prob);

```

## Battle rewards

Battles reward you with experience based on the following formula

```
const winMaxLevel = Math.max(
 winBattleTeam.front?.monsterStats.level || 0,
 winBattleTeam.middle?.monsterStats.level || 0,
 winBattleTeam.back?.monsterStats.level || 0
);
const loseMaxLevel = Math.max(
 loseBattleTeam.front?.monsterStats.level || 0,
 loseBattleTeam.middle?.monsterStats.level || 0,
 loseBattleTeam.back?.monsterStats.level || 0
);

if (winMaxLevel > loseMaxLevel + 5) {
 // do not award.
 return 0;
}

// award = [slope x=my-level, y=opponent-level] c \* x2-x1 / y2-y1;
// 100/c battles with same levels monsters
let slope = 100 / (winMaxLevel + 1);

// Encounter: -50%; lvl1 vs lvl1: 100/3 \* 0.5 = 16xp
// PVE: +30%; lvl1 vs lvl1: 100/3 \* 1.3 = 43xp
// PVP: 0xp
switch (battleType) {
 case BattleType.encounter:
 slope \*= 0.5;
 break;
 case BattleType.pve:
 slope \*= 1.3;
 break;
 slope = 0;
 break;
}
const xpAward = ((loseMaxLevel / winMaxLevel) \* slope) | 0;
// console.log('XP Awarded:', xpAward, { loseMaxLevel, winMaxLevel, slope });
// Do not award more than 100xp
return Math.min(xpAward, 100);

```
Additionally, battles may drop Items