From bb72f752c7889ba9bc76f2f59052645dc7d41f45 Mon Sep 17 00:00:00 2001 From: CuteDarKy <1705zaq@gmail.com> Date: Thu, 22 Sep 2022 14:22:04 +0300 Subject: [PATCH 01/11] =?UTF-8?q?=D0=9A=D0=BE=D1=87=D0=BD=D0=B5=D0=B2?= =?UTF-8?q?=D0=B0=20=D0=94=D0=B0=D1=80=D0=B8=D0=BD=D0=B0=202/42=20=D0=9A?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CourseApp/Country.cs | 61 ++++++++++++++++++++++++++++++++++++++++++++ CourseApp/Program.cs | 21 ++++++++++++--- 2 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 CourseApp/Country.cs diff --git a/CourseApp/Country.cs b/CourseApp/Country.cs new file mode 100644 index 0000000..13e075e --- /dev/null +++ b/CourseApp/Country.cs @@ -0,0 +1,61 @@ +namespace CourseApp; + +using System; + +public class Country +{ + private double square; + + public Country(string name, string capital, double sq) + { + this.Name = name; + this.Capital = capital; + this.Square = sq; + } + + public Country(string n, string cap) + { + this.Name = n; + this.Capital = cap; + Square = 1000; + } + + public Country(string n) + { + this.Name = n; + Capital = "Moscow"; + Square = 1000; + } + + public string Name { get; set; } + + public string Capital { get; set; } + + public double Square + { + get + { + return square; + } + + set + { + square = value; + } + } + + public void Print() + { + Console.WriteLine($"Название: {Name} Столица: {Capital} Площадь: {Square} км^2"); + } + + public void TheCapital() + { + Console.WriteLine($"The capital of {Name} is {Capital}"); + } + + public void Welcome() + { + Console.WriteLine($"Welcome to the {Name}! \n"); + } +} diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index d6d2c87..bdbe1b6 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -3,10 +3,23 @@ using System; public class Program - { - public static void Main(string[] args) { - Console.WriteLine("Hello World"); + public static void Main(string[] args) + { + Country rus = new Country("Russia", "Moskow", 17000); + Country can = new Country("Canada", "Ottawa"); + Country usa = new Country("USA"); + rus.Print(); + rus.TheCapital(); + rus.Welcome(); + + can.Print(); + can.TheCapital(); + can.Welcome(); + + usa.Print(); + usa.TheCapital(); + usa.Welcome(); } } -} +} \ No newline at end of file From c2666de687d0224bb777d12034fe87e87b25bb41 Mon Sep 17 00:00:00 2001 From: CuteDarKy <1705zaq@gmail.com> Date: Thu, 22 Sep 2022 14:22:34 +0300 Subject: [PATCH 02/11] =?UTF-8?q?=D0=9A=D0=BE=D1=87=D0=BD=D0=B5=D0=B2?= =?UTF-8?q?=D0=B0=20=D0=94=D0=B0=D1=80=D0=B8=D0=BD=D0=B0=202/42=20=D0=A2?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D1=8B=20=D0=BA=20=D0=BA=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D1=81=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CourseApp.Tests/CountryTest.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 CourseApp.Tests/CountryTest.cs diff --git a/CourseApp.Tests/CountryTest.cs b/CourseApp.Tests/CountryTest.cs new file mode 100644 index 0000000..2e00ec8 --- /dev/null +++ b/CourseApp.Tests/CountryTest.cs @@ -0,0 +1,25 @@ +namespace CourseApp.Tests +{ + using Xunit; + + public class CountryTest + { + [Fact] + public void RussiaTest() + { + var rus = new Country("Russia", "Moscow", 17000); + Assert.Equal("Russia", rus.Name); + Assert.Equal("Moscow", rus.Capital); + Assert.Equal(17000, rus.Square); + } + + [Fact] + public void CanadaTest() + { + var can = new Country("Canada", "Ottawa", 10000); + Assert.Equal("Canada", can.Name); + Assert.Equal("Ottawa", can.Capital); + Assert.Equal(10000, can.Square); + } + } +} From c5ec3214fdc1616442ae6dd8e0eebce6b96917d2 Mon Sep 17 00:00:00 2001 From: CuteDarKy <1705zaq@gmail.com> Date: Mon, 24 Oct 2022 23:34:58 +0300 Subject: [PATCH 03/11] =?UTF-8?q?=D0=94=D0=BE=D1=87=D0=B5=D1=80=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D1=8B=20=D0=B8=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=BA=20=D0=BD=D0=B8=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CourseApp.Tests/CountryTest.cs | 111 ++++++++++++++++++++++++++++++++- CourseApp/Canada.cs | 38 +++++++++++ CourseApp/Country.cs | 37 +++++------ CourseApp/Program.cs | 31 ++++----- CourseApp/Russia.cs | 38 +++++++++++ CourseApp/USA.cs | 38 +++++++++++ 6 files changed, 258 insertions(+), 35 deletions(-) create mode 100644 CourseApp/Canada.cs create mode 100644 CourseApp/Russia.cs create mode 100644 CourseApp/USA.cs diff --git a/CourseApp.Tests/CountryTest.cs b/CourseApp.Tests/CountryTest.cs index 2e00ec8..00bec8b 100644 --- a/CourseApp.Tests/CountryTest.cs +++ b/CourseApp.Tests/CountryTest.cs @@ -7,7 +7,7 @@ public class CountryTest [Fact] public void RussiaTest() { - var rus = new Country("Russia", "Moscow", 17000); + var rus = new Russia("Russia", "Moscow", 17000); Assert.Equal("Russia", rus.Name); Assert.Equal("Moscow", rus.Capital); Assert.Equal(17000, rus.Square); @@ -16,10 +16,115 @@ public void RussiaTest() [Fact] public void CanadaTest() { - var can = new Country("Canada", "Ottawa", 10000); + var can = new Canada("Canada", "Ottawa", 10000); Assert.Equal("Canada", can.Name); Assert.Equal("Ottawa", can.Capital); Assert.Equal(10000, can.Square); } + + [Fact] + public void USATest() + { + var usa = new USA("USA", "Washington", 7000); + Assert.Equal("USA", usa.Name); + Assert.Equal("Washington", usa.Capital); + Assert.Equal(7000, usa.Square); + } + + [Fact] + public void RussiaCountryAgeTest() + { + var rus = new Russia("Russia", "Moscow", 17000); + var result = rus.CountryAge(); + Assert.Equal("1159 years ", result); + } + + [Fact] + public void CanadaCountryAgeTest() + { + var can = new Canada("Canada", "Ottawa", 10000); + var result = can.CountryAge(); + Assert.Equal("155 years ", result); + } + + [Fact] + public void USACountryAgeTest() + { + var usa = new USA("USA", "Washington", 7000); + var result = usa.CountryAge(); + Assert.Equal("245 years ", result); + } + + [Fact] + public void RussiaPresidentsNameTest() + { + var rus = new Russia("Russia", "Moscow", 17000); + var result = rus.PresidentsName(); + Assert.Equal("Putin ", result); + } + + [Fact] + public void CanadaPresidentsNameTest() + { + var can = new Canada("Canada", "Ottawa", 10000); + var result = can.PresidentsName(); + Assert.Equal("Carl ", result); + } + + [Fact] + public void USAPresidentsNameTest() + { + var usa = new USA("USA", "Washington", 7000); + var result = usa.PresidentsName(); + Assert.Equal("Biden ", result); + } + + [Fact] + public void RussiaNameOfElementTest() + { + var rus = new Russia("Russia", "Moscow", 17000); + var result = rus.NameOfElement(); + Assert.Equal("Russia: ", result); + } + + [Fact] + public void CanadaNameOfElementTest() + { + var can = new Canada("Canada", "Ottawa", 10000); + var result = can.NameOfElement(); + Assert.Equal("Canada: ", result); + } + + [Fact] + public void USANameOfElementTest() + { + var usa = new USA("USA", "Washington", 7000); + var result = usa.NameOfElement(); + Assert.Equal("USA: ", result); + } + + [Fact] + public void RussiaToStringTest() + { + var rus = new Russia("Russia", "Moscow", 17000); + var result = rus.ToString(); + Assert.Equal("Moscow is a capital of Russia", result); + } + + [Fact] + public void CanadaToStringTest() + { + var can = new Canada("Canada", "Ottawa", 10000); + var result = can.ToString(); + Assert.Equal("Ottawa is a capital of Canada", result); + } + + [Fact] + public void USANameToStringTest() + { + var usa = new USA("USA", "Washington", 7000); + var result = usa.ToString(); + Assert.Equal("Washington is a capital of USA", result); + } } -} +} \ No newline at end of file diff --git a/CourseApp/Canada.cs b/CourseApp/Canada.cs new file mode 100644 index 0000000..f17cc57 --- /dev/null +++ b/CourseApp/Canada.cs @@ -0,0 +1,38 @@ +namespace CourseApp; + +using System; + +public class Canada : Country +{ + private int positionSq = 2; + + public Canada(string name, string capital, double sq) + : base(name, capital, sq) + { + } + + public void PositionSquare() + { + Console.WriteLine($"{Name} in {positionSq} place in terms of area "); + } + + public override string CountryAge() + { + return "155 years "; + } + + public override string PresidentsName() + { + return "Carl "; + } + + public override string NameOfElement() + { + return "Canada: "; + } + + public override string ToString() + { + return $"{Capital} is a capital of {Name}"; + } +} \ No newline at end of file diff --git a/CourseApp/Country.cs b/CourseApp/Country.cs index 13e075e..f6ea1a5 100644 --- a/CourseApp/Country.cs +++ b/CourseApp/Country.cs @@ -2,7 +2,7 @@ using System; -public class Country +public abstract class Country { private double square; @@ -13,20 +13,6 @@ public Country(string name, string capital, double sq) this.Square = sq; } - public Country(string n, string cap) - { - this.Name = n; - this.Capital = cap; - Square = 1000; - } - - public Country(string n) - { - this.Name = n; - Capital = "Moscow"; - Square = 1000; - } - public string Name { get; set; } public string Capital { get; set; } @@ -46,10 +32,10 @@ public double Square public void Print() { - Console.WriteLine($"Название: {Name} Столица: {Capital} Площадь: {Square} км^2"); + Console.Write($"Название: {Name} Столица: {Capital} Площадь: {Square} км^2 "); } - public void TheCapital() + /*public void TheCapital() { Console.WriteLine($"The capital of {Name} is {Capital}"); } @@ -57,5 +43,20 @@ public void TheCapital() public void Welcome() { Console.WriteLine($"Welcome to the {Name}! \n"); + }*/ + + public virtual string CountryAge() + { + return "2000 years"; + } + + public virtual string PresidentsName() + { + return "sss"; + } + + public virtual string NameOfElement() + { + return "3"; } -} +} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index bdbe1b6..3a9ef3a 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,25 +1,28 @@ namespace CourseApp { using System; + using System.Collections.Generic; public class Program + { + public static void Main(string[] args) { - public static void Main(string[] args) - { - Country rus = new Country("Russia", "Moskow", 17000); - Country can = new Country("Canada", "Ottawa"); - Country usa = new Country("USA"); - rus.Print(); - rus.TheCapital(); - rus.Welcome(); + Russia rus = new ("Russia", "Moskow", 17000); + Canada can = new ("Canada", "Ottawa", 9000); + USA usa = new ("USA", "Washington", 7000); - can.Print(); - can.TheCapital(); - can.Welcome(); + var countryList = new List + { + rus, can, usa, + }; - usa.Print(); - usa.TheCapital(); - usa.Welcome(); + foreach (var country in countryList) + { + Console.WriteLine(country.NameOfElement()); + country.Print(); + Console.Write(country.CountryAge()); + Console.WriteLine(country.PresidentsName()); + } } } } \ No newline at end of file diff --git a/CourseApp/Russia.cs b/CourseApp/Russia.cs new file mode 100644 index 0000000..7f2ea5d --- /dev/null +++ b/CourseApp/Russia.cs @@ -0,0 +1,38 @@ +namespace CourseApp; + +using System; + +public class Russia : Country +{ + private int positionSq = 1; + + public Russia(string name, string capital, double sq) + : base(name, capital, sq) + { + } + + public void PositionSquare() + { + Console.WriteLine($"{Name} in {positionSq} place in terms of area "); + } + + public override string CountryAge() + { + return "1159 years "; + } + + public override string PresidentsName() + { + return "Putin "; + } + + public override string NameOfElement() + { + return "Russia: "; + } + + public override string ToString() + { + return $"{Capital} is a capital of {Name}"; + } +} \ No newline at end of file diff --git a/CourseApp/USA.cs b/CourseApp/USA.cs new file mode 100644 index 0000000..cd154e0 --- /dev/null +++ b/CourseApp/USA.cs @@ -0,0 +1,38 @@ +namespace CourseApp; + +using System; + +public class USA : Country +{ + private int positionSq = 3; + + public USA(string name, string capital, double sq) + : base(name, capital, sq) + { + } + + public void PositionSquare() + { + Console.WriteLine($"{Name} in {positionSq} place in terms of area "); + } + + public override string CountryAge() + { + return "245 years "; + } + + public override string PresidentsName() + { + return "Biden "; + } + + public override string NameOfElement() + { + return "USA: "; + } + + public override string ToString() + { + return $"{Capital} is a capital of {Name}"; + } +} \ No newline at end of file From 52bebfc1b8d0c78b1f563951ddb0a7864cb36b65 Mon Sep 17 00:00:00 2001 From: CuteDarKy <1705zaq@gmail.com> Date: Fri, 25 Nov 2022 10:46:35 +0300 Subject: [PATCH 04/11] Tests --- CourseApp/Canada.cs | 7 ------- CourseApp/Country.cs | 10 ---------- CourseApp/Russia.cs | 7 ------- CourseApp/USA.cs | 7 ------- 4 files changed, 31 deletions(-) diff --git a/CourseApp/Canada.cs b/CourseApp/Canada.cs index f17cc57..2bd2c71 100644 --- a/CourseApp/Canada.cs +++ b/CourseApp/Canada.cs @@ -4,18 +4,11 @@ public class Canada : Country { - private int positionSq = 2; - public Canada(string name, string capital, double sq) : base(name, capital, sq) { } - public void PositionSquare() - { - Console.WriteLine($"{Name} in {positionSq} place in terms of area "); - } - public override string CountryAge() { return "155 years "; diff --git a/CourseApp/Country.cs b/CourseApp/Country.cs index f6ea1a5..55b4e8b 100644 --- a/CourseApp/Country.cs +++ b/CourseApp/Country.cs @@ -35,16 +35,6 @@ public void Print() Console.Write($"Название: {Name} Столица: {Capital} Площадь: {Square} км^2 "); } - /*public void TheCapital() - { - Console.WriteLine($"The capital of {Name} is {Capital}"); - } - - public void Welcome() - { - Console.WriteLine($"Welcome to the {Name}! \n"); - }*/ - public virtual string CountryAge() { return "2000 years"; diff --git a/CourseApp/Russia.cs b/CourseApp/Russia.cs index 7f2ea5d..fbfa91b 100644 --- a/CourseApp/Russia.cs +++ b/CourseApp/Russia.cs @@ -4,18 +4,11 @@ public class Russia : Country { - private int positionSq = 1; - public Russia(string name, string capital, double sq) : base(name, capital, sq) { } - public void PositionSquare() - { - Console.WriteLine($"{Name} in {positionSq} place in terms of area "); - } - public override string CountryAge() { return "1159 years "; diff --git a/CourseApp/USA.cs b/CourseApp/USA.cs index cd154e0..3c058f4 100644 --- a/CourseApp/USA.cs +++ b/CourseApp/USA.cs @@ -4,18 +4,11 @@ public class USA : Country { - private int positionSq = 3; - public USA(string name, string capital, double sq) : base(name, capital, sq) { } - public void PositionSquare() - { - Console.WriteLine($"{Name} in {positionSq} place in terms of area "); - } - public override string CountryAge() { return "245 years "; From e83d0a0b805761204cecf5de86fbf6a56e64bf18 Mon Sep 17 00:00:00 2001 From: CuteDarKy <1705zaq@gmail.com> Date: Sat, 14 Jan 2023 06:39:19 +0300 Subject: [PATCH 05/11] rpg --- CourseApp/Program.cs | 17 +-------- CourseApp/RPGsaga/Archer.cs | 37 ++++++++++++++++++ CourseApp/RPGsaga/Game.cs | 74 ++++++++++++++++++++++++++++++++++++ CourseApp/RPGsaga/Logger.cs | 12 ++++++ CourseApp/RPGsaga/Paladin.cs | 35 +++++++++++++++++ CourseApp/RPGsaga/Player.cs | 35 +++++++++++++++++ CourseApp/RPGsaga/Wizard.cs | 33 ++++++++++++++++ Game.cs | 0 8 files changed, 227 insertions(+), 16 deletions(-) create mode 100644 CourseApp/RPGsaga/Archer.cs create mode 100644 CourseApp/RPGsaga/Game.cs create mode 100644 CourseApp/RPGsaga/Logger.cs create mode 100644 CourseApp/RPGsaga/Paladin.cs create mode 100644 CourseApp/RPGsaga/Player.cs create mode 100644 CourseApp/RPGsaga/Wizard.cs create mode 100644 Game.cs diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 3a9ef3a..7a11050 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -7,22 +7,7 @@ public class Program { public static void Main(string[] args) { - Russia rus = new ("Russia", "Moskow", 17000); - Canada can = new ("Canada", "Ottawa", 9000); - USA usa = new ("USA", "Washington", 7000); - - var countryList = new List - { - rus, can, usa, - }; - - foreach (var country in countryList) - { - Console.WriteLine(country.NameOfElement()); - country.Print(); - Console.Write(country.CountryAge()); - Console.WriteLine(country.PresidentsName()); - } + Game.Start(); } } } \ No newline at end of file diff --git a/CourseApp/RPGsaga/Archer.cs b/CourseApp/RPGsaga/Archer.cs new file mode 100644 index 0000000..8128a16 --- /dev/null +++ b/CourseApp/RPGsaga/Archer.cs @@ -0,0 +1,37 @@ +namespace CourseApp.RPGsaga + +using System; +using System.Collections.Generic; + +public class Archer : Player +{ + public Archer(int health, int force, string name, string abilityName) + : base(health, force, name, "Огненные стрелы") + { + } + + public bool AbilityUse = false; + + public string ToString() + { + return "(Лучник) " + Name; + } + + public void Use() + { + if (AbilityUse == false) + { + AbilityUse = true; + } + } + + public int Attack() + { + if (AbilityUse == true) + { + return force += 2; + } + else + return force; + } +} diff --git a/CourseApp/RPGsaga/Game.cs b/CourseApp/RPGsaga/Game.cs new file mode 100644 index 0000000..4afab62 --- /dev/null +++ b/CourseApp/RPGsaga/Game.cs @@ -0,0 +1,74 @@ +namespace CourseApp.RPGsaga + +using System; +using System.Collections.Generic; +using System.Linq; + +public class Game +{ + public void Start() + { + Console.WriteLine("Введите количество игроков (число должно быть чётным):"); + int players = Convert.ToInt32(Console.ReadLine()); + if (players <= 1) + { + Console.WriteLine("Число игроков не может быть меньше 2"); + } + else if (players % 2 != 0) + { + Console.WriteLine("Число игроков должно быть чётным!"); + } + + List playerList = PlayerListGenerator(players); + } + + private static void Round(List playerList) + { + for (int i = 0; i < playerList.Count / 2; i++) + { + Player[] Members = { playerList[i * 2], playerList[(i * 2) + 1] }; + + for (int i = 0; ; i++) + { + + } + + for (int i = 1; i < playerList.Count; i++) + { + playerList.RemoveAt(i); + } + } + } + + private static List PlayerListGenerator(int counter) + { + List playerList = new List(); + for (int i = 0; i < counter; i++) + { + playerList.Add(PlayerGenerator()); + } + + return playerList; + } + + private static Player PlayerGenerator() + { + string[] names = { "Даламар", "Володар", "Геральд", "Вельгеброрд", "Глэстин", "Винхелт", "Грендольф", "Рэйкон", "Шапалаум", "Зорро", "Кьярос", "Йотенхел", "Кузко" }; + Random rnd = new Random(); + int health = (int)rnd.NextInt64(1, 100); + int force = (int)rnd.NextInt64(1, 100); + int chouse = (int)rnd.NextInt64(0, 3); + switch (chouse) + { + case 0: + return new Paladin(health, force, names[rnd.Next(names.Length)]); + case 1: + return new Wizard(health, force, names[rnd.Next(names.Length)]); + case 2: + return new Archer(health, force, names[rnd.Next(names.Length)]); + default: + return new Paladin(health, force, names[rnd.Next(names.Length)]); + } + } + +} \ No newline at end of file diff --git a/CourseApp/RPGsaga/Logger.cs b/CourseApp/RPGsaga/Logger.cs new file mode 100644 index 0000000..59aa356 --- /dev/null +++ b/CourseApp/RPGsaga/Logger.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CourseApp.RPGsaga +{ + internal class Logger + { + } +} diff --git a/CourseApp/RPGsaga/Paladin.cs b/CourseApp/RPGsaga/Paladin.cs new file mode 100644 index 0000000..1f4b950 --- /dev/null +++ b/CourseApp/RPGsaga/Paladin.cs @@ -0,0 +1,35 @@ +namespace CourseApp.RPGsaga + +using System; +using System.Collections.Generic; + +public class Paladin : Player +{ + public Paladin(int health, int force, string name, string abilityName) + : base(health, force, name, "Удар возмездия") + { + } + + public bool AbilityUse = false; + + + public string ToString() + { + return "(Паладин) " + Name; + } + public void Use() + { + if (AbilityUse == false) + { + AbilityUse = true; + } + } + + public int Attack() + { + if (AbilityUse == true) + { + return force *= 0.3; + } + } +} \ No newline at end of file diff --git a/CourseApp/RPGsaga/Player.cs b/CourseApp/RPGsaga/Player.cs new file mode 100644 index 0000000..e1d8e30 --- /dev/null +++ b/CourseApp/RPGsaga/Player.cs @@ -0,0 +1,35 @@ +namespace CourseApp.RPGsaga + +using System; +using System.Collections.Generic; + +public abstract class Player +{ + public Player(int health, int force, string name, string abilityName) + { + this.Force = force; + this.Health = health; + this.Name = name; + this.AbilityName = abilityName; + } + + public double Force { get; set; } + + public int Health { get; set; } + + public string Name { get; set; } + + public string AbilityName { get; set; } + + public bool Death() + { + if (Health == 0) + { + return true; + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/CourseApp/RPGsaga/Wizard.cs b/CourseApp/RPGsaga/Wizard.cs new file mode 100644 index 0000000..dfa0f6d --- /dev/null +++ b/CourseApp/RPGsaga/Wizard.cs @@ -0,0 +1,33 @@ +namespace CourseApp.RPGsaga + +using System; +using System.Collections.Generic; + +public class Wizard : Player +{ + public Wizard(int health, int force, string name, string abilityName) + : base(health, force, name, "Удар возмездия") + { + } + + public bool AbilityUse = false; + public string ToString() + { + return "(Волшебник) " + Name; + } + public void Use() + { + if (AbilityUse == false) + { + AbilityUse = true; + } + } + + public int Attack() + { + if (AbilityUse == true) + { + damage = 0; + } + } +} \ No newline at end of file diff --git a/Game.cs b/Game.cs new file mode 100644 index 0000000..e69de29 From 63e3be2cdec91ffbda85a808a4d58301c792cd05 Mon Sep 17 00:00:00 2001 From: CuteDarKy <92202575+CuteDarKy@users.noreply.github.com> Date: Sat, 14 Jan 2023 12:04:04 +0300 Subject: [PATCH 06/11] Update Game.cs --- CourseApp/RPGsaga/Game.cs | 115 +++++++++++++++++++++++++++----------- 1 file changed, 82 insertions(+), 33 deletions(-) diff --git a/CourseApp/RPGsaga/Game.cs b/CourseApp/RPGsaga/Game.cs index 4afab62..70805a5 100644 --- a/CourseApp/RPGsaga/Game.cs +++ b/CourseApp/RPGsaga/Game.cs @@ -1,4 +1,4 @@ -namespace CourseApp.RPGsaga +namespace CourseApp.RPGsaga; using System; using System.Collections.Generic; @@ -6,69 +6,118 @@ public class Game { - public void Start() + public void Play() { - Console.WriteLine("Введите количество игроков (число должно быть чётным):"); - int players = Convert.ToInt32(Console.ReadLine()); - if (players <= 1) - { - Console.WriteLine("Число игроков не может быть меньше 2"); - } - else if (players % 2 != 0) - { - Console.WriteLine("Число игроков должно быть чётным!"); - } - + EnterNumberOfPlayers(); List playerList = PlayerListGenerator(players); + List winnerList = new List(); + Player winner = new Player(); + Logger.Winner(Round(List playerList)); } private static void Round(List playerList) - { + { for (int i = 0; i < playerList.Count / 2; i++) { + if (playerList.Count == null) + { + break; + } + Logger.Round(i); Player[] Members = { playerList[i * 2], playerList[(i * 2) + 1] }; - - for (int i = 0; ; i++) + Logger.VS(Player[] Members); + winnerList.Add(Figth(Members)); + } + for (int i = 1; i < playerList.Count; i++) + { + playerList.RemoveAt(i); + } + for (int i = 0; i < winnerList.Count / 2; i++) + { + if (winerList.Count == 1) { - + return winner = winerList[i * 2]; + break; } + Logger.Round(i); + Player[] Members = { winnerList[i * 2], winnerList[(i * 2) + 1] }; + Logger.VS(Player[] Members); + winnerList.Add(Figth(Members)); + } + for (int i = 1; i < winnerList.Count-1; i++) + { + winnerList.RemoveAt(i); + } + } - for (int i = 1; i < playerList.Count; i++) + private static Fight(Player[] Members) + { + for (int i = 0; ; i++) + { + + Members[(i * 2) + 1].NewHealth(Members[i * 2].Damage()); + Logger.Figth(Members[i * 2].Damage()); + if (Members[(i * 2) + 1].Death()) { - playerList.RemoveAt(i); + Logger.Death(Player[] Members); + return Members[i * 2]; + break; } - } - } + else + { + swap = Members[i * 2]; + Members[(i * 2) + 1] = Members[i * 2]; + Members[i * 2] = swap; + } + } + } private static List PlayerListGenerator(int counter) { List playerList = new List(); for (int i = 0; i < counter; i++) { - playerList.Add(PlayerGenerator()); + Random rnd = new Random(); + int health = (int)rnd.NextInt64(1, 100); + int force = (int)rnd.NextInt64(1, 100); + int chouse = (int)rnd.NextInt64(0, 3); + string[] names = { "Даламар", "Володар", "Геральд", "Вельгеброрд", "Глэстин", "Винхелт", "Грендольф", "Рэйкон", "Шапалаум", "Зорро", "Кьярос", "Йотенхел", "Кузко" }; + playerList.Add(PlayerGenerator(health, force, chouse, names[rnd.Next(names.Length)); } return playerList; } - private static Player PlayerGenerator() + private static Player PlayerGenerator(int health, int forceb, int chouse, string name) { - string[] names = { "Даламар", "Володар", "Геральд", "Вельгеброрд", "Глэстин", "Винхелт", "Грендольф", "Рэйкон", "Шапалаум", "Зорро", "Кьярос", "Йотенхел", "Кузко" }; - Random rnd = new Random(); - int health = (int)rnd.NextInt64(1, 100); - int force = (int)rnd.NextInt64(1, 100); - int chouse = (int)rnd.NextInt64(0, 3); switch (chouse) { case 0: - return new Paladin(health, force, names[rnd.Next(names.Length)]); + return new Paladin(health, force, name); case 1: - return new Wizard(health, force, names[rnd.Next(names.Length)]); + return new Wizard(health, force, name); case 2: - return new Archer(health, force, names[rnd.Next(names.Length)]); + return new Archer(health, force, name); default: - return new Paladin(health, force, names[rnd.Next(names.Length)]); + return new Paladin(health, force, name); } } -} \ No newline at end of file + private void EnterNumberOfPlayers() + { + Console.WriteLine("Введите количество игроков (число должно быть чётным):"); + int players = Convert.ToInt32(Console.ReadLine()); + if (players <= 1) + { + Console.WriteLine("Число игроков не может быть меньше 2"); + } + else if (players % 2 != 0) + { + Console.WriteLine("Число игроков должно быть чётным"); + } + } + public int Summa(int a, int b) + { + return a+b; + } +} From 1f27b776d174d18ec5bc0202046ad9ec3083e1ac Mon Sep 17 00:00:00 2001 From: CuteDarKy <92202575+CuteDarKy@users.noreply.github.com> Date: Sat, 14 Jan 2023 12:04:44 +0300 Subject: [PATCH 07/11] Update Player.cs --- CourseApp/RPGsaga/Player.cs | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/CourseApp/RPGsaga/Player.cs b/CourseApp/RPGsaga/Player.cs index e1d8e30..7323ea9 100644 --- a/CourseApp/RPGsaga/Player.cs +++ b/CourseApp/RPGsaga/Player.cs @@ -1,4 +1,4 @@ -namespace CourseApp.RPGsaga +namespace CourseApp.RPGsaga; using System; using System.Collections.Generic; @@ -21,9 +21,39 @@ public Player(int health, int force, string name, string abilityName) public string AbilityName { get; set; } + public virtual string ToString() + { + return "(Герой) " + Name; + } + + public bool AbilityUse = false; + + public virtual void Ability(string AbilityUse) + { + Random rnd = new Random(); + int prob = (int)rnd.NextInt64(1, 10); + switch (prob) + { + case 1: + return AbilityUse = true; + default: + return AbilityUse = false; + } + } + + public void NewHealth(int damage) + { + health -= damage; + } + + public int Damage() + { + return force; + } + public bool Death() { - if (Health == 0) + if (health == 0) { return true; } @@ -32,4 +62,4 @@ public bool Death() return false; } } -} \ No newline at end of file +} From 68d763df2a5f6754f999190e0a749f94f260efa4 Mon Sep 17 00:00:00 2001 From: CuteDarKy <92202575+CuteDarKy@users.noreply.github.com> Date: Sat, 14 Jan 2023 12:05:07 +0300 Subject: [PATCH 08/11] Update Wizard.cs --- CourseApp/RPGsaga/Wizard.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/CourseApp/RPGsaga/Wizard.cs b/CourseApp/RPGsaga/Wizard.cs index dfa0f6d..69eefde 100644 --- a/CourseApp/RPGsaga/Wizard.cs +++ b/CourseApp/RPGsaga/Wizard.cs @@ -1,4 +1,4 @@ -namespace CourseApp.RPGsaga +namespace CourseApp.RPGsaga; using System; using System.Collections.Generic; @@ -15,19 +15,16 @@ public string ToString() { return "(Волшебник) " + Name; } - public void Use() - { - if (AbilityUse == false) - { - AbilityUse = true; - } - } - public int Attack() + public override int Ability(string AbilityUse) { - if (AbilityUse == true) + Random rnd = new Random(); + int prob = (int)rnd.NextInt64(1, 10); + switch (prob) { - damage = 0; + case 1: + return AbilityUse = true; + default: + return AbilityUse = false; } } -} \ No newline at end of file From ea0d15f3a59bd84ccb27e562fd8dbb57b9616877 Mon Sep 17 00:00:00 2001 From: CuteDarKy <92202575+CuteDarKy@users.noreply.github.com> Date: Sat, 14 Jan 2023 12:05:43 +0300 Subject: [PATCH 09/11] Update Paladin.cs --- CourseApp/RPGsaga/Paladin.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/CourseApp/RPGsaga/Paladin.cs b/CourseApp/RPGsaga/Paladin.cs index 1f4b950..eeab427 100644 --- a/CourseApp/RPGsaga/Paladin.cs +++ b/CourseApp/RPGsaga/Paladin.cs @@ -1,4 +1,4 @@ -namespace CourseApp.RPGsaga +namespace CourseApp.RPGsaga; using System; using System.Collections.Generic; @@ -17,19 +17,17 @@ public string ToString() { return "(Паладин) " + Name; } - public void Use() - { - if (AbilityUse == false) - { - AbilityUse = true; - } - } - public int Attack() + public override int Ability(string AbilityUse) { - if (AbilityUse == true) + Random rnd = new Random(); + int prob = (int)rnd.NextInt64(1, 10); + switch (prob) { - return force *= 0.3; + case 1: + return AbilityUse = true; + default: + return AbilityUse = false; } } -} \ No newline at end of file +} From fdb657f7e5dfadfdd5e52583cabda1c126df215e Mon Sep 17 00:00:00 2001 From: CuteDarKy <92202575+CuteDarKy@users.noreply.github.com> Date: Sat, 14 Jan 2023 12:06:04 +0300 Subject: [PATCH 10/11] Update Archer.cs --- CourseApp/RPGsaga/Archer.cs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/CourseApp/RPGsaga/Archer.cs b/CourseApp/RPGsaga/Archer.cs index 8128a16..2856f94 100644 --- a/CourseApp/RPGsaga/Archer.cs +++ b/CourseApp/RPGsaga/Archer.cs @@ -1,4 +1,4 @@ -namespace CourseApp.RPGsaga +namespace CourseApp.RPGsaga; using System; using System.Collections.Generic; @@ -12,26 +12,21 @@ public Archer(int health, int force, string name, string abilityName) public bool AbilityUse = false; - public string ToString() + public override string ToString() { return "(Лучник) " + Name; } - public void Use() + public override int Ability(string AbilityUse) { - if (AbilityUse == false) + Random rnd = new Random(); + int prob = (int)rnd.NextInt64(1, 10); + switch (prob) { - AbilityUse = true; + case 1: + return AbilityUse = true; + default: + return AbilityUse = false; } } - - public int Attack() - { - if (AbilityUse == true) - { - return force += 2; - } - else - return force; - } } From dcd2309987ab85344725575dd0511a83d47d1383 Mon Sep 17 00:00:00 2001 From: CuteDarKy <92202575+CuteDarKy@users.noreply.github.com> Date: Sat, 14 Jan 2023 12:06:25 +0300 Subject: [PATCH 11/11] Update Logger.cs --- CourseApp/RPGsaga/Logger.cs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/CourseApp/RPGsaga/Logger.cs b/CourseApp/RPGsaga/Logger.cs index 59aa356..e027b0f 100644 --- a/CourseApp/RPGsaga/Logger.cs +++ b/CourseApp/RPGsaga/Logger.cs @@ -1,12 +1,34 @@ -using System; +namespace CourseApp.RPGsaga; + +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CourseApp.RPGsaga +public static class Logger { - internal class Logger + public static void Round(int round) + { + Console.WriteLine("Кон " + round); + } + + public static void VS(Player[] Members) + { + Console.WriteLine($"{Members[(i * 2) + 1].ToString()} vs {Members[i * 2].ToString()}"); + } + + public static void Fight(Player[] Members) + { + Console.WriteLine($"{Members[(i * 2) + 1].ToString()} наносит урон {Members[i * 2].Damage()} {Members[i * 2].ToString()}"); + } + + public static void Death(Player[] Members) + { + Console.WriteLine($"{Members[(i * 2) + 1].ToString()} погибает"); + } + public static void Winner() { + Console.WriteLine($"{Members[(i * 2) + 1].ToString()} погибает"); } }