diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj
index e43252f..a330a77 100644
--- a/CourseApp.Tests/CourseApp.Tests.csproj
+++ b/CourseApp.Tests/CourseApp.Tests.csproj
@@ -2,7 +2,7 @@
net6.0
- True
+ false
false
diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs
index 174ab9b..36c906b 100644
--- a/CourseApp.Tests/DemoTest.cs
+++ b/CourseApp.Tests/DemoTest.cs
@@ -1,6 +1,7 @@
namespace CourseApp.Tests
{
using Xunit;
+ using Vehicles;
public class DemoTest
{
diff --git a/CourseApp.Tests/TestSaga.cs b/CourseApp.Tests/TestSaga.cs
new file mode 100644
index 0000000..4888bbb
--- /dev/null
+++ b/CourseApp.Tests/TestSaga.cs
@@ -0,0 +1,30 @@
+namespace CourseApp.Tests
+{
+ using Xunit;
+ using Vehicles;
+
+ public class TestMatch
+ {
+ [Fact]
+ public void Test1()
+ {
+ Assert.True(true);
+ }
+
+ [Fact]
+ public void TestBattleWinner1()
+ {
+ var top = new Player("Knight", "top", 100, 10);
+ var low = new Player("Knight", "low", 10, 1);
+ var winner = Battle(top, low);
+ Assert.Equal(top, winner);
+ }
+ public void TestBattleWinner2()
+ {
+ top = new Player("Knight", "top", 100, 10);
+ low = new Player("Knight", "low", 10, 1);
+ var winner = Battle(low, top);
+ Assert.Equal(top, winner);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj
index 7305fad..b94a7a4 100644
--- a/CourseApp/CourseApp.csproj
+++ b/CourseApp/CourseApp.csproj
@@ -3,7 +3,7 @@
Exe
net6.0
- True
+ False
diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs
index 5e6076a..abe8ee3 100644
--- a/CourseApp/Program.cs
+++ b/CourseApp/Program.cs
@@ -3,12 +3,24 @@
using System;
using System.Collections.Generic;
using System.Text;
+ using RPGSaga;
public class Program
{
public static void Main(string[] args)
{
- var def = new Plane() { Speed = 1000, Height = 11000 };
+ var artur = new Knight() { Name = "Артур", Maxhealth = 80, Power = 5 };
+ artur.Greetings();
+ artur.DealDamage();
+ artur.VengStrike();
+ var mc = new MultiplyChars();
+ var twoheros = mc.CreateN(2);
+ foreach (var player in twoheros)
+ {
+ player.Greetings();
+ }
+
+ /* var def = new Plane() { Speed = 1000, Height = 11000 };
var ssj = new Copter() { Name = "SSJ100", Speed = 800, Diagonal = 8.2 };
var airbus = new Plane("Airbus", -1, 9500);
var pt300 = new Copter("ПТ300", 800, 5000);
@@ -18,7 +30,7 @@ public static void Main(string[] args)
foreach (var vehicle in transport)
{
Console.WriteLine(vehicle.Display());
- }
+ } */
}
}
}
\ No newline at end of file
diff --git a/CourseApp/RPGSaga/BattleMaker.cs b/CourseApp/RPGSaga/BattleMaker.cs
new file mode 100644
index 0000000..cc5762d
--- /dev/null
+++ b/CourseApp/RPGSaga/BattleMaker.cs
@@ -0,0 +1,36 @@
+namespace RPGSaga
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
+ public class BattleMaker
+ {
+ public static Player Battle(Player player1, Player player2)
+ {
+ player1.health = player1.Maxhealth;
+ player2.health = player2.Maxhealth;
+ var winner = player1;
+ while (player1.health > 0 && player2.health > 0)
+ {
+ player1.DealDamage();
+ player2.health = player2.health - player1.Power;
+ if (player2.health <= 0)
+ {
+ winner = player1;
+ Console.WriteLine($"Игрок {player1} победил!");
+ return winner;
+ }
+ player2.DealDamage();
+ player1.health = player1.health - player2.Power;
+ if (player2.health <= 0)
+ {
+ winner = player2;
+ Console.WriteLine($"Игрок {player2} победил!");
+ return winner;
+ }
+ }
+ return winner;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPGSaga/Bowman.cs b/CourseApp/RPGSaga/Bowman.cs
new file mode 100644
index 0000000..8fad822
--- /dev/null
+++ b/CourseApp/RPGSaga/Bowman.cs
@@ -0,0 +1,30 @@
+namespace RPGSaga
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
+ public class Bowman : Player
+ {
+ public Bowman()
+ {
+ Name = "Лучник";
+ Maxhealth = 50;
+ Power = 7;
+ }
+
+ public Bowman(string name, double maxhealth, double power)
+ {
+ Name = name;
+ Maxhealth = maxhealth;
+ Power = power;
+ }
+
+ public double Firearrows()
+ {
+ var damage = 0;
+ Console.WriteLine($"{Name} стреляет огненной стрелой");
+ return damage;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPGSaga/CharFactory.cs b/CourseApp/RPGSaga/CharFactory.cs
new file mode 100644
index 0000000..4c86243
--- /dev/null
+++ b/CourseApp/RPGSaga/CharFactory.cs
@@ -0,0 +1,19 @@
+namespace RPGSaga
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
+ public class CharFactory
+ {
+ public Player CreateChar(string type, string name, double maxhealth, double power)
+ {
+ if (type == "Knight")
+ {
+ return new Knight(name, maxhealth, power);
+ }
+
+ return new Bowman(name, maxhealth, power);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPGSaga/GetName.cs b/CourseApp/RPGSaga/GetName.cs
new file mode 100644
index 0000000..818c82b
--- /dev/null
+++ b/CourseApp/RPGSaga/GetName.cs
@@ -0,0 +1,17 @@
+namespace RPGSaga
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
+ public class GetName
+ {
+ private List namelist = new List() { "Артур", "Ланселот", "Гавейн", "Мерлин", "Арагорн", "Боромир", "Гимли", "Леголас", "Робин" };
+
+ public string RandomName()
+ {
+ Random r = new Random();
+ return namelist[r.Next(0, namelist.Count)];
+ }
+ }
+}
diff --git a/CourseApp/RPGSaga/Knight.cs b/CourseApp/RPGSaga/Knight.cs
new file mode 100644
index 0000000..802ec44
--- /dev/null
+++ b/CourseApp/RPGSaga/Knight.cs
@@ -0,0 +1,30 @@
+namespace RPGSaga
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
+ public class Knight : Player
+ {
+ public Knight()
+ {
+ Name = "Рыцарь";
+ Maxhealth = 80;
+ Power = 5;
+ }
+
+ public Knight(string name, double maxhealth, double power)
+ {
+ Name = name;
+ Maxhealth = maxhealth;
+ Power = power;
+ }
+
+ public double VengStrike()
+ {
+ var damage = Power * 1.3;
+ Console.WriteLine($"{Name} наносит {damage} урона");
+ return damage;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPGSaga/MatchMaker.cs b/CourseApp/RPGSaga/MatchMaker.cs
new file mode 100644
index 0000000..9125e7f
--- /dev/null
+++ b/CourseApp/RPGSaga/MatchMaker.cs
@@ -0,0 +1,27 @@
+namespace RPGSaga
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
+ public class MatchMaker
+ {
+ public MatchMaker()
+ {
+ var multiplyheros = new MultiplyChars();
+ heros = multiplyheros.CreateN(N);
+ }
+ private int N = 4;
+ List heros;
+ public void Match()
+ {
+ for (int i = 1; i <= N; i += 2)
+ {
+ heros[i].Greetings();
+ heros[i + 1].Greetings();
+ BattleMaker.Battle(heros[i], heros[i + 1]);
+/* return Battle(heros[i], heros[i + 1]); */
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPGSaga/MultiplyChars.cs b/CourseApp/RPGSaga/MultiplyChars.cs
new file mode 100644
index 0000000..4acfc97
--- /dev/null
+++ b/CourseApp/RPGSaga/MultiplyChars.cs
@@ -0,0 +1,28 @@
+namespace RPGSaga
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
+ public class MultiplyChars
+ {
+ private List heros;
+
+ public List CreateN(int n)
+ {
+ heros = new List();
+ var factory = new CharFactory();
+ for (int i = 1; i <= n; i++)
+ {
+ Random r = new Random();
+ double maxhealth = r.Next(1, 100);
+ double power = r.Next(1, 10);
+ var getname = new GetName();
+ string name = getname.RandomName();
+ heros.Add(factory.CreateChar("Bowman", name, maxhealth, power));
+ }
+
+ return heros;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/RPGSaga/Player.cs b/CourseApp/RPGSaga/Player.cs
new file mode 100644
index 0000000..6605829
--- /dev/null
+++ b/CourseApp/RPGSaga/Player.cs
@@ -0,0 +1,100 @@
+namespace RPGSaga
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
+ public abstract class Player
+ {
+ public string Type;
+ public double health;
+ private double maxhealth;
+ private double power;
+
+ public Player()
+ {
+ Name = "<Безымянный>";
+ Maxhealth = 100;
+ Power = 1;
+ }
+
+ public Player(string name, double maxhealth, double power)
+ {
+ Name = name;
+ Maxhealth = maxhealth;
+ Power = power;
+ }
+ public Player(string type, string name, double maxhealth, double power)
+ {
+ Type = type;
+ Name = name;
+ Maxhealth = maxhealth;
+ Power = power;
+ }
+ public string Name { get; set; }
+
+ public double Maxhealth
+ {
+ get
+ {
+ return maxhealth;
+ }
+
+ set
+ {
+ if (value > 0 && value <= 100)
+ {
+ maxhealth = value;
+ }
+ else
+ {
+ maxhealth = 50;
+ }
+ }
+ }
+
+ public double Health
+ {
+ get
+ {
+ return maxhealth;
+ }
+ }
+
+ public double Power
+ {
+ get
+ {
+ return power;
+ }
+
+ set
+ {
+ if (value > 0 && value <= 10)
+ {
+ power = value;
+ }
+ else
+ {
+ power = 5;
+ }
+ }
+ }
+
+ public void Greetings()
+ {
+ Console.WriteLine($"Игрок {Name} (здоровье {Maxhealth}, атака {Power}) готов к бою!");
+ }
+
+ public double DealDamage()
+ {
+ Console.WriteLine($"{Name} наносит {Power} урона");
+ return Power;
+ }
+
+/* public double GetDamage()
+ {
+ Health = Health - damage
+ } */
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Car.cs b/CourseApp/Vehicles/Car.cs
similarity index 96%
rename from CourseApp/Car.cs
rename to CourseApp/Vehicles/Car.cs
index b78a30c..ae8f695 100644
--- a/CourseApp/Car.cs
+++ b/CourseApp/Vehicles/Car.cs
@@ -1,4 +1,4 @@
-namespace CourseApp
+namespace Vehicles
{
using System;
using System.Collections.Generic;
diff --git a/CourseApp/Copter.cs b/CourseApp/Vehicles/Copter.cs
similarity index 94%
rename from CourseApp/Copter.cs
rename to CourseApp/Vehicles/Copter.cs
index 10da959..38eebb0 100644
--- a/CourseApp/Copter.cs
+++ b/CourseApp/Vehicles/Copter.cs
@@ -1,4 +1,4 @@
-namespace CourseApp
+namespace Vehicles
{
using System;
using System.Collections.Generic;
@@ -11,8 +11,8 @@ public class Copter : Plane
public Copter()
{
Name = "Boing737";
- Speed = 800;
- Height = 8000;
+ Speed = 60;
+ Height = 1000;
Diagonal = 8.4;
}
diff --git a/CourseApp/Phone.cs b/CourseApp/Vehicles/Phone.cs
similarity index 97%
rename from CourseApp/Phone.cs
rename to CourseApp/Vehicles/Phone.cs
index 3260118..ccbc031 100644
--- a/CourseApp/Phone.cs
+++ b/CourseApp/Vehicles/Phone.cs
@@ -1,4 +1,4 @@
-namespace CourseApp
+namespace Vehicles
{
using System;
diff --git a/CourseApp/Plane.cs b/CourseApp/Vehicles/Plane.cs
similarity index 98%
rename from CourseApp/Plane.cs
rename to CourseApp/Vehicles/Plane.cs
index 8fc0bd4..bace5ae 100644
--- a/CourseApp/Plane.cs
+++ b/CourseApp/Vehicles/Plane.cs
@@ -1,4 +1,4 @@
-namespace CourseApp
+namespace Vehicles
{
using System;
using System.Collections.Generic;
diff --git a/CourseApp/Vehicle.cs b/CourseApp/Vehicles/Vehicle.cs
similarity index 97%
rename from CourseApp/Vehicle.cs
rename to CourseApp/Vehicles/Vehicle.cs
index 42e0468..a9caaaa 100644
--- a/CourseApp/Vehicle.cs
+++ b/CourseApp/Vehicles/Vehicle.cs
@@ -1,4 +1,4 @@
-namespace CourseApp
+namespace Vehicles
{
using System;
using System.Collections.Generic;