generated from admin/template
Лаб2 шарп
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "stage2", "stage2\stage2.csproj", "{A9E84F86-4AF2-4A73-ACBD-FAF925179F24}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A9E84F86-4AF2-4A73-ACBD-FAF925179F24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A9E84F86-4AF2-4A73-ACBD-FAF925179F24}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A9E84F86-4AF2-4A73-ACBD-FAF925179F24}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A9E84F86-4AF2-4A73-ACBD-FAF925179F24}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,101 @@
|
||||
Console.WriteLine("======================================================================");
|
||||
Console.WriteLine("ИНИЦИАЛИЗАЦИЯ КАРТОЧКИ");
|
||||
Console.WriteLine("---------------------------------------------------------------------");
|
||||
Console.Write("Введите имя поекмона ");
|
||||
string name = Console.ReadLine();
|
||||
Console.Write("Введите название первой атаки ");
|
||||
string attack1Name = Console.ReadLine();
|
||||
Console.Write("Введите название второй атаки ");
|
||||
string attack2Name = Console.ReadLine();
|
||||
Console.Write($"Введите текущее HP {name}: ");
|
||||
int hp = int.Parse(Console.ReadLine());
|
||||
Console.Write($"Введите базовый урон атаки {attack2Name}: ");
|
||||
int attack2BaseDamage = int.Parse(Console.ReadLine());
|
||||
|
||||
Console.WriteLine("---------------------------------------------------------------------");
|
||||
Console.WriteLine("ИСПОЛЬЗОВАНИЕ АТАК");
|
||||
Console.WriteLine("---------------------------------------------------------------------");
|
||||
Console.WriteLine($"[Атака 2: {attack1Name}]");
|
||||
Console.Write("Бросок монеты (1 - Орёл, 0 - Решка): ");
|
||||
int coin1 = int.Parse(Console.ReadLine());
|
||||
if (coin1 == 1)
|
||||
{
|
||||
Console.WriteLine("Результат: Активный Покемон противника парализован!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Результат: Эффект паралича не сработал.");
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine($"[Атака 2: {attack2Name}]");
|
||||
Console.Write("Бросок монеты (1 - Орёл, 0 - Решка): ");
|
||||
int coin2 = int.Parse(Console.ReadLine());
|
||||
|
||||
int finalAttack2Damage = attack2BaseDamage;
|
||||
if (coin2 == 1)
|
||||
{
|
||||
finalAttack2Damage += 10;
|
||||
Console.WriteLine($"Результат: Выпал орёл! Итоговый урон: {finalAttack2Damage}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Результат: Выпала решка! Итоговый урон: {finalAttack2Damage}");
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
Console.WriteLine("ПОЛУЧЕНИЕ УРОНА");
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
|
||||
Console.Write("Введите базовый урон атаки противника: ");
|
||||
int incomingDamage = int.Parse(Console.ReadLine());
|
||||
|
||||
Console.Write("Выберите тип атаки противника (1 - Боевой, 2 - Стальной, 3 - Обычный): ");
|
||||
int attackType = int.Parse(Console.ReadLine());
|
||||
Console.WriteLine();
|
||||
|
||||
int finalIncomingDamage = 0;
|
||||
bool isInputValid = true;
|
||||
|
||||
|
||||
switch (attackType)
|
||||
{
|
||||
case 1:
|
||||
Console.WriteLine("Расчёт: Боевой тип! Урон удваивается (x2).");
|
||||
finalIncomingDamage = incomingDamage * 2;
|
||||
break;
|
||||
case 2:
|
||||
Console.WriteLine("Расчёт: Стальной тип! Урон уменьшается на 20 (Resistance: -20).");
|
||||
finalIncomingDamage = incomingDamage - 20;
|
||||
if (finalIncomingDamage < 0)
|
||||
{
|
||||
finalIncomingDamage = 0;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений.");
|
||||
finalIncomingDamage = incomingDamage;
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Ошибка: Выбран неизвестный тип атаки!");
|
||||
isInputValid = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isInputValid)
|
||||
{
|
||||
Console.WriteLine($"Получено урона: {finalIncomingDamage}");
|
||||
|
||||
hp -= finalIncomingDamage;
|
||||
|
||||
if (hp <= 0)
|
||||
{
|
||||
Console.WriteLine($"{name} нокаутирован!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"{name} выдержал удар! Остаток HP: {hp}");
|
||||
}
|
||||
}
|
||||
Console.WriteLine("======================================================================");
|
||||
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user