public Damage calculateBaseDamage(Ability.IAbility ability) { int str = 0; float damageModifier = ability.getDamageModifier(); string damageType = ability.getAbilityClass(); bool crit; float critProb = 0.0f; float critMultiplier; switch (damageType) { case "Physical": str = strength; critMultiplier = 1.5f; critProb = getBasePhysicalCritProbability(); break; case "Fire": str = magic; critMultiplier = 1.2f; critProb = getBaseMagicCritProbability(); break; case "Ice": str = magic; critMultiplier = 1.2f; critProb = getBaseMagicCritProbability(); break; case "Light": str = spirit; critMultiplier = 1.2f; critProb = getBaseMagicCritProbability(); break; case "Poison": str = magic; critMultiplier = 1.2f; critProb = getBaseMagicCritProbability(); break; case "Ignore": return new Damage(0, false); default: throw new System.NotImplementedException(); } float rand = Random.Range(0.0f, 1.0f); crit = critProb > rand ? true : false; critMultiplier = crit ? 1.5f : 1.0f; return new Damage((int)(((str * str * str) / 32 + 32) * damageModifier * critMultiplier * Random.Range(0.8f, 1.2f)), crit); }