private int CastDamageSpell(Player player, DamageSpell damageSpell, ref GameSession.BattleResult battleResult) { int spellDamage = 0; //If the enemy would dodge the attack do not calculate spell damage if (RandomNumberGenerator.RandomNumberBetween(1, 100) <= player.DodgeChanceRate) { battleResult = GameSession.BattleResult.Missed; CurrentMana -= damageSpell.ManaCost; return(0); } //If the player would critical strike the enemy then calculate the spell damage accordingly if (RandomNumberGenerator.RandomNumberBetween(1, 100) <= CriticalChanceRate) { //Increase damage by critical damage modifier battleResult = GameSession.BattleResult.Critical; if (player.TotalResistance <= -10) { spellDamage = (int)(((damageSpell.DamageValue + ((Intellect * Intellect) / (Intellect + 1))) * (Math.Abs((double)player.TotalResistance) / 10)) * CriticalDamageModifier); } else if (player.TotalResistance <= 0) { spellDamage = (int)((damageSpell.DamageValue + ((Intellect * Intellect) / (Intellect + 1))) * CriticalDamageModifier); } else { spellDamage = (int)((damageSpell.DamageValue + ((Intellect * Intellect) / (Intellect + player.TotalResistance))) * CriticalDamageModifier); } CurrentMana -= damageSpell.ManaCost; } //Else the player would normally strike the enemy then calculate the spell damage accordingly else { battleResult = GameSession.BattleResult.Normal; if (player.TotalResistance <= -10) { spellDamage = (int)((damageSpell.DamageValue + ((Intellect * Intellect) / (Intellect + 1))) * (Math.Abs((double)player.TotalResistance) / 10)); } else if (player.TotalResistance <= 0) { spellDamage = (int)(damageSpell.DamageValue + ((Intellect * Intellect) / (Intellect + 1))); } else { spellDamage = (int)(damageSpell.DamageValue + ((Intellect * Intellect) / (Intellect + player.TotalResistance))); } CurrentMana -= damageSpell.ManaCost; } return(spellDamage); }
private void PlayerCastDamageSpell(BattleResult battleResult, int damage, DamageSpell damageSpell) { CurrentEnemy.CurrentHealth -= damage; switch (battleResult) { case BattleResult.Missed: RaiseMessage(CurrentPlayer.Name + " missed " + damageSpell.Name); break; case BattleResult.Normal: RaiseMessage(CurrentPlayer.Name + " casts " + damageSpell.Name + " and does " + damage + " points of magical damage"); break; case BattleResult.Critical: RaiseMessage(CurrentPlayer.Name + " casts " + damageSpell.Name + " and it critically strikes and does " + damage + " points of magical damage"); break; } if (CurrentEnemy.CurrentHealth <= 0) { GainBattleRewards(); } }