Добавлены еще задание из Lesson и stage

This commit is contained in:
GREYCATNERO
2026-09-15 08:01:55 +03:00
parent 4dd4380b31
commit 5c25b5b03a
21 changed files with 1134 additions and 13 deletions
View File
+255
View File
@@ -0,0 +1,255 @@
using System;
using System.Collections.Generic;
namespace ConsoleApp1
{
internal class Program
{
public static void Main(string[] args)
{
// ================= ЭТАП 1: РЕГИСТРАЦИЯ =================
Console.WriteLine("=== РЕГИСТРАЦИЯ НА СЕЗОН ЛИГИ ===");
string[] activeTeam = new string[3];
int[] pokedexHP = new int[3];
int[] pokedexDamage = new int[3];
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();
}
List<string> backpack = new List<string>();
backpack.Add("Зелье HP");
backpack.Add("Суперзелье");
backpack.Add("Антидот");
Console.WriteLine("Вы упаковали походную сумку тренера.");
Console.WriteLine($"Предметов в инвентаре изначально: {backpack.Count}");
// ================= ЭТАП 2: ОТСЧЁТ =================
Console.Clear();
Console.WriteLine("======================================================================");
Console.WriteLine("Подготовка завершена! Ворота Арены открываются через...");
for (int i = 3; i >= 1; i--)
{
Console.WriteLine($"{i}...");
}
Console.WriteLine();
// ================= БАЗА БОССОВ =================
string[] enemyNames = { "Мяут", "Геодуд", "Гарчомп" };
int[] enemyHPs = { 40, 65, 90 };
int[] enemyDamages = { 10, 15, 25 };
int[] enemyTypes = { 3, 1, 2 }; // 1-Боевой, 2-Стальной, 3-Обычный
int currentEnemyIndex = 0;
int activeFighterIndex = 0;
// ================= ЭТАП 3: ТУРНИР =================
while (currentEnemyIndex < 3 && AnyAlive(pokedexHP))
{
if (pokedexHP[activeFighterIndex] <= 0)
activeFighterIndex = FindAlive(pokedexHP);
Console.WriteLine("======================================================================");
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-while: валидация выбора ---
int choice;
do
{
Console.Write("Выберите действие (1 - Атака, 2 - Сумка, 3 - Смена Покемона): ");
choice = int.Parse(Console.ReadLine());
} while (choice < 1 || choice > 3);
bool validAction = true;
switch (choice)
{
case 1: // АТАКА
Console.Write("Проверка точности (1 - Критический урон, 0 - Обычный): ");
int crit = int.Parse(Console.ReadLine());
int dmg = pokedexDamage[activeFighterIndex];
if (crit == 1)
{
dmg += 15;
Console.WriteLine($"Результат: Критический удар! Нанесено урона: {dmg}");
}
else
{
Console.WriteLine($"Результат: Базовый урон: {dmg}");
}
enemyHPs[currentEnemyIndex] -= dmg;
break;
case 2: // СУМКА
if (backpack.Count == 0)
{
Console.WriteLine("Сумка пуста! Использовать нечего.");
validAction = false;
break;
}
Console.WriteLine("--- Содержимое вашей сумки ---");
foreach (string item in backpack)
{
Console.WriteLine($"[Предмет] -> {item}");
}
Console.Write("Какой предмет использовать? Введите название: ");
string chosenItem = Console.ReadLine();
if (backpack.Contains(chosenItem))
{
backpack.Remove(chosenItem);
if (chosenItem == "Зелье HP")
{
pokedexHP[activeFighterIndex] += 30;
Console.WriteLine($"Результат: {activeTeam[activeFighterIndex]} восстановил 30 HP! Предмет удален из сумки.");
}
else
{
Console.WriteLine($"Результат: {chosenItem} использован! Предмет удален из сумки.");
}
}
else
{
Console.WriteLine("Такого предмета в сумке нет!");
validAction = false;
}
break;
case 3: // СМЕНА
Console.WriteLine("--- Ваша команда ---");
for (int i = 0; i < 3; i++)
{
Console.WriteLine($"{i}: {activeTeam[i]} (HP: {pokedexHP[i]})");
}
Console.Write("Введите индекс нового бойца: ");
int newIdx = int.Parse(Console.ReadLine());
if (newIdx >= 0 && newIdx < 3 && pokedexHP[newIdx] > 0 && newIdx != activeFighterIndex)
{
activeFighterIndex = newIdx;
Console.WriteLine($"Активный боец сменён на {activeTeam[activeFighterIndex]}.");
}
else
{
Console.WriteLine("Неверный выбор!");
validAction = false;
}
break;
}
if (!validAction) continue;
// --- Проверка нокаута врага ---
if (enemyHPs[currentEnemyIndex] <= 0)
{
enemyHPs[currentEnemyIndex] = 0;
Console.WriteLine($"Дикий {enemyNames[currentEnemyIndex]} нокаутирован! Вы переходите на следующий этап!");
break;
}
// --- Ход врага ---
Console.WriteLine();
Console.WriteLine($"Дикий {enemyNames[currentEnemyIndex]} проводит контратаку!");
int baseIn = enemyDamages[currentEnemyIndex];
int finalIn;
switch (enemyTypes[currentEnemyIndex])
{
case 1:
finalIn = baseIn * 2;
Console.WriteLine("Расчёт: Боевой тип! Урон удваивается.");
break;
case 2:
finalIn = baseIn - 10;
if (finalIn < 0) finalIn = 0;
Console.WriteLine("Расчёт: Стальной тип! Урон снижен на 10.");
break;
default:
finalIn = baseIn;
Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений.");
break;
}
pokedexHP[activeFighterIndex] -= finalIn;
Console.WriteLine($"{activeTeam[activeFighterIndex]} получил урон: {finalIn}");
Console.WriteLine("----------------------------------------------------------------------");
Console.WriteLine($"Текущий статус: {activeTeam[activeFighterIndex]} (HP: {pokedexHP[activeFighterIndex]}) | {enemyNames[currentEnemyIndex]} (HP: {enemyHPs[currentEnemyIndex]})");
Console.WriteLine();
// --- Проверка нокаута игрока ---
if (pokedexHP[activeFighterIndex] <= 0)
{
pokedexHP[activeFighterIndex] = 0;
Console.WriteLine($"{activeTeam[activeFighterIndex]} нокаутирован!");
if (AnyAlive(pokedexHP))
{
Console.WriteLine("Выберите нового бойца!");
for (int i = 0; i < 3; i++)
{
Console.WriteLine($"{i}: {activeTeam[i]} (HP: {pokedexHP[i]})");
}
Console.Write("Введите индекс нового бойца: ");
int nextIdx = int.Parse(Console.ReadLine());
while (nextIdx < 0 || nextIdx >= 3 || pokedexHP[nextIdx] <= 0)
{
Console.Write("Неверный выбор. Попробуйте снова: ");
nextIdx = int.Parse(Console.ReadLine());
}
activeFighterIndex = nextIdx;
}
}
}
if (enemyHPs[currentEnemyIndex] <= 0) currentEnemyIndex++;
if (!AnyAlive(pokedexHP)) break;
}
Console.WriteLine();
Console.WriteLine("======================================================================");
Console.WriteLine("=== ТУРНИР ОКОНЧЕН ===");
if (currentEnemyIndex >= 3)
Console.WriteLine("Вы победили всех боссов Лиги и стали Чемпионом!");
else
Console.WriteLine("Ваша команда полностью нокаутирована. Турнир проигран...");
Console.WriteLine("======================================================================");
Console.ReadLine();
}
// Есть ли хоть один живой покемон
static bool AnyAlive(int[] hps)
{
foreach (int h in hps) if (h > 0) return true;
return false;
}
// Индекс первого живого покемона
static int FindAlive(int[] hps)
{
for (int i = 0; i < hps.Length; i++) if (hps[i] > 0) return i;
return 0;
}
}
}