From a9a23b6b58c248c16220199728a2fe9b91e21f64 Mon Sep 17 00:00:00 2001 From: Puzanova Date: Mon, 21 Sep 2026 15:53:52 +0300 Subject: [PATCH] stage3 --- works/CSharp/stage3/stage3/Program.cs | 188 ++++++++++++++++++-------- 1 file changed, 129 insertions(+), 59 deletions(-) diff --git a/works/CSharp/stage3/stage3/Program.cs b/works/CSharp/stage3/stage3/Program.cs index cf3b255..22f33d2 100644 --- a/works/CSharp/stage3/stage3/Program.cs +++ b/works/CSharp/stage3/stage3/Program.cs @@ -1,5 +1,7 @@ -namespace stage3 -{ +using System.Globalization; + +namespace stage3 +{ class stage3 { static void Main(string[] args) @@ -14,37 +16,41 @@ Console.WriteLine("Введите вид покемона: "); string category = Console.ReadLine(); Console.WriteLine("Введите название 1-й атаки: "); - string attack1Name = Console.ReadLine(); + string attack1Name = Console.ReadLine(); Console.WriteLine("Введите эффект 1-й атаки: "); - string attack1Desc = Console.ReadLine(); + string attack1Desc = Console.ReadLine(); Console.WriteLine("Введите базовый урон 1-й атаки:"); - int attack1BaseDamage = int.Parse(Console.ReadLine()); + int attack1BaseDamage = int.Parse(Console.ReadLine()); Console.WriteLine("Введите название 2-й атаки: "); - string attack2Name = Console.ReadLine(); + string attack2Name = Console.ReadLine(); Console.WriteLine("Введите эффект 2-й атаки: "); - string attack2Desc = Console.ReadLine(); + string attack2Desc = Console.ReadLine(); Console.WriteLine("Введите базовый урон 2-й атаки: "); - int attack2BaseDamage = int.Parse(Console.ReadLine()); + int attack2BaseDamage = int.Parse(Console.ReadLine()); Console.WriteLine("Введите уязвимость: "); - string weakness = Console.ReadLine(); + string weakness = Console.ReadLine(); Console.WriteLine("Введите устойчивость: "); - string resistance = Console.ReadLine(); + string resistance = Console.ReadLine(); Console.WriteLine("Введите текущее HP: "); int hp = int.Parse(Console.ReadLine()); string enemyName = "Булбазавр"; - int enemyHp = 70 ; - int enemyBaseDamage = 15 ; - int roundNumber = 20 ; - int actionChoice = 1 ; - bool isEnemyDebuffed = true; + int enemyHp = 70; + int enemyBaseDamage = 15; + int roundNumber = 1; + int actionChoice; + int attackChoice; + bool isEnemyDebuffed = false; + Console.Clear(); Console.WriteLine(" "); Console.WriteLine(" "); Console.WriteLine("======================================================================"); - Console.WriteLine($"[{stage}] Чармандер ОЖ: {enemyHp}"); + Console.WriteLine($"[{stage}] Чармандер ОЖ: {hp}"); Console.WriteLine("----------------------------------------------------------------------"); Console.WriteLine($"Вид: {category}"); - Console.WriteLine($"[Атака 1] {attack1Name} Урон: {attack1BaseDamage}"); + Console.WriteLine("----------------------------------------------------------------------"); + Console.WriteLine( + $"[Атака 1] {attack1Name} Урон: {attack1BaseDamage}"); Console.WriteLine($"Эффект: {attack1Desc}"); Console.WriteLine(" "); Console.WriteLine($"[Атака 2] {attack2Name} Урон: {attack2BaseDamage}+"); @@ -53,63 +59,127 @@ Console.WriteLine($"Слабость: {weakness} | Устойчивость: {resistance}"); Console.WriteLine("======================================================================"); Console.WriteLine(" "); + Console.WriteLine("Приготовьтесь к дуэли!"); - for (int i = 3; i > 0 ; i--) + for (int i = 3; i > 0; i--) { Console.WriteLine($"{i}..."); } - Console.WriteLine($"=== СТАРТ ДУЭЛИ: {name} (HP: {hp}) VS {enemyName } (HP: {enemyHp}) ===\n"); + + Console.WriteLine($"=== СТАРТ ДУЭЛИ: {name} (HP: {hp}) VS {enemyName} (HP: {enemyHp}) ===\n"); + while (hp > 0 && enemyHp > 0) { Console.WriteLine($"--- Раунд {roundNumber} ---"); + do + { + Console.Write("Выберите действие (1 - Угольки, 2 - Огненный Клык): "); + attackChoice = int.Parse(Console.ReadLine()); + } while (attackChoice != 1 && attackChoice != 2); - int choice; + roundNumber++; - do - { - Console.WriteLine($"Выберите атаку: 1 — {attack1Name}, 2 — {attack2Name}"); - - if (choice == 1 || choice == 2) - { - break; - } - else - { - Console.WriteLine("Неверный ввод. Введите 1 или 2."); - } - } while (true); - - Console.WriteLine("Вы выбрали: " + choice); - + if (attackChoice == 1) + { + enemyHp -= attack1BaseDamage; + do + { + Console.Write($"[{attack1Name}] Проверка условия спецэффекта (1 - Сработал, 0 - Нет): "); + actionChoice = int.Parse(Console.ReadLine()); + } while (actionChoice != 0 && actionChoice != 1); + if (actionChoice == 0) + Console.WriteLine("Результат: Спецэффект не сработал."); + else + { + isEnemyDebuffed = true; + Console.WriteLine( + $"Результат: Спецэффект сработал! {enemyName} потерял возможность атаковать!"); + } + } + else + { + do + { + Console.Write( + $"[{attack2Name}] Проверка условия спецэффекта (1 - Критический урон, 0 - Обычный): "); + actionChoice = int.Parse(Console.ReadLine()); + } while (actionChoice != 0 && actionChoice != 1); + + if (actionChoice == 0) + { + enemyHp -= attack2BaseDamage; + Console.WriteLine("Результат: Базовый урон: " + attack2BaseDamage); + } + else + { + enemyHp -= (attack2BaseDamage + 10); + Console.WriteLine("Результат: Условие выполнено! Нанесен усиленный урон: " + + (attack2BaseDamage + 10)); + } + } + + if (enemyHp <= 0) + { + enemyHp = 0; + Console.WriteLine($"{enemyName} нокаутирован!"); + break; + } if (isEnemyDebuffed == true) { - Console.WriteLine($" {enemyName} пропускает ход из-за эффекта атаки!"); - + Console.WriteLine($"\n{enemyName} пропускает ход из-за эффекта атаки!"); + isEnemyDebuffed = false; } - else Console.WriteLine(); + else + { + do + { + Console.Write( + $"Выберите тип атаки противника (1 - Уязвимость, 2 - Устойчивость, 3 - Обычный): "); + actionChoice = int.Parse(Console.ReadLine()); + } while (actionChoice != 1 && actionChoice != 2 && actionChoice != 3); + + switch (actionChoice) + { + case 1: + hp -= (enemyBaseDamage * 2); + Console.WriteLine($"Расчёт: Уязвимость ({weakness})! Урон удваивается (x2)."); + break; + case 2: + if (enemyBaseDamage < 20) + { + Console.WriteLine($"Расчёт: Устойчивость ({resistance})! Урон уменьшается на 0."); + } + else hp -= (enemyBaseDamage - 20); + + Console.WriteLine($"Расчёт: Устойчивость ({resistance})! Урон уменьшается на 20."); + break; + + case 3: + hp -= enemyBaseDamage; + Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений."); + break; + + + } + } + } + + Console.WriteLine("=== ДУЭЛЬ ОКОНЧЕНА ==="); + if (hp > enemyHp) + { + Console.WriteLine("$Победитель: {name}!"); + } + else Console.WriteLine($"Победитель: {enemyName}!"); + + Console.WriteLine($"Победитель: "); + Console.WriteLine("======================================================================"); + + + + } - roundNumber++; - - - Console.WriteLine("----------------------------------------------------------------------"); - Console.WriteLine("----------------------------------------------------------------------"); - Console.WriteLine("======================================================================"); - Console.WriteLine("=== ДУЭЛЬ ОКОНЧЕНА ==="); - if (hp > enemyHp) - { - Console.WriteLine("$\"Победитель: {name}!\""); - } - else Console.WriteLine($"Победитель: {enemyName}!"); - - Console.WriteLine($"Победитель: "); - Console.WriteLine("======================================================================"); - - - - } } -}