public void AddXp(Character character, Beast beast) { if (beast == null) { throw new ArgumentNullException("beast"); } if (character.Level - beast.Level > 10) { return; } if (character.Level - beast.Level > -10) { return; } if (character.Level > beast.Level) { character.Xp += beast.Xp * Math.Abs(character.Level - beast.Level) / 10; } if (character.Level < beast.Level) { character.Xp += beast.Xp * (Math.Abs(character.Level - beast.Level) / 10 + 1); } }
/// <summary> /// Бросок костей для монстра, в зависимости от уровня /// </summary> /// <param name="beast"></param> /// <returns></returns> public List<int> AiDice(Beast beast) { var ints = new List<int>(); var random = new Random(); var rolls = beast.Level; for (var i = 0; i < rolls; i++) { ints.Add(random.Next(6) + 1); } return ints; }
public void Turn(Character character, Beast beast, List <int> charDices, List <int> beastDices) { if (CharStrengherThanBeast(character, beast)) { for (var i = 0; i < charAttack.Count; i++) { if (charAttack[i].Power > beastAttack[i].Defence) { if (charDices.Count(j => j == 6) >= 1) { beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.4m); } else { if (charDices.Count(j => j == 5) >= 2) { beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.6m); } if (charDices.Count(j => j == 5) >= 1) { beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.8m); } } } if (charAttack[i].Power < beastAttack[i].Defence) { if (charDices.Count(j => j == 6) >= 2) { beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.5m); } else { if (charDices.Count(j => j == 5) < 0) { character.Player.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.8m); } if (charDices.Count(j => j == 5) < 1) { beast.Life -= charAttack[i].Power - (int)(beastAttack[i].Defence * 0.4m); } } } } } if (beast.Life <= 0) { new ExpierenceService().AddXp(character, beast); } }
public List <int> AiDice(Beast beast) { var ints = new List <int>(); var random = new Random(); var rolls = beast.Level; for (var i = 0; i < rolls; i++) { ints.Add(random.Next(6) + 1); } return(ints); }
/// <summary> /// Рассчет количества опыта получаемого за врага. /// опыт начисляется в зависимости от того, какая разница уровней /// есть между сражающимися. Если один из них слишком крут, то опыта /// не будет. /// </summary> /// <param name="character"></param> /// <param name="beast"></param> public void AddXp(Character character, Beast beast) { if (beast == null) { throw new ArgumentNullException("beast"); } if (character.Level - beast.Level > 10) { return; } if (character.Level - beast.Level > -10) { return; } if (character.Level > beast.Level) { character.Xp += beast.Xp*Math.Abs(character.Level - beast.Level)/10; } if (character.Level < beast.Level) { character.Xp += beast.Xp*(Math.Abs(character.Level - beast.Level)/10 + 1); } }
private bool CharStrengherThanBeast(Character character, Beast beast) { return((character.Level > beast.Level) && (charAttack.Count >= beastAttack.Count)); }
public void Fight(Character character, Beast beast) { charAttack = character.Attack(); beastAttack = beast.Attack(); }
/// <summary> /// Рассчет одного хода битвы /// В зависимости от того, у кого круче уровень, будет по разному рассчитаны коэффициенты атаки и защиты, /// соответственно и урона. /// Далее сравниваются атака и защита борющихся и в зависимости от этого опять же меняются коэффициенты. /// </summary> /// <param name="character"></param> /// <param name="beast"></param> /// <param name="charDices"></param> /// <param name="beastDices"></param> public void Turn(Character character, Beast beast, List<int> charDices, List<int> beastDices) { if (character.Level > beast.Level) { if (charAttack.Count >= beastAttack.Count) { for (var i = 0; i < charAttack.Count; i++) { if (charAttack[i].Power > beastAttack[i].Defence) { if (charDices.Count(j => j == 6) >= 1) { beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.4m); } else { if (charDices.Count(j => j == 5) >= 2) { beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.6m); } if (charDices.Count(j => j == 5) >= 1) { beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.8m); } } } if (charAttack[i].Power < beastAttack[i].Defence) { if (charDices.Count(j => j == 6) >= 2) { beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.5m); } else { if (charDices.Count(j => j == 5) <= 0) { character.Player.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.8m); } if (charDices.Count(j => j == 5) < 2) { beast.Life -= charAttack[i].Power - (int) (beastAttack[i].Defence*0.4m); } } } } } } if (beast.Life <= 0) { new ExpierenceService().AddXp(character, beast); } }
/// <summary> /// Битва между персонажем и чудовищем /// </summary> /// <param name="character"></param> /// <param name="beast"></param> public void Fight(Character character, Beast beast) { charAttack = character.GetAttacks(); beastAttack = beast.GetAttacks(); }