Blaze-Brigade
Static Public Member Functions | List of all members
Model.DamageCalculations Class Reference

This class calculates all damage related calculations More...

Static Public Member Functions

static int getDamageDealt (Unit attacker, Unit defender, bool physOrMagic)
 
static int getHitRate (Unit attacker, Unit defender)
 
static int getCritRate (Unit attacker, Unit defender)
 
static int getHitCount (Unit attacker, Unit defender)
 
static int finalDamage (Unit attacker, Unit defender, bool physOrMagic)
 

Detailed Description

This class calculates all damage related calculations

Member Function Documentation

§ finalDamage()

static int Model.DamageCalculations.finalDamage ( Unit  attacker,
Unit  defender,
bool  physOrMagic 
)
static

factors in damage dealt, hit rate, crit rate, and number of attacks (as in how above functions were calculated) to calculate actual damage dealt. Hit and crit is factored in by creating a random number between 0-100, and see if that random number is within the range of the crit or hit rate. If it is, then the unit hits with the attack and/or crits.
If an attack misses, damage dealt is 0, otherwise damage is dealt normally.
If an attack crits, damage dealt is x2 regular normal damage.
If numOfAttacks is 1, damage is dealt once. Else if 2, damage is dealt twice.

Parameters
attackerThe unit performing the attack
defenderThe unit defending against the attack
physOrMagicBoolean that tells the controller if it's physical or magical damage to be calculated

§ getCritRate()

static int Model.DamageCalculations.getCritRate ( Unit  attacker,
Unit  defender 
)
static

Passes in the 2 units, and returns the crit rate as a percentage out of 100 by taking into account both unit's skill.
This calculation is found according to the equation [((attackerSkill/10) - (defenderSkill/10) +1) *0.1] *100.
A negative hitrate will be changed to 0.

Parameters
attackerThe unit performing the attack
defenderThe unit defending against the attack

§ getDamageDealt()

static int Model.DamageCalculations.getDamageDealt ( Unit  attacker,
Unit  defender,
bool  physOrMagic 
)
static

passes in the 2 units, and a boolean on whether attack is physical (false). Damage is then calculated by taking attacker's Str/int, and defender's def/res (where str-def is for physical, and int-res is for magic). If the defending stat is higher, final damage is 0 as an attack cannot heal.

Parameters
attackerThe unit performing the attack
defenderThe unit defending against the attack
physOrMagicBoolean that tells the controller if it's physical or magical damage to be calculated

§ getHitCount()

static int Model.DamageCalculations.getHitCount ( Unit  attacker,
Unit  defender 
)
static

passes in then 2 units, and determines how many attacks the attacker makes by factoring in both unit's relative speed. If one unit's speed is 4 or more higher then the other unit, hitCount will return 2.

Parameters
attackerThe unit performing the attack
defenderThe unit defending against the attack

§ getHitRate()

static int Model.DamageCalculations.getHitRate ( Unit  attacker,
Unit  defender 
)
static

Passes in the 2 units, and returns the hit rate as a percentage out of 100 by taking into account both unit's skill.
This calculation is found according to the equation [((attackerSkill/10) - (defenderSkill/10) +1) *0.8] *100.
A negative hitrate will be changed to 0.

Parameters
attackerThe unit performing the attack
defenderThe unit defending against the attack

The documentation for this class was generated from the following file: