Resolves errors being thrown randomly due to divide by 0

This commit is contained in:
Joe0 2012-03-15 01:25:02 -05:00
parent 1a59778484
commit bf92ee7a3e

View File

@ -64,14 +64,23 @@ public class Damage {
} }
public double getRangePortion() { public double getRangePortion() {
if (getTotalDamage() == 0) {
return 0;
}
return getRangeDamage() / getTotalDamage(); return getRangeDamage() / getTotalDamage();
} }
public double getMagicPortion() { public double getMagicPortion() {
if (getTotalDamage() == 0) {
return 0;
}
return getMagicDamage() / getTotalDamage(); return getMagicDamage() / getTotalDamage();
} }
public double getCombatPortion() { public double getCombatPortion() {
if (getTotalDamage() == 0) {
return 0;
}
return getCombatDamage() / getTotalDamage(); return getCombatDamage() / getTotalDamage();
} }
} }