generated from admin/template
Stage №4
- Студент: Прибыткова Елизавета Дмитриевна
- Техническое задание: Турнир Лиги Покемонов (Глобальный игровой цикл с коллекциями)
Ключевой код
string[] activeTeam = new string[3];
List<string> backpack = new List<string>();
int[] pokedexHP = new int[3];
int[] pokedexDamage = new int[3];
string[] enemyNames = { "Мяут", "Геодуд", "Гарчомп" };
int[] enemyHPs = { 40, 65, 90 };
int[] enemyDamages = { 10, 15, 25 };
int[] enemyTypes = { 3, 1, 2 };
int currentEnemyIndex = 0;
int activeFighterIndex = 0;
int actionChoice, attackChoice;
string itemChoice;
Console.WriteLine("=== РЕГИСТРАЦИЯ НА СЕЗОН ЛИГИ ===");
for (int i = 0; i < 3; i++)
{
Console.Write($"Введите имя покемона №{i + 1}: ");
activeTeam[i] = Console.ReadLine();
Console.Write($"Введите макс. HP для {activeTeam[i]}: ");
pokedexHP[i] = int.Parse(Console.ReadLine());
Console.Write($"Введите базовый урон для {activeTeam[i]}: ");
pokedexDamage[i] = int.Parse(Console.ReadLine());;
Console.WriteLine();
}
backpack.Add("Зелье HP");
backpack.Add("Суперзелье");
backpack.Add("Антидот");
Console.WriteLine("Вы упаковали походную сумку тренера.");
Console.WriteLine("Предметов в инвентаре изначально: " + backpack.Count);
Console.ReadLine();
Console.Clear();
Console.WriteLine("Подготовка завершена! Ворота Арены открываются через...");
for (int i = 3; i > 0; i--)
{
Console.WriteLine(i + "...");
}
Console.WriteLine("======================================================================");
Console.WriteLine("=== ТУРНИР НАЧАЛСЯ ===");
while (currentEnemyIndex < 3 && (pokedexHP[0] > 0 | pokedexHP[1] > 0 | pokedexHP[2] > 0))
{
Console.WriteLine($"=== ЭТАП {currentEnemyIndex + 1} ===");
Console.WriteLine($"Ваш активный боец: {activeTeam[activeFighterIndex]} (HP: {pokedexHP[activeFighterIndex]}) VS Дикий {enemyNames[currentEnemyIndex]} (HP: {enemyHPs[currentEnemyIndex]})");
Console.WriteLine("----------------------------------------------------------------------");
while (pokedexHP[activeFighterIndex] > 0 && enemyHPs[currentEnemyIndex] > 0)
{
do
{
Console.Write("Выберите действие (1 - Атака, 2 - Сумка, 3 - Смена Покемона): ");
actionChoice = int.Parse(Console.ReadLine());
} while (actionChoice != 1 && actionChoice != 2 && actionChoice != 3 );
switch (actionChoice)
{
case 1:
do
{
Console.Write("Проверка точности (1 - Критический урон, 0 - Обычный): ");
attackChoice = int.Parse(Console.ReadLine());
} while (attackChoice != 0 && attackChoice != 1);
if (attackChoice == 0)
{
enemyHPs[currentEnemyIndex] -= pokedexDamage[activeFighterIndex];
Console.WriteLine($"Результат: Нанесено урона: {pokedexDamage[activeFighterIndex]}");
}
else
{
enemyHPs[currentEnemyIndex] -= (pokedexDamage[activeFighterIndex] + 15);
Console.WriteLine($"Результат: Критический удар! Нанесено урона: {pokedexDamage[activeFighterIndex] + 15}");
}
break;
case 2:
if (backpack.Count > 0)
{
Console.WriteLine("--- Содержимое вашей сумки ---");
foreach (var item in backpack)
{
Console.WriteLine($"[Предмет] -> {item}");
}
Console.Write("Какой предмет использовать? Введите название: ");
itemChoice = Console.ReadLine();
switch (itemChoice)
{
case "Зелье HP":
backpack.Remove(itemChoice);
Console.WriteLine($"Результат: {activeTeam[activeFighterIndex]} восстановил 30 HP! Предмет удален из сумки.");
pokedexHP[activeFighterIndex] += 30;
break;
case "Суперзелье":
backpack.Remove(itemChoice);
Console.WriteLine($"Результат: {activeTeam[activeFighterIndex]} восстановил 60 HP! Предмет удален из сумки.");
pokedexHP[activeFighterIndex] += 60;
break;
case "Антидот":
backpack.Remove(itemChoice);
Console.WriteLine($"Результат: {activeTeam[activeFighterIndex]} выпивает антидот! Предмет удален из сумки.");
break;
default:
Console.WriteLine("Такого предмета нет в сумке.");
break;
}
}
else
Console.WriteLine("Ваш рюкзак пуст.");
break;
case 3:
Console.WriteLine("--- Ваша команда ---");
for (int i = 0; i < activeTeam.Length; i++)
{
Console.WriteLine($" {i + 1}. {activeTeam[i]} HP: {pokedexHP[i]}");
}
do
{
Console.Write("Введите номер замены: ");
attackChoice = int.Parse(Console.ReadLine());
if (attackChoice >= 1 && attackChoice <= 3 && pokedexHP[attackChoice - 1] <= 0)
Console.WriteLine($"{activeTeam[attackChoice - 1]} в нокауте. Выберите другого бойца.");
else if (attackChoice < 1 || attackChoice > 3)
Console.WriteLine("Неверный номер. Введите число от 1 до 3.");
} while (attackChoice < 1 | attackChoice > 3 | pokedexHP[attackChoice - 1] <= 0);
if (pokedexHP[attackChoice - 1] > 0)
{
activeFighterIndex = attackChoice - 1;
Console.WriteLine($"Ваш текущий боец: {activeTeam[activeFighterIndex]} (HP: {pokedexHP[activeFighterIndex]})");
}
break;
}
if (enemyHPs[currentEnemyIndex] <= 0)
{
enemyHPs[currentEnemyIndex] = 0;
Console.WriteLine($"Дикий {enemyNames[currentEnemyIndex]} нокаутирован! Вы переходите на следующий этап!\n");
break;
}
Console.WriteLine($"\nДикий {enemyNames[currentEnemyIndex]} проводит контратаку!");
attackChoice = enemyTypes[currentEnemyIndex];
switch (attackChoice)
{
case 1:
pokedexHP[activeFighterIndex] -= enemyDamages[currentEnemyIndex] * 2;
Console.WriteLine("Расчёт: Боевой тип! Урон удваивается.");
Console.WriteLine($"{activeTeam[activeFighterIndex]} получил урон: {enemyDamages[currentEnemyIndex] * 2}");
break;
case 2:
if (enemyDamages[currentEnemyIndex] < 10)
{
Console.WriteLine($"{activeTeam[activeFighterIndex]} не получает урона!");
}
else
{
pokedexHP[activeFighterIndex] -= (enemyDamages[currentEnemyIndex] - 10);
Console.WriteLine("Расчёт: Стальной тип! Урон снижается на 10 единиц.");
Console.WriteLine($"{activeTeam[activeFighterIndex]} получил урон: {enemyDamages[currentEnemyIndex] - 10}");
}
break;
case 3:
pokedexHP[activeFighterIndex] -= enemyDamages[currentEnemyIndex];
Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений.");
Console.WriteLine($"{activeTeam[activeFighterIndex]} получил урон: {enemyDamages[currentEnemyIndex]}");
break;
}
if (pokedexHP[activeFighterIndex] <= 0)
{
pokedexHP[activeFighterIndex] = 0;
if((pokedexHP[0] > 0 | pokedexHP[1] > 0 | pokedexHP[2] > 0))
{Console.WriteLine($"{activeTeam[activeFighterIndex]} нокаутирован. Выберите другого бойца.");
Console.WriteLine("--- Ваша команда ---");
for (int i = 0; i < activeTeam.Length; i++)
{
Console.WriteLine($" {i + 1}. {activeTeam[i]} HP: {pokedexHP[i]}");
}
do
{
Console.Write("Введите номер замены: ");
attackChoice = int.Parse(Console.ReadLine());
if (attackChoice >= 1 && attackChoice <= 3 && pokedexHP[attackChoice - 1] <= 0)
Console.WriteLine($"{activeTeam[attackChoice - 1]} в нокауте. Выберите другого бойца.");
else if (attackChoice < 1 || attackChoice > 3)
Console.WriteLine("Неверный номер. Введите число от 1 до 3.");
} while (attackChoice < 1 | attackChoice > 3 | pokedexHP[attackChoice - 1] <= 0);
if (pokedexHP[attackChoice - 1] > 0)
{
activeFighterIndex = attackChoice - 1;
Console.WriteLine($"Ваш текущий боец: {activeTeam[activeFighterIndex]} (HP: {pokedexHP[activeFighterIndex]})");
}
}
else
{
Console.WriteLine($"Команда потерпела поражение от {enemyNames[currentEnemyIndex]}. Попробуйте еще раз.");
break;
}
}
Console.WriteLine("----------------------------------------------------------------------");
Console.WriteLine($"Текущий статус: {activeTeam[activeFighterIndex]} (HP: {pokedexHP[activeFighterIndex]}) | {enemyNames[currentEnemyIndex]} (HP: {enemyHPs[currentEnemyIndex]})\n");
}
if (pokedexHP[0] == 0 && pokedexHP[1] == 0 && pokedexHP[2] == 0)
break;
currentEnemyIndex++;
}
if((pokedexHP[0] > 0 | pokedexHP[1] > 0 | pokedexHP[2] > 0))
{
Console.WriteLine("\n======================================================================");
Console.WriteLine("=== ТУРНИР ОКОНЧЕН ===");
Console.WriteLine("Вы победили всех боссов Лиги и стали Чемпионом!");
Console.WriteLine("======================================================================");
}


