Mana

Chess pieces earn **mana** when they deal damage and when they take damage.

When a unit collects 100 mana, they try to cast their active ability if available.

## Mechanics

### Mana gain when taking damage

When a unit takes damage, it gains mana, and the amount is calculated by following steps

1. Mana gain is set to damage taken (after all damage manipulations and damage block) / 5 and cap at a maximum of 50
2. Mana gain is set to a random number between (mana gain/2) and (mana gain).
3. If unit has Ultimate Orb or Blink Dagger, Mana gain is set to Mana gain \* 1.25
4. If unit has Scythe of Vyse, Mana gain is set to Mana gain \* 1.50

### Mana gain when dealing damage

When a unit deal damage, it gains mana, and the amount is calculated by following steps

1. If attacker is Shaman, Warlock, Mage or Priest, mana gain is set to damage dealt (after all damage manipulations and damage block) / 2.5 and cap at a maximum of 20. Else, mana gain is set to the mana gained by the target, capped at 10.
2. If unit has Crown, or any Dagon, mana gain is set to Mana gain \* 1.5
3. If unit has Void stone, Scythe or Mystic Staff, Mana gain is set to Mana gain \* 2
4. If unit has Perseverance or Battle Fury, Mana gain is set to Mana gain \* 2
5. If unit has Refresher Orb, Mana gain is set to Mana gain \* 3

## Mana gain bonus from items

Crown: **+50%** mana gain when **dealing** damage.

Dagon: **+50%** mana gain when **dealing** damage.

Void Stone: **+100%** mana gain when **dealing** damage.

Mystic Staff: **+100%** mana gain when **dealing** damage.

Perseverance: **+100%** mana gain when **dealing** damage.

Battle Fury: **+100%** mana gain when **dealing** damage.

Refresher Orb: **+200%** mana gain when **dealing** damage.

Ultimate Orb: **+25%** mana gain when **taking** damage.

Blink Dagger: **+25%** mana gain when **taking** damage.

Scythe of Vyse: **+100%** mana gain when **dealing** damage and **+50%** mana gain when **taking** damage.

## Stacking

Item does not stack with the same item (e.g. 2 void stones do not stack). Items in following lines do not stack with the other item in the same line

* Ultimate Orb, Blink Dagger
* Crown, Dagon 1-5
* Void Stone, Mystic Staff, Scythe of Vyse
* Perseverance, Battle Fury

## Trivia

* Without mana gaining item, unit gain maximum of 10 mana (when deal an instance of 50 or more damage) when deal damage and a maximum of 25-50 mana (when take an instance of 250 damage or more) when take damage
	+ Assume that unit has no mana gaining item and takes no damage, a normal unit need to make at least 10 attacks to gain 100 mana.
	+ Assume that unit has no mana gaining item, deals no damage and does not take over-cap damage, the unit need to lose from a minimum of 500 HP to a maximum of 1000 HP from taking damage to get 100 mana.
* Mage, Warlock, Shaman, Priest receive double mana gain when dealing damage compared to other units.
* Demons auto attack with Fel Power buff counts as 2 damage instances, so they may get double the mana gain.
	+ SF is both Demon and Warlock, with high base damage. A 2\* SF can easily get 40 mana per auto attack.
* Mana gain bonus from item stacks multiplicatively.
* As a possible inconsistency (or intended?), mana gain bonus for taking damage also increases the mana gain for the attacker if the attacker is not a Shaman, Warlock, Mage or Priest and dealt very little damage (under 50).
	+ A more consistent working in this case: mana gain should be set to (damage dealt / 5) instead of the amount gained by the attack target.