This commit is contained in:
328p
2026-09-23 15:37:36 +03:00
parent b8fbd25206
commit 1f8605dd84
3 changed files with 123 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3", "3\3.csproj", "{3E2A654E-75FE-4BE6-90B3-635792DF4439}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3E2A654E-75FE-4BE6-90B3-635792DF4439}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E2A654E-75FE-4BE6-90B3-635792DF4439}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E2A654E-75FE-4BE6-90B3-635792DF4439}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E2A654E-75FE-4BE6-90B3-635792DF4439}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>_3</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+96
View File
@@ -0,0 +1,96 @@
using System;
namespace PokemonBattle
{
class Program
{
static void Main(string[] sender)
{
// задание 2
int userChoice;
do
{
Console.Write("Готовы начать бой? (1 - да, 0 - нет): ");
userChoice = int.Parse(Console.ReadLine());
if (userChoice != 1 && userChoice != 0)
{
Console.WriteLine("Некорректная команда! Попробуйте снова.");
}
} while (userChoice != 1 && userChoice != 0);
if (userChoice == 0)
{
Console.WriteLine("Вы отменили бой!");
return;
}
// задание 1
Console.WriteLine("Приготовьтесь!");
for (int i = 3; i >= 1; i--)
{
Console.WriteLine($"{i}...");
}
Console.WriteLine("БОЙ НАЧИНАЕТСЯ");
string pokemon1Name = "Пикачу";
int pokemon1Hp = 50;
int pokemon1Attack = 12;
string pokemon2Name = "Булбазавр";
int pokemon2Hp = 55;
int pokemon2Attack = 10;
int roundNumber = 1;
Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})\n");
// задание 3
while (pokemon1Hp > 0 && pokemon2Hp > 0)
{
Console.WriteLine($"--- Раунд {roundNumber} ---");
pokemon2Hp -= pokemon1Attack;
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
if (pokemon2Hp <= 0)
{
pokemon2Hp = 0;
Console.WriteLine($"{pokemon2Name} потерял сознание!\n");
break;
}
pokemon1Hp -= pokemon2Attack;
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
if (pokemon1Hp <= 0)
{
pokemon1Hp = 0;
Console.WriteLine($"{pokemon1Name} потерял сознание!\n");
break;
}
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}\n");
roundNumber++;
}
Console.WriteLine("БОЙ ОКОНЧЕН");
if (pokemon1Hp > 0)
{
Console.WriteLine($"Победитель: {pokemon1Name}!");
}
else
{
Console.WriteLine($"Победитель: {pokemon2Name}!");
}
}
}
}