The damage dealing is divided to 2 cases. First one being damage that is dealt right away, called immediate damage (in case of melee attacks),
and the other is delayed damage which is when it is dealt with some delay (in case of magic attack)
An example of player using delayed attack principle
For delayed damage to work, the damage number is generated in moment of actual attack action.
The number is, however, saved into an array held in the target character, along with a timer.
When timer's time is up, then the damage number is taken and dealt to the character (if he is still alive).
After that, damage after effects phase is initiated
4 Attack / defence calculation
input: attacker (Character), defender (Character)
output: damage to be dealt to the defender (number, can be negative)
!NEGATIVE DAMAGE NUMBER is only encoding for telling, that the damage is from poison!
In this phase, both characters (attacker and defender) are taken WITH CURENT SETUP AND BONUSES,
and roll for attacks / defences is done, with respect to the attack styles and game rules.
This results in number representing the damage to be dealt, and boolean which is telling, whether the damage was critical.
5 Damage after effects
input: damage (number), was damage critical (boolean)