From 974bb5ecbf05e3ca612173e6d0d93817a730cbc6 Mon Sep 17 00:00:00 2001 From: adam1ch Date: Tue, 6 Oct 2026 15:53:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=B0=206=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=87=D1=82=D0=B8=20=D0=B4=D0=B2=D0=B0=20=D0=B7=D0=B0=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- works/lab 6/src/one ex.cs | 53 ++++++++++++ works/lab 6/src/two ex.cs | 79 +++++++++++++++++ works/stage-03/src/main.cs | 173 +------------------------------------ 3 files changed, 133 insertions(+), 172 deletions(-) create mode 100644 works/lab 6/src/one ex.cs create mode 100644 works/lab 6/src/two ex.cs diff --git a/works/lab 6/src/one ex.cs b/works/lab 6/src/one ex.cs new file mode 100644 index 0000000..53146b4 --- /dev/null +++ b/works/lab 6/src/one ex.cs @@ -0,0 +1,53 @@ +namespace DefaultNamespace; + +public class one_ex +{ + static void Main(string[] args) + { + Pokemon pikachu = new Pokemon(100, 5, "Пикачу"); + Pokemon sqr = new Pokemon(90, 7, "Сквиртл"); + + pikachu.ShowInfo(); + sqr.ShowInfo(); + } +} + +class Pokemon +{ + private int hp; + private int level; + private string name; + + public int HP + { + get => hp; + set => hp = value; + } + + public int Level + { + get => level; + set => level = value; + } + + public string Name + { + get => name; + set => name = value; + } + + + + public Pokemon(int hp, int level, string name) + { + this.name = name; + this.level = level; + this.hp = hp; + } + + public void ShowInfo() + { + Console.WriteLine($"HP: {this.HP}, Level: {this.Level}, Name: {this.Name}"); + } + +} \ No newline at end of file diff --git a/works/lab 6/src/two ex.cs b/works/lab 6/src/two ex.cs new file mode 100644 index 0000000..75060fc --- /dev/null +++ b/works/lab 6/src/two ex.cs @@ -0,0 +1,79 @@ +namespace DefaultNamespace; + +public class two_ex +{ + static void Main(string[] args) + { + Pokemon pikachu = new Pokemon(100, 5, "Пикачу"); + Pokemon sqr = new Pokemon(90, 7, "Сквиртл"); + + pikachu.ShowInfo(); + sqr.ShowInfo(); + } +} + +class Pokemon +{ + private int hp; + private int level; + private string name; + + public int HP + { + get { return hp; } + set + { + if (hp < 0) hp = 0; + else if (hp > 100) hp = 100; + else hp = value; + } + + } + + public int Level + { + get { return level; } + set + { + if (level < 1) level = 1; + else if (level > 100) level = 100; + else level = level; + } + } + + public string Name + { + get { return name; } + + + set + { + if (name == "") name = "Безымянный"; + else name = value; + } + + + } + + public Pokemon(int hp, int level, string name) + { + this.name = name; + this.level = level; + this.hp = hp; + } + + public void ShowInfo() + { + Console.WriteLine($"HP: {this.HP}, Level: {this.Level}, Name: {this.Name}"); + } + + public int TakeDamage(int damage) + { + hp -= damage; + if (hp <= 0) return 0; + return this.hp; + } +} + + + \ No newline at end of file diff --git a/works/stage-03/src/main.cs b/works/stage-03/src/main.cs index 407f816..1e960e1 100644 --- a/works/stage-03/src/main.cs +++ b/works/stage-03/src/main.cs @@ -1,172 +1 @@ -namespace DefaultNamespace; - -public class Programm -{ - static void Main(string[] args) - { - Console.WriteLine("======================================================================"); - Console.WriteLine("ИНИЦИАЛИЗА КАРТОЧКИ ПОКЕМОНА"); - Console.WriteLine("----------------------------------------------------------------------"); - - Console.Write("Введите стадию развития: "); - string stage = Console.ReadLine(); - Console.Write("Введите имя покемона: "); - string name = Console.ReadLine(); - Console.Write("Введите вид покемона: "); - string category = Console.ReadLine(); - Console.Write("Введите название 1-й атаки: "); - string attack1Name = Console.ReadLine(); - Console.Write("Введите эффект 1-й атаки: "); - string attack1Desc = Console.ReadLine(); - Console.Write("Введите базовый урон 1-й атаки: "); - int attack1BaseDamage = int.Parse(Console.ReadLine()); - Console.Write("Введите название 2-й атаки: "); - string attack2Name = Console.ReadLine(); - Console.Write("Введите эффект 2-й атаки: "); - string attack2Desc = Console.ReadLine(); - Console.Write("Введите базовый урон 2-й атаки: "); - int attack2BaseDamage = int.Parse(Console.ReadLine()); - Console.Write("Введите уязвимость: "); - string weakness = Console.ReadLine(); - Console.Write("Введите устойчивость: "); - string resistance = Console.ReadLine(); - Console.Write("Введите текущее HP: "); - int hp = int.Parse(Console.ReadLine()); - - Console.Clear(); - Console.WriteLine("======================================================================"); - Console.WriteLine($"[{stage}] {name,-42} ОЖ: {hp}"); - Console.WriteLine("----------------------------------------------------------------------"); - Console.WriteLine($"Вид: {category}"); - Console.WriteLine("----------------------------------------------------------------------"); - Console.WriteLine($"[Атака 1] {attack1Name,-40} Урон: {attack1BaseDamage}"); - Console.WriteLine($"Эффект: {attack1Desc}\n"); - Console.WriteLine($"[Атака 2] {attack2Name,-40} Урон: {attack2BaseDamage}+"); - Console.WriteLine($"Эффект: {attack2Desc}"); - Console.WriteLine("----------------------------------------------------------------------"); - Console.WriteLine($"Слабость: {weakness} | Устойчивость: {resistance}"); - Console.WriteLine("======================================================================\n"); - - string enemyName = "Булбазавр"; - int enemyHp = 70; - int enemyBaseDamage = 15; - int roundNumber = 1; - bool isEnemyDebuffed = false; - - Console.WriteLine("Приготовьтесь к дуэли!"); - for (int i = 3; i >= 1; i--) - { - Console.WriteLine($"{i}..."); - } - Console.WriteLine($"\n=== СТАРТ ДУЭЛИ: {name} (HP: {hp}) VS {enemyName} (HP: {enemyHp}) ===\n"); - - while (hp > 0 && enemyHp > 0) - { - Console.WriteLine($"--- Раунд {roundNumber} ---"); - int actionChoice; - - do - { - Console.Write($"Выберите действие (1 - {attack1Name}, 2 - {attack2Name}): "); - actionChoice = int.Parse(Console.ReadLine()); - } while (actionChoice != 1 && actionChoice != 2); - - int playerDamage = 0; - if (actionChoice == 1) - { - Console.Write($"[{attack1Name}] Проверка условия спецэффекта (1 - Сработал, 0 - Нет): "); - int effectChoice = int.Parse(Console.ReadLine()); - - playerDamage = attack1BaseDamage; - if (effectChoice == 1) - { - isEnemyDebuffed = true; - Console.WriteLine($"Результат: Спецэффект сработал! {enemyName} потерял возможность атаковать!"); - } - else - { - Console.WriteLine("Результат: Спецэффект не сработал."); - } - } - else if (actionChoice == 2) - { - Console.Write($"[{attack2Name}] Проверка условия спецэффекта (1 - Критический урон, 0 - Обычный): "); - int bonusChoice = int.Parse(Console.ReadLine()); - - if (bonusChoice == 1) - { - playerDamage = attack2BaseDamage + 10; - Console.WriteLine($"Результат: Условие выполнено! Нанесен усиленный урон: {playerDamage}"); - } - else - { - playerDamage = attack2BaseDamage; - Console.WriteLine($"Результат: Базовый урон: {playerDamage}"); - } - } - - enemyHp -= playerDamage; - - if (enemyHp <= 0) - { - enemyHp = 0; - Console.WriteLine($"{enemyName} нокаутирован!"); - break; - } - - if (isEnemyDebuffed) - { - Console.WriteLine($"{enemyName} пропускает ход из-за эффекта атаки!"); - isEnemyDebuffed = false; - } - else - { - Console.Write("Выберите тип атаки противника (1 - Уязвимость, 2 - Устойчивость, 3 - Обычный): "); - int enemyAttackType = int.Parse(Console.ReadLine()); - int finalIncomingDamage = 0; - - switch (enemyAttackType) - { - case 1: - finalIncomingDamage = enemyBaseDamage * 2; - Console.WriteLine($"Расчёт: Уязвимость ({weakness})! Урон удваивается (x2)."); - break; - case 2: - finalIncomingDamage = enemyBaseDamage - 20; - if (finalIncomingDamage < 0) - { - finalIncomingDamage = 0; - } - Console.WriteLine($"Расчёт: Устойчивость ({resistance})! Урон уменьшается на 20."); - break; - case 3: - finalIncomingDamage = enemyBaseDamage; - Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений."); - break; - } - - hp -= finalIncomingDamage; - } - - if (hp <= 0) - { - hp = 0; - Console.WriteLine($"{name} нокаутирован!"); - break; - } - Console.WriteLine($"Итог раунда: {name} HP: {hp} | {enemyName} HP: {enemyHp}\n"); - roundNumber++; - } - Console.WriteLine("\n======================================================================"); - Console.WriteLine("=== ДУЭЛЬ ОКОНЧЕНА ==="); - if (hp > 0) - { - Console.WriteLine($"Победитель: {name}!"); - } - else - { - Console.WriteLine($"Победитель: {enemyName}!"); - } - Console.WriteLine("======================================================================"); - } -} \ No newline at end of file +/ \ No newline at end of file