diff --git a/CourseApp.Tests/AnimalsTest.cs b/CourseApp.Tests/AnimalsTest.cs
new file mode 100644
index 00000000..0790c476
--- /dev/null
+++ b/CourseApp.Tests/AnimalsTest.cs
@@ -0,0 +1,54 @@
+namespace CourseApp.Tests
+{
+ using Xunit;
+
+ public class AnimalsTest
+ {
+ [Theory]
+ [InlineData("Animals", "Animals")]
+ [InlineData("Бычок", "Бычок")]
+ public void TestName(string a, string exp)
+ {
+ Pig actualResult = new Pig(a, 1);
+ Assert.Equal(exp, actualResult.Name);
+ }
+
+ [Theory]
+ [InlineData(88, 88)]
+ [InlineData(-20, 0)]
+ public void TestWeight(int a, int exp)
+ {
+ Pig actual = new Pig(" ", a);
+ Assert.Equal(exp, actual.Weight);
+ }
+
+ [Theory]
+ [InlineData(0, 0)]
+ [InlineData(-1, 0)]
+ [InlineData(88, 88)]
+ public void TestFat(int a, int expected)
+ {
+ Pig actual = new Pig(" ", 0, a);
+ Assert.Equal(expected, actual.Lard);
+ }
+
+ [Theory]
+ [InlineData(0, 0)]
+ [InlineData(-1, 0)]
+ [InlineData(8, 8)]
+ public void TestAge(int a, int expected)
+ {
+ Pig actual = new Pig(" ", 0, a, 88);
+ Assert.Equal(expected, actual.Age);
+ }
+
+ [Theory]
+ [InlineData("Бычок", 5, "Из Бычок можно получить 5 сала\n")]
+ [InlineData("Бычок", 0, "Бычок Без сала\n")]
+ public void TestToString(string n, int a, string expected)
+ {
+ Bull actual = new Bull(n, 8, a);
+ Assert.Equal(expected, actual.ToString());
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs
index cf7cbb14..99cd7448 100644
--- a/CourseApp.Tests/DemoTest.cs
+++ b/CourseApp.Tests/DemoTest.cs
@@ -5,9 +5,58 @@ namespace CourseApp.Tests
public class DemoTest
{
[Fact]
- public void Test1()
+ public void Test()
{
Assert.True(true);
}
+
+ [Fact]
+ public void TestIntSum()
+ {
+ int firstNumber = 2;
+ int secondNumber = 3;
+ int expected = 5;
+ var calc = new Calculator();
+ var actual = calc.GetSum(firstNumber, secondNumber);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public void TestIntProduct()
+ {
+ int firstNumber = 2;
+ int secondNumber = 3;
+ int expected = 6;
+ var calc = new Calculator();
+ var actual = calc.GetProduct(firstNumber, secondNumber);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public void TestDoubleQuotient()
+ {
+ double firstNumber = 5;
+ double secondNumber = 2;
+ double expected = 2.5;
+ var calc = new Calculator();
+ var actual = calc.GetQuotient(firstNumber, secondNumber);
+
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public void TestDoubleQuotientNull()
+ {
+ var calc = new Calculator();
+ double firstNumber = 5;
+ double secondNumber = 0;
+ double expected = double.PositiveInfinity;
+
+ var actual = calc.GetQuotient(firstNumber, secondNumber);
+
+ Assert.Equal(expected, actual);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/CourseApp.Tests/MyProgTests.cs b/CourseApp.Tests/MyProgTests.cs
new file mode 100644
index 00000000..0eaef01e
--- /dev/null
+++ b/CourseApp.Tests/MyProgTests.cs
@@ -0,0 +1,20 @@
+namespace CourseApp.Tests
+{
+ using Xunit;
+
+ public class MyProgTests
+ {
+ [Fact]
+ public void Sum1_And2_Returned3()
+ {
+ int x = 1;
+ int y = 2;
+ int expected = 3;
+
+ MyProg c = new MyProg();
+ int actual = c.Sum(x, y);
+
+ Assert.Equal(expected, actual);
+ }
+ }
+}
diff --git a/CourseApp/Animals.cs b/CourseApp/Animals.cs
new file mode 100644
index 00000000..707ea6b9
--- /dev/null
+++ b/CourseApp/Animals.cs
@@ -0,0 +1,117 @@
+namespace CourseApp
+{
+ /* using System; */
+ /* using System.Collections.Generic;*/
+
+ public abstract class Animals
+ {
+ private int lard;
+ private int weight;
+ private int age;
+
+ public Animals()
+ : this("неизвестного животного", 10, 12, 13)
+ {
+ }
+
+ public Animals(string name, int weight)
+ : this(name, weight, 0, 0)
+ {
+ }
+
+ public Animals(string name, int weight, int lard)
+ : this(name, weight, 0, lard)
+ {
+ }
+
+ public Animals(string name, int weight, int age, int lard)
+ {
+ Name = name;
+ Lard = lard;
+ Age = age;
+ Weight = weight;
+ }
+
+ public string Name
+ {
+ get;
+ set;
+ }
+
+ public int Weight
+ {
+ get
+ {
+ return weight;
+ }
+
+ set
+ {
+ if (value < 0)
+ {
+ weight = 0;
+ }
+ else
+ {
+ weight = value;
+ }
+ }
+ }
+
+ public int Age
+ {
+ get
+ {
+ return age;
+ }
+
+ set
+ {
+ if (value < 0)
+ {
+ age = 0;
+ }
+ else
+ {
+ age = value;
+ }
+ }
+ }
+
+ public int Lard
+ {
+ get
+ {
+ return lard;
+ }
+
+ set
+ {
+ if (value < 0)
+ {
+ lard = 0;
+ }
+ else
+ {
+ lard = value;
+ }
+ }
+ }
+
+ public override string ToString()
+ {
+ if (lard == 0)
+ {
+ return $"{Name} Без сала\n";
+ }
+ else
+ {
+ return $"Из {Name} можно получить {Lard} сала\n";
+ }
+ }
+
+ public abstract string Died();
+
+ public abstract string MakePhrase(string[] phraseArray);
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Bull.cs b/CourseApp/Bull.cs
new file mode 100644
index 00000000..b9db7158
--- /dev/null
+++ b/CourseApp/Bull.cs
@@ -0,0 +1,44 @@
+namespace CourseApp
+{
+ using System;
+ /* using System.Collections.Generic;*/
+
+ public class Bull : Animals
+ {
+ private Random random = new Random();
+
+ public Bull()
+ : base()
+ {
+ }
+
+ public Bull(string name, int weight)
+ : base(name, weight)
+ {
+ }
+
+ public Bull(string name, int weight, int lard)
+ : base(name, weight, lard)
+ {
+ }
+
+ public Bull(string name, int weight, int age, int lard)
+ : base(name, weight, age, lard)
+ {
+ }
+
+ public override string Died()
+ {
+ int lard = Lard;
+ Lard = 0;
+ return $"{Name} убит\nПолучено {lard} сала\n";
+ }
+
+ public override string MakePhrase(string[] phraseArray)
+ {
+ int index = random.Next(0, 3);
+ string phrase = phraseArray[index];
+ return $"{phrase}";
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Calculator.cs b/CourseApp/Calculator.cs
new file mode 100644
index 00000000..aec26da0
--- /dev/null
+++ b/CourseApp/Calculator.cs
@@ -0,0 +1,25 @@
+namespace CourseApp
+{
+ public class Calculator
+ {
+ public int GetSum(int a, int b)
+ {
+ return a + b;
+ }
+
+ public double GeSum(double a, double b)
+ {
+ return a + b;
+ }
+
+ public int GetProduct(int a, int b)
+ {
+ return a * b;
+ }
+
+ public double GetQuotient(double a, double b)
+ {
+ return a / b;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj
index 260260d3..74abf5c9 100644
--- a/CourseApp/CourseApp.csproj
+++ b/CourseApp/CourseApp.csproj
@@ -2,21 +2,9 @@
Exe
- netcoreapp2.1
- True
+ net6.0
+ enable
+ enable
-
-
-
-
-
- ../_stylecop/stylecop.ruleset
- true
-
-
-
-
-
-
diff --git a/CourseApp/CourseApp.sln b/CourseApp/CourseApp.sln
deleted file mode 100644
index 9eae834c..00000000
--- a/CourseApp/CourseApp.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2027
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp.csproj", "{9B953FDD-1645-4B1A-B148-5849E7C2D3A7}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "..\CourseApp.Tests\CourseApp.Tests.csproj", "{C348D2ED-C90F-4CE7-A1D8-9E57CBB33BDE}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {9B953FDD-1645-4B1A-B148-5849E7C2D3A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9B953FDD-1645-4B1A-B148-5849E7C2D3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9B953FDD-1645-4B1A-B148-5849E7C2D3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9B953FDD-1645-4B1A-B148-5849E7C2D3A7}.Release|Any CPU.Build.0 = Release|Any CPU
- {C348D2ED-C90F-4CE7-A1D8-9E57CBB33BDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C348D2ED-C90F-4CE7-A1D8-9E57CBB33BDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C348D2ED-C90F-4CE7-A1D8-9E57CBB33BDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C348D2ED-C90F-4CE7-A1D8-9E57CBB33BDE}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {064E603C-674E-4DB9-A061-4B08C0ACD98C}
- EndGlobalSection
-EndGlobal
diff --git a/CourseApp/Function.cs b/CourseApp/Function.cs
new file mode 100644
index 00000000..1435b1d8
--- /dev/null
+++ b/CourseApp/Function.cs
@@ -0,0 +1,42 @@
+namespace CourseApp
+{
+ using System;
+
+ public class Function
+ {
+ public double MathFunction(double x = 0)
+ {
+ double arcSin = Math.Asin(x);
+ double arcCos = Math.Acos(x);
+ return Math.Pow((arcSin * arcSin * arcSin * arcSin) + (arcCos * arcCos * arcCos * arcCos * arcCos * arcCos), 1 / 7);
+ }
+
+ public double[] TaskA(double xn, double xk, double dx)
+ {
+ int g = (int)(((xk - xn) / dx) + 1);
+ double[] results = new double[g];
+ int i = 0;
+ while (xn <= xk)
+ {
+ results[i] = MathFunction(xn);
+ i++;
+ xn = xn + dx;
+ }
+
+ return results;
+ }
+
+ public double[] TaskB(double[] numbers)
+ {
+ double[] results = new double[numbers.Length];
+ int g = 0;
+ foreach (double i in numbers)
+ {
+ results[g] = MathFunction(i);
+ g++;
+ }
+
+ return results;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/MyProg.cs b/CourseApp/MyProg.cs
new file mode 100644
index 00000000..0ba1b64d
--- /dev/null
+++ b/CourseApp/MyProg.cs
@@ -0,0 +1,10 @@
+namespace CourseApp
+{
+ public class MyProg
+ {
+ public int Sum(int x, int y)
+ {
+ return x + y;
+ }
+ }
+}
diff --git a/CourseApp/Pig.cs b/CourseApp/Pig.cs
new file mode 100644
index 00000000..38111fe1
--- /dev/null
+++ b/CourseApp/Pig.cs
@@ -0,0 +1,49 @@
+namespace CourseApp
+{
+ using System;
+ /*using System.Collections.Generic;*/
+
+ public class Pig : Animals
+ {
+ private Random random = new Random();
+
+ public Pig()
+ : base()
+ {
+ }
+
+ public Pig(string name, int weight)
+ : base(name, weight)
+ {
+ }
+
+ public Pig(string name, int weight, int lard)
+ : base(name, weight, lard)
+ {
+ }
+
+ public Pig(string name, int weight, int age, int lard)
+ : base(name, weight, age, lard)
+ {
+ }
+
+ public void AddLard(int lard)
+ {
+ Lard += lard;
+ }
+
+ public override string Died()
+ {
+ int lard = Lard;
+ Lard = 0;
+ return $"{Name} зарезана\nПолучено {lard} сала\n";
+ }
+
+ public override string MakePhrase(string[] phraseArray)
+ {
+ int index = random.Next(0, 3);
+ string phrase = phraseArray[index];
+ return $"{phrase}";
+ }
+ }
+}
diff --git a/CourseApp/PigAndSalo.cs b/CourseApp/PigAndSalo.cs
new file mode 100644
index 00000000..1acb582b
--- /dev/null
+++ b/CourseApp/PigAndSalo.cs
@@ -0,0 +1,76 @@
+namespace CourseApp
+{
+ public class PigAndSalo
+ {
+ private string pig;
+ private string salo;
+ private int age;
+ private int dateOfDeath;
+
+ public PigAndSalo(string pig, string salo, string color, int age, int dateOfDeath)
+ {
+ Pig = pig;
+ Salo = salo;
+ Age = age;
+ DateOfDeath = dateOfDeath;
+ }
+
+ public string Pig
+ {
+ get
+ {
+ return pig;
+ }
+
+ set
+ {
+ pig = value;
+ }
+ }
+
+ public string Salo
+ {
+ get
+ {
+ return salo;
+ }
+
+ set
+ {
+ salo = value;
+ }
+ }
+
+ public int Age
+ {
+ get
+ {
+ return age;
+ }
+
+ set
+ {
+ if (age > 20)
+ {
+ age = value;
+ }
+ }
+ }
+
+ public int DateOfDeath
+ {
+ get
+ {
+ return age;
+ }
+
+ set
+ {
+ if (dateOfDeath > 30)
+ {
+ dateOfDeath = value;
+ }
+ }
+ }
+ }
+}
diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs
index 51d2a96d..fa14d673 100644
--- a/CourseApp/Program.cs
+++ b/CourseApp/Program.cs
@@ -1,13 +1,18 @@
-namespace CourseApp
-{
- using System;
-
- public class Program
- {
- public static void Main(string[] args)
- {
- Console.WriteLine($"Hello world");
- Console.ReadLine();
- }
- }
-}
+namespace CourseApp
+{
+ using System;
+ using System.Collections.Generic;
+
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ int tournamentParticipants = 0;
+ Game start = new Game();
+ tournamentParticipants = start.StartTournament(tournamentParticipants);
+ Arena arena = new Arena();
+ arena.Tournament(tournamentParticipants);
+ Console.ReadLine();
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Abstract/Player.cs b/CourseApp/RPG/Abstract/Player.cs
new file mode 100644
index 00000000..11cdc36a
--- /dev/null
+++ b/CourseApp/RPG/Abstract/Player.cs
@@ -0,0 +1,83 @@
+namespace CourseApp
+{
+ using System;
+
+ public abstract class Player : IPlayer
+ {
+ public Player(string name, double health, int strength)
+ {
+ Name = name;
+ Health = health;
+ Strength = strength;
+ Afk = 0;
+ Effect = false;
+ DefaultHealth = health;
+ }
+
+ public int Afk { get; set; }
+
+ public double DefaultHealth { get; set; }
+
+ public string Name { get; set; }
+
+ public string ClassPlayer { get; set; }
+
+ public bool Effect { get; set; }
+
+ public string UltimateName { get; set; }
+
+ public int UltimateDamage { get; set; }
+
+ public int InfoAboutDamage { get; set; }
+
+ public double Health { get; set; }
+
+ public int Strength { get; set; }
+
+ public virtual int Ultimate(Player player, Player rival)
+ {
+ return 0;
+ }
+
+ public int Attack(Player soldier, Player soldierRival)
+ {
+ if (soldier.Effect)
+ {
+ soldier.Effect = false;
+ return InfoAboutDamage = soldier.Ultimate(soldier, soldierRival);
+ }
+ else
+ {
+ return InfoAboutDamage = Strength;
+ }
+ }
+
+ public int AttackAntagonist(Player soldier, Player soldierRival)
+ {
+ if (soldierRival.Effect)
+ {
+ soldierRival.Effect = false;
+ return InfoAboutDamage = soldierRival.Ultimate(soldier, soldierRival);
+ }
+ else
+ {
+ return InfoAboutDamage = Strength;
+ }
+ }
+
+ public virtual string Output()
+ {
+ return $"Имя: {Name} ; Здоровье: {Health} ; Сила: {Strength}";
+ }
+
+ public void Damage(int damage)
+ {
+ Health -= damage;
+ }
+
+ public void ResetHealth()
+ {
+ Health = DefaultHealth;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Heroes/Archer.cs b/CourseApp/RPG/Heroes/Archer.cs
new file mode 100644
index 00000000..d41e8b44
--- /dev/null
+++ b/CourseApp/RPG/Heroes/Archer.cs
@@ -0,0 +1,26 @@
+namespace CourseApp
+{
+ using System;
+
+ public class Archer : Player
+ {
+ public Archer(string name, double health, int strength)
+ : base(name, health, strength)
+ {
+ ClassPlayer = "Лучник";
+ UltimateName = "Ядовитый выстрел";
+ }
+
+ public override int Ultimate(Player player, Player rival)
+ {
+ UltimateDamage = 20;
+ Logger.LoggerOutput($"{ClassPlayer} {Name} использовал суперпособность {UltimateName}!");
+ return Strength += UltimateDamage;
+ }
+
+ public override string Output()
+ {
+ return $"Класс: {ClassPlayer}; Имя: {Name}; Здоровье: {Health}; Сила {Strength}";
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Heroes/Knight.cs b/CourseApp/RPG/Heroes/Knight.cs
new file mode 100644
index 00000000..d397ffaa
--- /dev/null
+++ b/CourseApp/RPG/Heroes/Knight.cs
@@ -0,0 +1,25 @@
+namespace CourseApp
+{
+ using System;
+
+ public class Knight : Player
+ {
+ public Knight(string name, double health, int strength)
+ : base(name, health, strength)
+ {
+ ClassPlayer = "Рыцарь";
+ UltimateName = "Ярость";
+ }
+
+ public override int Ultimate(Player player, Player rival)
+ {
+ Logger.LoggerOutput($"{ClassPlayer} {Name} использовал суперспособность {UltimateName}!");
+ return Strength = (int)(Strength * 13);
+ }
+
+ public override string Output()
+ {
+ return $"Класс: {ClassPlayer}; Имя: {Name}; Здоровье: {Health}; Сила {Strength}";
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Heroes/Mage.cs b/CourseApp/RPG/Heroes/Mage.cs
new file mode 100644
index 00000000..a0bf8813
--- /dev/null
+++ b/CourseApp/RPG/Heroes/Mage.cs
@@ -0,0 +1,36 @@
+namespace CourseApp
+{
+ using System;
+
+ public class Mage : Player
+ {
+ public Mage(string name, double health, int strength)
+ : base(name, health, strength)
+ {
+ ClassPlayer = "Маг";
+ UltimateName = "Превращение в пепел";
+ }
+
+ public override int Ultimate(Player player, Player rival)
+ {
+ if (player.Effect)
+ {
+ player.Afk = 10;
+ rival.Afk = 20;
+ }
+ else if (rival.Effect)
+ {
+ player.Afk = 20;
+ rival.Afk = 10;
+ }
+
+ Logger.LoggerOutput($"{ClassPlayer} {Name} использовал суперспособность {UltimateName}!");
+ return 0;
+ }
+
+ public override string Output()
+ {
+ return $"Призвание: {ClassPlayer}; Имя: {Name}; Здоровье: {Health}; Сила {Strength}";
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Interface/IPlayer.cs b/CourseApp/RPG/Interface/IPlayer.cs
new file mode 100644
index 00000000..5faef852
--- /dev/null
+++ b/CourseApp/RPG/Interface/IPlayer.cs
@@ -0,0 +1,11 @@
+namespace CourseApp
+{
+ public interface IPlayer
+ {
+ string Name { get; set; }
+
+ double Health { get; set; }
+
+ int Strength { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Logger/Logger.cs b/CourseApp/RPG/Logger/Logger.cs
new file mode 100644
index 00000000..81d30dc4
--- /dev/null
+++ b/CourseApp/RPG/Logger/Logger.cs
@@ -0,0 +1,12 @@
+namespace CourseApp
+{
+ using System;
+
+ public class Logger
+ {
+ public static void LoggerOutput(string log)
+ {
+ Console.WriteLine(log);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Tournament/Arena.cs b/CourseApp/RPG/Tournament/Arena.cs
new file mode 100644
index 00000000..fcd01619
--- /dev/null
+++ b/CourseApp/RPG/Tournament/Arena.cs
@@ -0,0 +1,97 @@
+namespace CourseApp
+{
+ using System;
+ using System.Collections.Generic;
+
+ public class Arena
+ {
+ private readonly Random random = new Random();
+ private Logger logger = new Logger();
+ private List soldiers = new List();
+ private List winners = new List();
+ private ListParticipants list = new ListParticipants();
+
+ private int round = 1;
+
+ private Fight fight = new Fight();
+
+ public void Tournament(int tournamentParticipants)
+ {
+ soldiers = list.AddAtList(tournamentParticipants);
+
+ Logger.LoggerOutput("Бойцы:");
+ foreach (Player item in soldiers)
+ {
+ Logger.LoggerOutput($"Боец {item.Name} - {item.ClassPlayer}");
+ }
+
+ Logger.LoggerOutput("Турнир начинается!");
+ Logger.LoggerOutput($"Раунд {round++}-й");
+ while (soldiers.Count + winners.Count > 1)
+ {
+ if (soldiers.Count >= 2)
+ {
+ int randomSoldierFirst = random.Next(0, soldiers.Count);
+ int randomSoldierSecond = random.Next(0, soldiers.Count);
+ while (randomSoldierFirst == randomSoldierSecond)
+ {
+ randomSoldierSecond = random.Next(0, soldiers.Count);
+ }
+
+ Player soldier = soldiers[randomSoldierFirst];
+ Player soldierRival = soldiers[randomSoldierSecond];
+ Logger.LoggerOutput($"Бой начинается: {soldier.ClassPlayer} {soldier.Name} против {soldierRival.ClassPlayer} {soldierRival.Name} \n");
+ fight.Zaruba(soldier, soldierRival);
+ Console.WriteLine("\n");
+ if (soldier.Health <= 0)
+ {
+ Logger.LoggerOutput($"{soldier.ClassPlayer} {soldier.Name} потерпел поражение и выбывает из турнира!");
+ soldierRival.ResetHealth();
+ soldiers.Remove(soldier);
+ soldiers.Remove(soldierRival);
+ winners.Add(soldierRival);
+ }
+ else
+ {
+ Logger.LoggerOutput($"{soldierRival.ClassPlayer} {soldierRival.Name} потерпел поражение и выбывает из турнира!");
+ soldier.ResetHealth();
+ soldiers.Remove(soldier);
+ soldiers.Remove(soldierRival);
+ winners.Add(soldier);
+ }
+ }
+
+ if ((winners.Count >= 2) && (soldiers.Count == 0))
+ {
+ int randomSoldierFirst = random.Next(0, winners.Count);
+ int randomSoldierSecond = random.Next(0, winners.Count);
+ while (randomSoldierFirst == randomSoldierSecond)
+ {
+ randomSoldierSecond = random.Next(0, winners.Count);
+ }
+
+ Logger.LoggerOutput($"Тур {round++}-й");
+ Player soldier = winners[randomSoldierFirst];
+ Player soldierRival = winners[randomSoldierSecond];
+ Logger.LoggerOutput($"Бой начинается: {soldier.ClassPlayer} {soldier.Name} против {soldierRival.ClassPlayer} {soldierRival.Name} \n");
+ fight.Zaruba(soldier, soldierRival);
+ if (soldier.Health <= 0)
+ {
+ Logger.LoggerOutput($"{soldier.ClassPlayer} {soldier.Name} потерпел поражение и выбывает из турнира!");
+ soldierRival.ResetHealth();
+ winners.Remove(soldier);
+ }
+ else
+ {
+ Logger.LoggerOutput($"{soldierRival.ClassPlayer} {soldierRival.Name} потерпел поражение и выбывает из турнира!");
+ soldier.ResetHealth();
+ winners.Remove(soldierRival);
+ }
+ }
+ }
+
+ Logger.LoggerOutput($"Победитель турнира - {winners[0].ClassPlayer} {winners[0].Name}!");
+ Logger.LoggerOutput("Турнир окончен!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Tournament/Fight.cs b/CourseApp/RPG/Tournament/Fight.cs
new file mode 100644
index 00000000..d2528fb3
--- /dev/null
+++ b/CourseApp/RPG/Tournament/Fight.cs
@@ -0,0 +1,56 @@
+namespace CourseApp
+{
+ using System;
+ using System.Collections.Generic;
+
+ public class Fight
+ {
+ private readonly Random random = new Random();
+ private int counterOne = 0;
+ private int counterTwo = 0;
+
+ public Tuple Zaruba(Player soldier, Player soldierRival)
+ {
+ while ((soldier.Health > 0) && (soldierRival.Health > 0))
+ {
+ if ((random.Next(1, 5) == 1) && (soldier.Effect == false) && (counterOne != 1))
+ {
+ counterOne = 1;
+ soldier.Effect = true;
+ }
+
+ if ((random.Next(1, 5) == 2) && (soldierRival.Effect == false) && (counterTwo != 2))
+ {
+ counterTwo = 2;
+ soldierRival.Effect = true;
+ }
+
+ if ((soldier.Afk > 0) && (soldier.Health > 0))
+ {
+ Logger.LoggerOutput($"{soldier.Name} пропускает свой ход.");
+ soldier.Afk--;
+ }
+ else if (soldier.Health > 0)
+ {
+ soldierRival.Damage(soldier.Attack(soldier, soldierRival));
+ Logger.LoggerOutput($"{soldierRival.Name} теряет {soldier.InfoAboutDamage} здоровье от удара {soldier.Name}!");
+ }
+
+ if ((soldierRival.Afk > 0) && (soldierRival.Health > 0))
+ {
+ Logger.LoggerOutput($"{soldierRival.Name} пропускает свой ход.");
+ soldierRival.Afk--;
+ }
+ else if (soldierRival.Health > 0)
+ {
+ soldier.Damage(soldierRival.AttackAntagonist(soldier, soldierRival));
+ Logger.LoggerOutput($"{soldier.Name} теряет {soldierRival.InfoAboutDamage} здоровье от удара {soldierRival.Name}!");
+ }
+ }
+
+ counterOne = 0;
+ counterTwo = 0;
+ return new Tuple(soldier, soldierRival);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Tournament/Game.cs b/CourseApp/RPG/Tournament/Game.cs
new file mode 100644
index 00000000..0a0f9222
--- /dev/null
+++ b/CourseApp/RPG/Tournament/Game.cs
@@ -0,0 +1,20 @@
+namespace CourseApp
+{
+ using System;
+
+ public class Game
+ {
+ public int StartTournament(int tournamentParticipants)
+ {
+ Logger.LoggerOutput("Введите количество участников турнира: ");
+ tournamentParticipants = Convert.ToInt32(Console.ReadLine());
+ while ((tournamentParticipants % 2 != 0) && (tournamentParticipants > 0))
+ {
+ Logger.LoggerOutput("Количество участников должно быть кратно двум и больше нуля! ");
+ tournamentParticipants = Convert.ToInt32(Console.ReadLine());
+ }
+
+ return tournamentParticipants;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPG/Tournament/ListParticipants.cs b/CourseApp/RPG/Tournament/ListParticipants.cs
new file mode 100644
index 00000000..4f937bea
--- /dev/null
+++ b/CourseApp/RPG/Tournament/ListParticipants.cs
@@ -0,0 +1,46 @@
+namespace CourseApp
+{
+ using System;
+ using System.Collections.Generic;
+
+ public class ListParticipants
+ {
+ private readonly Random random = new Random();
+ private readonly string[] arrayOfName = new string[10]
+ {
+ "Брон",
+ "Дрэйкон",
+ "Вистан",
+ "Тазар",
+ "Алкин",
+ "Корбак",
+ "Гервульф",
+ "Бронхильд",
+ "Мирланда",
+ "Розик",
+ };
+
+ private List soldiers = new List();
+
+ public List AddAtList(int tournamentParticipants)
+ {
+ while (soldiers.Count < tournamentParticipants)
+ {
+ switch (random.Next(0, 3))
+ {
+ case 0:
+ soldiers.Add(new Archer(arrayOfName[random.Next(0, 10)], random.Next(100, 130), random.Next(10, 10)));
+ break;
+ case 1:
+ soldiers.Add(new Knight(arrayOfName[random.Next(0, 10)], random.Next(100, 130), random.Next(10, 10)));
+ break;
+ case 2:
+ soldiers.Add(new Mage(arrayOfName[random.Next(0, 10)], random.Next(100, 130), random.Next(10, 10)));
+ break;
+ }
+ }
+
+ return soldiers;
+ }
+ }
+}
\ No newline at end of file