From 12fd41aa27a98d0f7931c5f159cfee24cb08cd3d Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Sat, 22 Oct 2022 15:23:02 +0300 Subject: [PATCH 01/11] RPG --- CourseApp/Archer.cs | 10 ++++++++++ CourseApp/Game.cs | 6 ++++++ CourseApp/Hero.cs | 18 ++++++++++++++++++ CourseApp/Knight.cs | 10 ++++++++++ CourseApp/Magician.cs | 10 ++++++++++ CourseApp/Program.cs | 3 ++- 6 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 CourseApp/Archer.cs create mode 100644 CourseApp/Game.cs create mode 100644 CourseApp/Hero.cs create mode 100644 CourseApp/Knight.cs create mode 100644 CourseApp/Magician.cs diff --git a/CourseApp/Archer.cs b/CourseApp/Archer.cs new file mode 100644 index 0000000..17db2b8 --- /dev/null +++ b/CourseApp/Archer.cs @@ -0,0 +1,10 @@ +namespace CourseApp +{ + public class Archer : Hero + { + public Archer(int health, int power, string name) + : base(health, power, name) + { + } + } +} diff --git a/CourseApp/Game.cs b/CourseApp/Game.cs new file mode 100644 index 0000000..f040e85 --- /dev/null +++ b/CourseApp/Game.cs @@ -0,0 +1,6 @@ +namespace CourseApp +{ + public class Game + { + } +} diff --git a/CourseApp/Hero.cs b/CourseApp/Hero.cs new file mode 100644 index 0000000..baec35f --- /dev/null +++ b/CourseApp/Hero.cs @@ -0,0 +1,18 @@ +namespace CourseApp +{ + public abstract class Hero + { + public Hero(int health, int power, string name) + { + Health = health; + Power = power; + Name = name; + } + + public int Health { get; } + + public int Power { get; } + + public string Name { get; } + } +} diff --git a/CourseApp/Knight.cs b/CourseApp/Knight.cs new file mode 100644 index 0000000..287f185 --- /dev/null +++ b/CourseApp/Knight.cs @@ -0,0 +1,10 @@ +namespace CourseApp +{ + public class Knight : Hero + { + public Knight(int health, int power, string name) + : base(health, power, name) + { + } + } +} diff --git a/CourseApp/Magician.cs b/CourseApp/Magician.cs new file mode 100644 index 0000000..4c2b342 --- /dev/null +++ b/CourseApp/Magician.cs @@ -0,0 +1,10 @@ +namespace CourseApp +{ + public class Magician : Hero + { + public Magician(int health, int power, string name) + : base(health, power, name) + { + } + } +} diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 6a4b38d..411295a 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,6 +1,7 @@ -namespace AutoApp +namespace CourseApp { using System; + using AutoApp; public class Program { From 7fb4951274c4f1b70d830fb794b06e4f6a79ba9b Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Thu, 10 Nov 2022 19:56:57 +0300 Subject: [PATCH 02/11] OOP --- CourseApp.Tests/{Auto_Tests.cs => AutoTests.cs} | 2 +- CourseApp/Ability.cs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) rename CourseApp.Tests/{Auto_Tests.cs => AutoTests.cs} (98%) create mode 100644 CourseApp/Ability.cs diff --git a/CourseApp.Tests/Auto_Tests.cs b/CourseApp.Tests/AutoTests.cs similarity index 98% rename from CourseApp.Tests/Auto_Tests.cs rename to CourseApp.Tests/AutoTests.cs index 5491c3e..93fcaf7 100644 --- a/CourseApp.Tests/Auto_Tests.cs +++ b/CourseApp.Tests/AutoTests.cs @@ -3,7 +3,7 @@ using AutoApp; using Xunit; - public class Auto_Tests + public class AutoTests { [Fact] public void Test1() diff --git a/CourseApp/Ability.cs b/CourseApp/Ability.cs new file mode 100644 index 0000000..f55ff48 --- /dev/null +++ b/CourseApp/Ability.cs @@ -0,0 +1,6 @@ +namespace CourseApp +{ + public class Ability + { + } +} From 9fd556f9465e264132a393283263b8c655db1ff0 Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Fri, 25 Nov 2022 09:36:05 +0300 Subject: [PATCH 03/11] RPG_Saga --- CourseApp/Ability.cs | 6 ---- CourseApp/Archer.cs | 5 +++ CourseApp/Game.cs | 25 +++++++++++++ CourseApp/Hero.cs | 19 ++++++++-- CourseApp/Knight.cs | 6 ++++ CourseApp/Magician.cs | 5 +++ CourseApp/Program.cs | 83 ++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 139 insertions(+), 10 deletions(-) delete mode 100644 CourseApp/Ability.cs diff --git a/CourseApp/Ability.cs b/CourseApp/Ability.cs deleted file mode 100644 index f55ff48..0000000 --- a/CourseApp/Ability.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CourseApp -{ - public class Ability - { - } -} diff --git a/CourseApp/Archer.cs b/CourseApp/Archer.cs index 17db2b8..70d2ec5 100644 --- a/CourseApp/Archer.cs +++ b/CourseApp/Archer.cs @@ -6,5 +6,10 @@ public Archer(int health, int power, string name) : base(health, power, name) { } + + public override string AbilityDisplay() + { + return $"{Name} использует (Огненные стрелы) и противник теряет за каждый ход 2 единицы жизни"; + } } } diff --git a/CourseApp/Game.cs b/CourseApp/Game.cs index f040e85..0bb21ec 100644 --- a/CourseApp/Game.cs +++ b/CourseApp/Game.cs @@ -2,5 +2,30 @@ { public class Game { + public Game() + : this(100, 75, "Артур", "Удар возмездия") + { + } + + public Game(int health, int power, string name, string ability) + { + Health = health; + Power = power; + Name = name; + Ability = ability; + } + + public int Health { get; set; } + + public int Power { get; set; } + + public string Name { get; set; } + + public string Ability { get; set; } + + public string Print() + { + return $"Здоровье: {Health} Сила: {Power} Имя: {Name} Способность: {Ability}"; + } } } diff --git a/CourseApp/Hero.cs b/CourseApp/Hero.cs index baec35f..8e3d68d 100644 --- a/CourseApp/Hero.cs +++ b/CourseApp/Hero.cs @@ -9,10 +9,23 @@ public Hero(int health, int power, string name) Name = name; } - public int Health { get; } + public int Health { get; set; } - public int Power { get; } + public int Power { get; set; } - public string Name { get; } + public string Name { get; set; } + + public abstract string AbilityDisplay(); + + public string Action() + { + return $"{Name} наносит урон {Power} противнику"; + } + + public string Damage() + { + Health = Health - Power; + return $"{Name} получил урон {Power} и теряет {Health - Power} единицы жизни"; + } } } diff --git a/CourseApp/Knight.cs b/CourseApp/Knight.cs index 287f185..9935b6a 100644 --- a/CourseApp/Knight.cs +++ b/CourseApp/Knight.cs @@ -6,5 +6,11 @@ public Knight(int health, int power, string name) : base(health, power, name) { } + + public override string AbilityDisplay() + { + Power = Power + 30; + return $"{Name} использует (Удар возмездия) и наносит урон {Power}"; + } } } diff --git a/CourseApp/Magician.cs b/CourseApp/Magician.cs index 4c2b342..9d343cf 100644 --- a/CourseApp/Magician.cs +++ b/CourseApp/Magician.cs @@ -6,5 +6,10 @@ public Magician(int health, int power, string name) : base(health, power, name) { } + + public override string AbilityDisplay() + { + return $"{Name} использует (Заворожение) и противник пропускает ход"; + } } } diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 411295a..465551c 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -24,13 +24,94 @@ public static void Main(string[] args) Automobile minibus = new Minibus("Маршрутка"); Automobile bus = new Bus("Автобус"); Automobile trolleybus = new Trolleybus("Троллейбус"); - Console.WriteLine("--------------------------"); + Console.WriteLine(" "); Console.WriteLine(minibus.Display()); minibus.Move(); Console.WriteLine(bus.Display()); bus.Move(); Console.WriteLine(trolleybus.Display()); trolleybus.Move(); + Console.WriteLine("-------------------------------------------------"); + + Game saga = new Game(); + saga.Print(); + + /*Game rpg = new Game(100, 35, "(Рыцарь) Артур", "Удар возмездия"); + int characterHealth = rpg.Health; + int characterPower = rpg.Power; + string characterName = rpg.Name; + string characterAbility = rpg.Ability; + Console.WriteLine($"Здоровье: {characterHealth} Сила: {characterPower} Имя: {characterName} Способность: {characterAbility}"); + + rpg.Health = 50; + rpg.Power = 20; + rpg.Name = "(Рыцарь) Ричард"; + rpg.Ability = "Удар возмездия"; + Console.WriteLine(rpg.Print());*/ + + Hero knight1 = new Knight(50, 20, "(Рыцарь) Ричард"); + Hero knight2 = new Knight(50, 20, "(Рыцарь) Зигфрид"); + Hero archer = new Archer(50, 20, "(Лучник) Леголас"); + Hero magician = new Magician(50, 20, "(Маг) Дамблдор"); + + Console.WriteLine("Кон 1."); + Console.WriteLine("(Рыцарь) Ричард vs (Лучник) Леголас"); + while ((knight1.Health > 0) && (archer.Health > 0)) + { + Console.WriteLine(knight1.Action()); + archer.Damage(); + if (archer.Health <= 0) + { + break; + } + + Console.WriteLine(archer.Action()); + knight1.Damage(); + if (knight1.Health <= 0) + { + break; + } + } + + if (knight1.Health <= 0) + { + Console.WriteLine("(Рыцарь) Ричард погибает"); + } + else if (archer.Health <= 0) + { + Console.WriteLine("(Лучник) Леголас погибает"); + } + + Console.WriteLine(" "); + Console.WriteLine("(Рыцарь) Зигрфрид vs (Маг) Дамблдор"); + while ((knight2.Health > 0) && (magician.Health > 0)) + { + Console.WriteLine(magician.Action()); + knight2.Damage(); + if (knight2.Health <= 0) + { + break; + } + + Console.WriteLine(knight2.Action()); + magician.Damage(); + if (magician.Health <= 0) + { + break; + } + } + + if (knight2.Health <= 0) + { + Console.WriteLine("(Рыцарь) Зигфрид погибает"); + } + else if (magician.Health <= 0) + { + Console.WriteLine("(Маг) Дамблдор погибает"); + } + + Console.WriteLine(" "); + Console.WriteLine("Кон 2."); } } } From 3247c721b3434d08815c16b81314454231f03646 Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Sat, 26 Nov 2022 15:25:56 +0300 Subject: [PATCH 04/11] RPG_Saga --- CourseApp/Logger.cs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 CourseApp/Logger.cs diff --git a/CourseApp/Logger.cs b/CourseApp/Logger.cs new file mode 100644 index 0000000..bca11b1 --- /dev/null +++ b/CourseApp/Logger.cs @@ -0,0 +1,6 @@ +namespace CourseApp +{ + public class Logger + { + } +} From 02903f7877e3de53b837d42e6402c31fb0cd6bf7 Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Sat, 26 Nov 2022 15:31:28 +0300 Subject: [PATCH 05/11] RPG_Saga --- CourseApp/Archer.cs | 2 +- CourseApp/Hero.cs | 19 ++++++++++++++++++- CourseApp/Magician.cs | 2 +- CourseApp/Program.cs | 40 ++++++++++++++++++++++++++++++++++------ 4 files changed, 54 insertions(+), 9 deletions(-) diff --git a/CourseApp/Archer.cs b/CourseApp/Archer.cs index 70d2ec5..37c6a55 100644 --- a/CourseApp/Archer.cs +++ b/CourseApp/Archer.cs @@ -9,7 +9,7 @@ public Archer(int health, int power, string name) public override string AbilityDisplay() { - return $"{Name} использует (Огненные стрелы) и противник теряет за каждый ход 2 единицы жизни"; + return $"{Name} использует (Огненные стрелы)"; } } } diff --git a/CourseApp/Hero.cs b/CourseApp/Hero.cs index 8e3d68d..c6df53f 100644 --- a/CourseApp/Hero.cs +++ b/CourseApp/Hero.cs @@ -25,7 +25,24 @@ public string Action() public string Damage() { Health = Health - Power; - return $"{Name} получил урон {Power} и теряет {Health - Power} единицы жизни"; + return $"{Name} получил урон {Power} и теряет {Health} единицы жизни"; + } + + public string KnightAbiltiy() + { + Health = Health - (Power + 30); + return $"{Name} теряет {Health} единицы жизни"; + } + + public string ArcherAbility() + { + Health = Health - 2; + return $"{Name} теряет {Health - 2} единицы жизни"; + } + + public string MagicianAbility() + { + return $"{Name} пропускает ход"; } } } diff --git a/CourseApp/Magician.cs b/CourseApp/Magician.cs index 9d343cf..8241369 100644 --- a/CourseApp/Magician.cs +++ b/CourseApp/Magician.cs @@ -9,7 +9,7 @@ public Magician(int health, int power, string name) public override string AbilityDisplay() { - return $"{Name} использует (Заворожение) и противник пропускает ход"; + return $"{Name} использует (Заворожение)"; } } } diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 465551c..b1ed1e4 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -58,16 +58,16 @@ public static void Main(string[] args) Console.WriteLine("(Рыцарь) Ричард vs (Лучник) Леголас"); while ((knight1.Health > 0) && (archer.Health > 0)) { - Console.WriteLine(knight1.Action()); - archer.Damage(); - if (archer.Health <= 0) + Console.WriteLine(archer.Action()); + Console.WriteLine(knight1.Damage()); + if (knight1.Health <= 0) { break; } - Console.WriteLine(archer.Action()); - knight1.Damage(); - if (knight1.Health <= 0) + Console.WriteLine(knight1.AbilityDisplay()); + Console.WriteLine(archer.KnightAbiltiy()); + if (archer.Health <= 0) { break; } @@ -112,6 +112,34 @@ public static void Main(string[] args) Console.WriteLine(" "); Console.WriteLine("Кон 2."); + Console.WriteLine("(Рыцарь) Ричард vs (Маг) Дамблдор"); + while ((knight1.Health > 0) && (magician.Health > 0)) + { + Console.WriteLine(magician.AbilityDisplay()); + Console.WriteLine(knight1.MagicianAbility()); + Console.WriteLine(magician.Action()); + knight1.Damage(); + if (knight1.Health <= 0) + { + break; + } + + Console.WriteLine(knight1.Action()); + magician.Damage(); + if (magician.Health <= 0) + { + break; + } + } + + if (knight1.Health <= 0) + { + Console.WriteLine("(Рыцарь) Ричард погибает"); + } + else if (magician.Health <= 0) + { + Console.WriteLine("(Маг) Дамблдор погибает"); + } } } } From ab3509ef80dc8d1cd9f62ceebbddf6b1b5425b68 Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Sat, 14 Jan 2023 08:30:49 +0300 Subject: [PATCH 06/11] RPG_Saga --- CourseApp.Tests/RPGsagaTest.cs | 82 +++++++++++++++++++++++++ CourseApp/Archer.cs | 15 ----- CourseApp/Knight.cs | 16 ----- CourseApp/Logger.cs | 6 -- CourseApp/Magician.cs | 15 ----- CourseApp/Program.cs | 102 +++----------------------------- CourseApp/RPGsaga/Archer.cs | 19 ++++++ CourseApp/{ => RPGsaga}/Game.cs | 26 +++++++- CourseApp/{ => RPGsaga}/Hero.cs | 35 ++++++----- CourseApp/RPGsaga/Knight.cs | 16 +++++ CourseApp/RPGsaga/Logger.cs | 12 ++++ CourseApp/RPGsaga/Magician.cs | 18 ++++++ 12 files changed, 196 insertions(+), 166 deletions(-) create mode 100644 CourseApp.Tests/RPGsagaTest.cs delete mode 100644 CourseApp/Archer.cs delete mode 100644 CourseApp/Knight.cs delete mode 100644 CourseApp/Logger.cs delete mode 100644 CourseApp/Magician.cs create mode 100644 CourseApp/RPGsaga/Archer.cs rename CourseApp/{ => RPGsaga}/Game.cs (51%) rename CourseApp/{ => RPGsaga}/Hero.cs (57%) create mode 100644 CourseApp/RPGsaga/Knight.cs create mode 100644 CourseApp/RPGsaga/Logger.cs create mode 100644 CourseApp/RPGsaga/Magician.cs diff --git a/CourseApp.Tests/RPGsagaTest.cs b/CourseApp.Tests/RPGsagaTest.cs new file mode 100644 index 0000000..5aa30f2 --- /dev/null +++ b/CourseApp.Tests/RPGsagaTest.cs @@ -0,0 +1,82 @@ +namespace RPGsagaApp.Tests +{ + using RPGsagaApp; + using Xunit; + + public class RPGsagaTest + { + [Fact] + public void Test1() + { + Assert.True(true); + } + + [Fact] + public void TestConstructor() + { + var hero1 = new Knight(50, 20, "(Рыцарь) Ричард"); + Assert.Equal(50, hero1.Health); + Assert.Equal(20, hero1.Power); + Assert.Equal("(Рыцарь) Ричард", hero1.Name); + + var hero2 = new Archer(50, 20, "(Лучник) Леголас"); + Assert.Equal(50, hero2.Health); + Assert.Equal(20, hero2.Power); + Assert.Equal("(Лучник) Леголас", hero2.Name); + + while ((hero1.Health > 0) && (hero2.Health > 0)) + { + hero1.Action(); + hero2.Damage(); + if (hero2.Health <= 0) + { + break; + } + + hero2.Action(); + hero1.Damage(); + if (hero1.Health <= 0) + { + break; + } + } + } + + [Fact] + public void TestConstructor2() + { + var hero1 = new Knight(50, 20, "(Рыцарь) Зигфрид"); + Assert.Equal(50, hero1.Health); + Assert.Equal(20, hero1.Power); + Assert.Equal("(Рыцарь) Зигфрид", hero1.Name); + + var hero2 = new Magician(50, 20, "(Маг) Дамблдор"); + Assert.Equal(50, hero2.Health); + Assert.Equal(20, hero2.Power); + Assert.Equal("(Маг) Дамблдор", hero2.Name); + + while ((hero1.Health > 0) && (hero2.Health > 0)) + { + hero2.Action(); + hero1.Damage(); + if (hero1.Health <= 0) + { + break; + } + + hero1.Action(); + hero2.Damage(); + if (hero2.Health <= 0) + { + break; + } + } + } + + [Fact] + + public void TestConstructorFinal() + { + } + } +} diff --git a/CourseApp/Archer.cs b/CourseApp/Archer.cs deleted file mode 100644 index 37c6a55..0000000 --- a/CourseApp/Archer.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace CourseApp -{ - public class Archer : Hero - { - public Archer(int health, int power, string name) - : base(health, power, name) - { - } - - public override string AbilityDisplay() - { - return $"{Name} использует (Огненные стрелы)"; - } - } -} diff --git a/CourseApp/Knight.cs b/CourseApp/Knight.cs deleted file mode 100644 index 9935b6a..0000000 --- a/CourseApp/Knight.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace CourseApp -{ - public class Knight : Hero - { - public Knight(int health, int power, string name) - : base(health, power, name) - { - } - - public override string AbilityDisplay() - { - Power = Power + 30; - return $"{Name} использует (Удар возмездия) и наносит урон {Power}"; - } - } -} diff --git a/CourseApp/Logger.cs b/CourseApp/Logger.cs deleted file mode 100644 index bca11b1..0000000 --- a/CourseApp/Logger.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CourseApp -{ - public class Logger - { - } -} diff --git a/CourseApp/Magician.cs b/CourseApp/Magician.cs deleted file mode 100644 index 8241369..0000000 --- a/CourseApp/Magician.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace CourseApp -{ - public class Magician : Hero - { - public Magician(int health, int power, string name) - : base(health, power, name) - { - } - - public override string AbilityDisplay() - { - return $"{Name} использует (Заворожение)"; - } - } -} diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index b1ed1e4..57c4d73 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -2,6 +2,7 @@ { using System; using AutoApp; + using RPGsagaApp; public class Program { @@ -36,7 +37,7 @@ public static void Main(string[] args) Game saga = new Game(); saga.Print(); - /*Game rpg = new Game(100, 35, "(Рыцарь) Артур", "Удар возмездия"); + Game rpg = new Game(100, 35, "(Рыцарь) Артур", "Удар возмездия"); int characterHealth = rpg.Health; int characterPower = rpg.Power; string characterName = rpg.Name; @@ -47,99 +48,12 @@ public static void Main(string[] args) rpg.Power = 20; rpg.Name = "(Рыцарь) Ричард"; rpg.Ability = "Удар возмездия"; - Console.WriteLine(rpg.Print());*/ + Console.WriteLine(rpg.Print()); - Hero knight1 = new Knight(50, 20, "(Рыцарь) Ричард"); - Hero knight2 = new Knight(50, 20, "(Рыцарь) Зигфрид"); - Hero archer = new Archer(50, 20, "(Лучник) Леголас"); - Hero magician = new Magician(50, 20, "(Маг) Дамблдор"); - - Console.WriteLine("Кон 1."); - Console.WriteLine("(Рыцарь) Ричард vs (Лучник) Леголас"); - while ((knight1.Health > 0) && (archer.Health > 0)) - { - Console.WriteLine(archer.Action()); - Console.WriteLine(knight1.Damage()); - if (knight1.Health <= 0) - { - break; - } - - Console.WriteLine(knight1.AbilityDisplay()); - Console.WriteLine(archer.KnightAbiltiy()); - if (archer.Health <= 0) - { - break; - } - } - - if (knight1.Health <= 0) - { - Console.WriteLine("(Рыцарь) Ричард погибает"); - } - else if (archer.Health <= 0) - { - Console.WriteLine("(Лучник) Леголас погибает"); - } - - Console.WriteLine(" "); - Console.WriteLine("(Рыцарь) Зигрфрид vs (Маг) Дамблдор"); - while ((knight2.Health > 0) && (magician.Health > 0)) - { - Console.WriteLine(magician.Action()); - knight2.Damage(); - if (knight2.Health <= 0) - { - break; - } - - Console.WriteLine(knight2.Action()); - magician.Damage(); - if (magician.Health <= 0) - { - break; - } - } - - if (knight2.Health <= 0) - { - Console.WriteLine("(Рыцарь) Зигфрид погибает"); - } - else if (magician.Health <= 0) - { - Console.WriteLine("(Маг) Дамблдор погибает"); - } - - Console.WriteLine(" "); - Console.WriteLine("Кон 2."); - Console.WriteLine("(Рыцарь) Ричард vs (Маг) Дамблдор"); - while ((knight1.Health > 0) && (magician.Health > 0)) - { - Console.WriteLine(magician.AbilityDisplay()); - Console.WriteLine(knight1.MagicianAbility()); - Console.WriteLine(magician.Action()); - knight1.Damage(); - if (knight1.Health <= 0) - { - break; - } - - Console.WriteLine(knight1.Action()); - magician.Damage(); - if (magician.Health <= 0) - { - break; - } - } - - if (knight1.Health <= 0) - { - Console.WriteLine("(Рыцарь) Ричард погибает"); - } - else if (magician.Health <= 0) - { - Console.WriteLine("(Маг) Дамблдор погибает"); - } + Hero knight1 = new Knight(50, 20, "(Рыцарь) Ричард", "Удар возмездия"); + Hero knight2 = new Knight(50, 20, "(Рыцарь) Зигфрид", "Удар возмездия"); + Hero archer = new Archer(50, 20, "(Лучник) Леголас", "Огненные стрелы"); + Hero magician = new Magician(50, 20, "(Маг) Дамблдор", "Заворожение"); } } -} +} \ No newline at end of file diff --git a/CourseApp/RPGsaga/Archer.cs b/CourseApp/RPGsaga/Archer.cs new file mode 100644 index 0000000..939a3b0 --- /dev/null +++ b/CourseApp/RPGsaga/Archer.cs @@ -0,0 +1,19 @@ +namespace RPGsagaApp +{ + using System; + + public class Archer : Hero + { + public Archer(int health, int power, string name, string ability) + : base(health, power, name, ability) + { + } + + public override string AbilityDisplay() + { + Console.WriteLine($"Лучник {Name} использует {Ability}"); + Health = Health - 2; + return $" {Name} периодически получает урон {Health} от способности {Ability}"; + } + } +} diff --git a/CourseApp/Game.cs b/CourseApp/RPGsaga/Game.cs similarity index 51% rename from CourseApp/Game.cs rename to CourseApp/RPGsaga/Game.cs index 0bb21ec..b187dff 100644 --- a/CourseApp/Game.cs +++ b/CourseApp/RPGsaga/Game.cs @@ -1,9 +1,10 @@ -namespace CourseApp +namespace RPGsagaApp { + using System; + public class Game { public Game() - : this(100, 75, "Артур", "Удар возмездия") { } @@ -27,5 +28,26 @@ public string Print() { return $"Здоровье: {Health} Сила: {Power} Имя: {Name} Способность: {Ability}"; } + + public Hero Fight(Hero hero1, Hero hero2, Hero n_round) + { + hero1.Action(); + hero2.Damage(); + if (hero2.Health <= 0) + { + Console.WriteLine($"{hero2.Name} погибает"); + return hero1; + } + + hero2.Action(); + hero1.Damage(); + if (hero1.Health <= 0) + { + Console.WriteLine($"{hero1.Name} погибает"); + return hero2; + } + + return hero1; + } } } diff --git a/CourseApp/Hero.cs b/CourseApp/RPGsaga/Hero.cs similarity index 57% rename from CourseApp/Hero.cs rename to CourseApp/RPGsaga/Hero.cs index c6df53f..f05aa17 100644 --- a/CourseApp/Hero.cs +++ b/CourseApp/RPGsaga/Hero.cs @@ -1,12 +1,16 @@ -namespace CourseApp +namespace RPGsagaApp { public abstract class Hero { - public Hero(int health, int power, string name) + private int defaultHealth; + + public Hero(int health, int power, string name, string ability) { Health = health; + defaultHealth = Health; Power = power; Name = name; + Ability = ability; } public int Health { get; set; } @@ -15,34 +19,29 @@ public Hero(int health, int power, string name) public string Name { get; set; } + public string Ability { get; set; } + public abstract string AbilityDisplay(); - public string Action() + public string EnterFight(int n_kon) { - return $"{Name} наносит урон {Power} противнику"; + return $"Кон. {n_kon}"; } - public string Damage() + public string Advertisement(Hero hero1, Hero hero2) { - Health = Health - Power; - return $"{Name} получил урон {Power} и теряет {Health} единицы жизни"; + return $"{hero1.Name} vs {hero2.Name}"; } - public string KnightAbiltiy() - { - Health = Health - (Power + 30); - return $"{Name} теряет {Health} единицы жизни"; - } - - public string ArcherAbility() + public string Action() { - Health = Health - 2; - return $"{Name} теряет {Health - 2} единицы жизни"; + return $"{Name} наносит урон {Power} противнику"; } - public string MagicianAbility() + public string Damage() { - return $"{Name} пропускает ход"; + Health = Health - Power; + return $"{Name} получил урон {Power} и теряет {Health} единицы жизни"; } } } diff --git a/CourseApp/RPGsaga/Knight.cs b/CourseApp/RPGsaga/Knight.cs new file mode 100644 index 0000000..2c2e2ad --- /dev/null +++ b/CourseApp/RPGsaga/Knight.cs @@ -0,0 +1,16 @@ +namespace RPGsagaApp +{ + public class Knight : Hero + { + public Knight(int health, int power, string name, string ability) + : base(health, power, name, ability) + { + } + + public override string AbilityDisplay() + { + Power = Power + 30; + return $"Рыцарь {Name} использует {Ability} и наносит урон {Power} противнику"; + } + } +} diff --git a/CourseApp/RPGsaga/Logger.cs b/CourseApp/RPGsaga/Logger.cs new file mode 100644 index 0000000..fd39d34 --- /dev/null +++ b/CourseApp/RPGsaga/Logger.cs @@ -0,0 +1,12 @@ +namespace RPGsagaApp +{ + using System; + + public class Logger + { + public void GameOver(Hero winner) + { + Console.WriteLine($"Победителем становится {winner}!"); + } + } +} \ No newline at end of file diff --git a/CourseApp/RPGsaga/Magician.cs b/CourseApp/RPGsaga/Magician.cs new file mode 100644 index 0000000..739736c --- /dev/null +++ b/CourseApp/RPGsaga/Magician.cs @@ -0,0 +1,18 @@ +namespace RPGsagaApp +{ + using System; + + public class Magician : Hero + { + public Magician(int health, int power, string name, string ability) + : base(health, power, name, ability) + { + } + + public override string AbilityDisplay() + { + Console.WriteLine($"Маг {Name} использует {Ability}"); + return $"{Name} пропускает ход из-за способности {Ability}"; + } + } +} From 41559cf870452e1a800134684194b289f2dd9f4b Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Sat, 14 Jan 2023 08:40:50 +0300 Subject: [PATCH 07/11] RPG_Saga --- CourseApp/RPGsaga/Game.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CourseApp/RPGsaga/Game.cs b/CourseApp/RPGsaga/Game.cs index b187dff..69974f4 100644 --- a/CourseApp/RPGsaga/Game.cs +++ b/CourseApp/RPGsaga/Game.cs @@ -29,8 +29,10 @@ public string Print() return $"Здоровье: {Health} Сила: {Power} Имя: {Name} Способность: {Ability}"; } - public Hero Fight(Hero hero1, Hero hero2, Hero n_round) + public Hero Fight(Hero hero1, Hero hero2, Hero n_round, int n_kon) { + n_round.EnterFight(n_kon); + n_round.Advertisement(hero1, hero2); hero1.Action(); hero2.Damage(); if (hero2.Health <= 0) From 150e0f389e68ff4edae78f07d21fd0c9548721a7 Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Sat, 14 Jan 2023 08:43:56 +0300 Subject: [PATCH 08/11] RPG_Saga --- CourseApp/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 57c4d73..d206e0a 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -54,6 +54,7 @@ public static void Main(string[] args) Hero knight2 = new Knight(50, 20, "(Рыцарь) Зигфрид", "Удар возмездия"); Hero archer = new Archer(50, 20, "(Лучник) Леголас", "Огненные стрелы"); Hero magician = new Magician(50, 20, "(Маг) Дамблдор", "Заворожение"); + Console.WriteLine(" "); } } } \ No newline at end of file From fe33caa42cb8c9508fda7883eb00a6953395df23 Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Sat, 14 Jan 2023 08:52:23 +0300 Subject: [PATCH 09/11] RPG_Saga --- CourseApp.Tests/RPGsagaTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CourseApp.Tests/RPGsagaTest.cs b/CourseApp.Tests/RPGsagaTest.cs index 5aa30f2..dd2323e 100644 --- a/CourseApp.Tests/RPGsagaTest.cs +++ b/CourseApp.Tests/RPGsagaTest.cs @@ -14,12 +14,12 @@ public void Test1() [Fact] public void TestConstructor() { - var hero1 = new Knight(50, 20, "(Рыцарь) Ричард"); + var hero1 = new Knight(50, 20, "(Рыцарь) Ричард", "Удар возмездя"); Assert.Equal(50, hero1.Health); Assert.Equal(20, hero1.Power); Assert.Equal("(Рыцарь) Ричард", hero1.Name); - var hero2 = new Archer(50, 20, "(Лучник) Леголас"); + var hero2 = new Archer(50, 20, "(Лучник) Леголас", "Огненные стрелы"); Assert.Equal(50, hero2.Health); Assert.Equal(20, hero2.Power); Assert.Equal("(Лучник) Леголас", hero2.Name); @@ -45,12 +45,12 @@ public void TestConstructor() [Fact] public void TestConstructor2() { - var hero1 = new Knight(50, 20, "(Рыцарь) Зигфрид"); + var hero1 = new Knight(50, 20, "(Рыцарь) Зигфрид", "Удар возмездя"); Assert.Equal(50, hero1.Health); Assert.Equal(20, hero1.Power); Assert.Equal("(Рыцарь) Зигфрид", hero1.Name); - var hero2 = new Magician(50, 20, "(Маг) Дамблдор"); + var hero2 = new Magician(50, 20, "(Маг) Дамблдор", "Заворожение"); Assert.Equal(50, hero2.Health); Assert.Equal(20, hero2.Power); Assert.Equal("(Маг) Дамблдор", hero2.Name); From efb93142d06578ebc034efc90ce714cb513a1a26 Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Thu, 19 Jan 2023 11:04:45 +0300 Subject: [PATCH 10/11] RPG_Saga --- CourseApp/Program.cs | 15 +++++++++++++++ CourseApp/RPGsaga/Game.cs | 14 +++++++++++--- CourseApp/RPGsaga/Hero.cs | 20 ++++++-------------- CourseApp/RPGsaga/Logger.cs | 6 ++---- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index d206e0a..62d77bf 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -55,6 +55,21 @@ public static void Main(string[] args) Hero archer = new Archer(50, 20, "(Лучник) Леголас", "Огненные стрелы"); Hero magician = new Magician(50, 20, "(Маг) Дамблдор", "Заворожение"); Console.WriteLine(" "); + + Game fight1 = new Game(); + Console.WriteLine(fight1.EnterFight(1)); + Console.WriteLine(fight1.Advertisement(knight1, archer)); + fight1.Fight(knight1, archer); + + Game fight2 = new Game(); + fight2.EnterFight(1); + fight2.Advertisement(knight2, magician); + fight2.Fight(knight2, magician); + + Game fightFinal = new Game(); + fightFinal.EnterFight(2); + fightFinal.Advertisement(knight1, knight2); + fightFinal.Fight(knight1, knight2); } } } \ No newline at end of file diff --git a/CourseApp/RPGsaga/Game.cs b/CourseApp/RPGsaga/Game.cs index 69974f4..665cfb2 100644 --- a/CourseApp/RPGsaga/Game.cs +++ b/CourseApp/RPGsaga/Game.cs @@ -29,10 +29,18 @@ public string Print() return $"Здоровье: {Health} Сила: {Power} Имя: {Name} Способность: {Ability}"; } - public Hero Fight(Hero hero1, Hero hero2, Hero n_round, int n_kon) + public string EnterFight(int n_kon) + { + return $"Кон. {n_kon};"; + } + + public string Advertisement(Hero hero1, Hero hero2) + { + return $"{hero1.Name} vs {hero2.Name}"; + } + + public Hero Fight(Hero hero1, Hero hero2) { - n_round.EnterFight(n_kon); - n_round.Advertisement(hero1, hero2); hero1.Action(); hero2.Damage(); if (hero2.Health <= 0) diff --git a/CourseApp/RPGsaga/Hero.cs b/CourseApp/RPGsaga/Hero.cs index f05aa17..892e7d4 100644 --- a/CourseApp/RPGsaga/Hero.cs +++ b/CourseApp/RPGsaga/Hero.cs @@ -1,5 +1,7 @@ namespace RPGsagaApp { + using System; + public abstract class Hero { private int defaultHealth; @@ -23,25 +25,15 @@ public Hero(int health, int power, string name, string ability) public abstract string AbilityDisplay(); - public string EnterFight(int n_kon) - { - return $"Кон. {n_kon}"; - } - - public string Advertisement(Hero hero1, Hero hero2) - { - return $"{hero1.Name} vs {hero2.Name}"; - } - - public string Action() + public void Action() { - return $"{Name} наносит урон {Power} противнику"; + Console.WriteLine($"{Name} наносит урон {Power} противнику"); } - public string Damage() + public void Damage() { Health = Health - Power; - return $"{Name} получил урон {Power} и теряет {Health} единицы жизни"; + Console.WriteLine($"{Name} получил урон {Power} и теряет {Health} единицы жизни"); } } } diff --git a/CourseApp/RPGsaga/Logger.cs b/CourseApp/RPGsaga/Logger.cs index fd39d34..7d58aee 100644 --- a/CourseApp/RPGsaga/Logger.cs +++ b/CourseApp/RPGsaga/Logger.cs @@ -1,12 +1,10 @@ namespace RPGsagaApp { - using System; - public class Logger { - public void GameOver(Hero winner) + public string GameOver(Hero winner) { - Console.WriteLine($"Победителем становится {winner}!"); + return $"Победителем становится {winner}!"; } } } \ No newline at end of file From a8393dde3a9bd89e4b25ed36f9f879b3cfcee8ab Mon Sep 17 00:00:00 2001 From: NikitaZhulenkov <92643849+NikitaZhulenkov@users.noreply.github.com> Date: Sat, 25 Mar 2023 15:50:36 +0300 Subject: [PATCH 11/11] Add files via upload --- index.html | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..9050cac --- /dev/null +++ b/index.html @@ -0,0 +1,73 @@ + + + + + Web сайт + + + + + + + + + +
+
+

Жуленков Никита Ильич

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+

Далее »

+
+
+
+
+
+

Учебное заведение\(Работа)

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+

Далее »

+
+
+

Увлечения

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+

Далее »

+
+
+

Личная жизнь

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+

Далее »

+
+
+
+ +
+ + + + + +