|
It ’s best not to rely on a method for the algorithm of injury, but to use the interface,
For example, all types of units have
int getPAttack (); // Physical Attack
int getMAttack (); // Magic attack power
int getPAttackType (); // Physical attack type
int getMAttackType (); // Magic attack type
int getPDefence (int pType); // Defense for a certain type of physical attack
... there are attack rewards / coefficients, defense rewards / coefficients, immunity, hit rate / MISS rate, distance coefficient, height coefficient, random coefficient, etc.
int computeDamage (Unit atk, Unit def) {
int pDmg = atk.getPAttack ()-def.getPDefence (atk.getPAttackType ());
int mDmg = atk.getMAttack ()-def.getMDefence (atk.getMAttackType ());
int dmg = pDmg + mDmg ........;
}
In this way, each class of arms overrides / implement these methods, and returns different values according to the current state of the unit, and then calculates |
|