Files
cshap/works/lab-03/readme.md
T

103 lines
3.5 KiB
Markdown

internal class Program
{
static string pokemon1Name = "Пикачу";
static int pokemon1Hp = 50;
static int pokemon1Attack = 12;
static string pokemon2Name = "Булбазавр";
static int pokemon2Hp = 55;
static int pokemon2Attack = 10;
static int roundNumber = 1;
static void Main(string[] args)
{
string userInput;
do
{
Console.WriteLine("1 -> Задание 1");
Console.WriteLine("2 -> Задание 2");
Console.WriteLine("3 -> Задание 3");
Console.WriteLine("4 -> Выход");
Console.Write("Выбор: ");
userInput = Console.ReadLine();
switch (userInput)
{
case "1":
part1();
break;
case "2":
part2();
break;
case "3":
part3();
break;
case "4":
part3();
break;
default:
Console.WriteLine("выбор не допустим");
break;
}
} while (userInput != "4");
}
static void part1()
{
Console.WriteLine("\nПриготовьтесь!");
for (int i = 3; i >0; i--)
{
Console.WriteLine(i +"...");
Thread.Sleep(1000);
}
Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ===");
Console.WriteLine($"{pokemon1Name}({pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name}({pokemon2Hp} | Атака: {pokemon2Attack})\n");
}
static void part2()
{
Console.Write("\nГотовы начать бой? (1 — Начать бой, 0 — Сдаться): ");
string userInput2 = Console.ReadLine();
var consoleText = "";
do
{
if (userInput2 == "1")
{
consoleText = "Бой начинается!";
}
else if (userInput2 == "0")
{
consoleText = "...Никаких боев";
}
else
{
consoleText = "Неверный ввод";
}
} while (userInput2 != "1" && userInput2 != "0");
Console.WriteLine(consoleText + "\n");
}
static void part3()
{
Console.WriteLine("\n=== БОЙ НАЧИНАЕТСЯ ===");
for (int i = 1; i <= 5; i++)
{
Console.WriteLine($"---Раунд {i}---");
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
pokemon2Hp -= pokemon1Attack;
if (pokemon2Hp <= 0)
{
pokemon2Hp = 0;
Console.WriteLine($"{pokemon2Name} потерял сознание!");
break;
}
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
pokemon1Hp -= pokemon2Attack;
if (pokemon1Hp <= 0)
{
pokemon1Hp = 0;
Console.WriteLine($"{pokemon1Name} потерял сознание!");
break;
}
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}\n");
Thread.Sleep(1000);
}
}
}