generated from admin/template
Добавить works/lab-03
This commit is contained in:
@@ -0,0 +1,97 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConsoleApp1
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
string pokemon1Name = "Пикачу";
|
||||||
|
int pokemon1Hp = 50;
|
||||||
|
int pokemon1Attack = 12;
|
||||||
|
string pokemon2Name = "Булбазавр";
|
||||||
|
int pokemon2Hp = 55;
|
||||||
|
int pokemon2Attack = 10;
|
||||||
|
int roundNumber = 1;
|
||||||
|
int consFight;
|
||||||
|
|
||||||
|
Console.WriteLine("Приготовьтесь!");
|
||||||
|
for (int i = 1; i < 4; i++)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{i}...");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ===");
|
||||||
|
Console.WriteLine(
|
||||||
|
$"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
||||||
|
consFight = int.Parse(Console.ReadLine());
|
||||||
|
if (consFight == 1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (consFight == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректная команда! Попробуйте снова.");
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (true);
|
||||||
|
|
||||||
|
if (consFight == 1)
|
||||||
|
{
|
||||||
|
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||||
|
pokemon2Hp -= pokemon1Attack;
|
||||||
|
if (pokemon2Hp >= 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pokemon2Hp = 0;
|
||||||
|
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||||
|
Console.WriteLine($"{pokemon2Name} потерял сознание!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
pokemon1Hp -= pokemon2Attack;
|
||||||
|
if (pokemon1Hp >= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pokemon1Hp = 0;
|
||||||
|
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
|
||||||
|
Console.WriteLine($"{pokemon1Name} потерял сознание!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp})");
|
||||||
|
roundNumber += 1;
|
||||||
|
}
|
||||||
|
Console.WriteLine("=== БОЙ ОКОНЧЕН ===");
|
||||||
|
if (pokemon1Hp <= 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Победитель: {pokemon2Name}!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Победитель: {pokemon1Name}!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user