/// <summary> /// Apply the action's spell to the given target. /// </summary> /// <returns>True if there was any effect on the target.</returns> private bool ApplySpell(Combatant spellTarget) { StatisticsValue effectStatistics = CalculateSpellDamage(combatant, spell); if (spell.IsOffensive) { // calculate the defense Int32Range defenseRange = spellTarget.Character.MagicDefenseRange + spellTarget.Statistics.MagicalDefense; Int32 defense = defenseRange.GenerateValue(Session.Random); // subtract the defense effectStatistics -= new StatisticsValue(defense, defense, defense, defense, defense, defense); // make sure that this only contains damage effectStatistics.ApplyMinimum(new StatisticsValue()); // damage the target spellTarget.Damage(effectStatistics, spell.TargetDuration); } else { // make sure that this only contains healing effectStatistics.ApplyMinimum(new StatisticsValue()); // heal the target spellTarget.Heal(effectStatistics, spell.TargetDuration); } return(!effectStatistics.IsZero); }
/// <summary> /// Apply the action's spell to the given target. /// </summary> /// <returns>True if there was any effect on the target.</returns> private bool ApplySpell(Combatant spellTarget) { StatisticsValue effectStatistics = CalculateSpellDamage(combatant, spell); if (spell.IsOffensive) { // calculate the defense Int32Range defenseRange = spellTarget.Character.MagicDefenseRange + spellTarget.Statistics.MagicalDefense; Int32 defense = defenseRange.GenerateValue(Session.Random); // subtract the defense effectStatistics -= new StatisticsValue(defense, defense, defense, defense, defense, defense); // make sure that this only contains damage effectStatistics.ApplyMinimum(new StatisticsValue()); // damage the target spellTarget.Damage(effectStatistics, spell.TargetDuration); } else { // make sure that this only contains healing effectStatistics.ApplyMinimum(new StatisticsValue()); // heal the target spellTarget.Heal(effectStatistics, spell.TargetDuration); } return !effectStatistics.IsZero; }