generated from admin/template
сделаны лаба 3,лаба 4 и стейджи 2,3
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
# Лабораторная работа №2
|
||||
|
||||
* **Студент:** Хорошилкина Анна Дмитриевна
|
||||
* **Вариант / Карточка:** [Например: #025 Pikachu]
|
||||
|
||||
---
|
||||
|
||||
## Ключевой код
|
||||
```csharp
|
||||
// Самая важная часть реализации (методы, структуры, логика)
|
||||
public class Card
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Hp { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
//задание 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})");
|
||||
Console.WriteLine();
|
||||
|
||||
//задание 2
|
||||
int userChoice = 1;
|
||||
|
||||
if (userChoice == 0)
|
||||
{
|
||||
Console.WriteLine("Вы отменили бой!");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
|
||||
//задание 3
|
||||
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
||||
{
|
||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||
|
||||
pokemon2Hp -= pokemon1Attack;
|
||||
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||
|
||||
if (pokemon2Hp <= 0)
|
||||
{
|
||||
pokemon2Hp = 0;
|
||||
Console.WriteLine($"{pokemon2Name} потерял сознание!");
|
||||
break;
|
||||
}
|
||||
|
||||
pokemon1Hp -= pokemon2Attack;
|
||||
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
|
||||
|
||||
if (pokemon1Hp <= 0)
|
||||
{
|
||||
pokemon1Hp = 0;
|
||||
Console.WriteLine($"{pokemon1Name} потерял сознание!");
|
||||
break;
|
||||
}
|
||||
|
||||
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}");
|
||||
Console.WriteLine();
|
||||
|
||||
roundNumber++;
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("=== БОЙ ОКОНЧЕН ===");
|
||||
|
||||
if (pokemon1Hp > 0)
|
||||
{
|
||||
Console.WriteLine($"Победитель: {pokemon1Name}!");
|
||||
}
|
||||
else if (pokemon2Hp > 0)
|
||||
{
|
||||
Console.WriteLine($"Победитель: {pokemon2Name}!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Ничья!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Лабораторная работа №2
|
||||
|
||||
* **Студент:** Хорошилкина Анна Дмитриевна
|
||||
* **Вариант / Карточка:** [Например: #025 Pikachu]
|
||||
|
||||
---
|
||||
|
||||
## Ключевой код
|
||||
```csharp
|
||||
// Самая важная часть реализации (методы, структуры, логика)
|
||||
public class Card
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Hp { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
string[] activeTeam = new string[3];
|
||||
|
||||
Console.WriteLine("=== РЕГИСТРАЦИЯ КОМАНДЫ ===");
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Console.Write("Введите имя покемона №" + (i + 1) + ": ");
|
||||
activeTeam[i] = Console.ReadLine();
|
||||
}
|
||||
|
||||
Console.WriteLine("\n--- Ваша команда на этот бой ---");
|
||||
Console.WriteLine("1. " + activeTeam[0]);
|
||||
Console.WriteLine("2. " + activeTeam[1]);
|
||||
Console.WriteLine("3. " + activeTeam[2]);
|
||||
|
||||
Console.WriteLine();
|
||||
|
||||
List<string> backpack = new List<string>();
|
||||
|
||||
backpack.Add("Зелье HP");
|
||||
backpack.Add("Покебол");
|
||||
backpack.Add("Антидот");
|
||||
|
||||
Console.WriteLine("=== ИНВЕНТАРЬ ТРЕНЕРА ===");
|
||||
Console.WriteLine("Вы положили вещи в сумку. Предметов в инвентаре: " + backpack.Count);
|
||||
|
||||
backpack.Remove("Покебол");
|
||||
|
||||
Console.WriteLine("Вы использовали один Покебол для поимки дикого покемона!");
|
||||
Console.WriteLine("Обновленный инвентарь. Осталось предметов: " + backpack.Count);
|
||||
|
||||
Console.WriteLine("\n--- Содержимое вашей сумки ---");
|
||||
|
||||
foreach (string item in backpack)
|
||||
{
|
||||
Console.WriteLine("[Предмет] -> " + item);
|
||||
}
|
||||
|
||||
Console.WriteLine("=============================");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
string name = "Пикачу";
|
||||
string attack1Name = "Электроудар";
|
||||
string attack2Name = "Быстрая Атака";
|
||||
|
||||
Console.WriteLine("======================================================================");
|
||||
Console.WriteLine("ИНИЦИАЛИЗАЦИЯ КАРТОЧКИ");
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
|
||||
Console.Write("Введите текущее HP Пикачу: ");
|
||||
string hpInput = Console.ReadLine();
|
||||
int hp = int.Parse(hpInput);
|
||||
|
||||
Console.Write("Введите базовый урон атаки \"Быстрая Атака\": ");
|
||||
string damageInput = Console.ReadLine();
|
||||
int attack2BaseDamage = int.Parse(damageInput);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
Console.WriteLine("ИСПОЛЬЗОВАНИЕ АТАК");
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
|
||||
Console.WriteLine("[Атака 1: " + attack1Name + "]");
|
||||
Console.Write("Бросок монеты (1 - Орёл, 0 - Решка): ");
|
||||
string coin1Input = Console.ReadLine();
|
||||
int coin1 = int.Parse(coin1Input);
|
||||
|
||||
if (coin1 == 1)
|
||||
{
|
||||
Console.WriteLine("Результат: Активный Покемон противника парализован!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Результат: Эффект паралича не сработал.");
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("[Атака 2: " + attack2Name + "]");
|
||||
Console.Write("Бросок монеты (1 - Орёл, 0 - Решка): ");
|
||||
string coin2Input = Console.ReadLine();
|
||||
int coin2 = int.Parse(coin2Input);
|
||||
|
||||
int finalAttackDamage;
|
||||
|
||||
if (coin2 == 1)
|
||||
{
|
||||
finalAttackDamage = attack2BaseDamage + 10;
|
||||
Console.WriteLine("Результат: Выпал орёл! Итоговый урон: " + finalAttackDamage);
|
||||
}
|
||||
else
|
||||
{
|
||||
finalAttackDamage = attack2BaseDamage;
|
||||
Console.WriteLine("Результат: Выпала решка! Итоговый урон: " + finalAttackDamage);
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
Console.WriteLine("ПОЛУЧЕНИЕ УРОНА");
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
|
||||
Console.Write("Введите базовый урон атаки противника: ");
|
||||
string incomingInput = Console.ReadLine();
|
||||
int incomingDamage = int.Parse(incomingInput);
|
||||
|
||||
Console.Write("Выберите тип атаки противника (1 - Боевой, 2 - Стальной, 3 - Обычный): ");
|
||||
string typeInput = Console.ReadLine();
|
||||
int attackType = int.Parse(typeInput);
|
||||
|
||||
int finalIncomingDamage;
|
||||
|
||||
switch (attackType)
|
||||
{
|
||||
case 1:
|
||||
finalIncomingDamage = incomingDamage * 2;
|
||||
Console.WriteLine("Расчёт: Боевой тип! Урон удваивается (x2).");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
finalIncomingDamage = incomingDamage - 20;
|
||||
|
||||
if (finalIncomingDamage < 0)
|
||||
{
|
||||
finalIncomingDamage = 0;
|
||||
}
|
||||
|
||||
Console.WriteLine("Расчёт: Стальной тип! Урон уменьшается на 20 (Resistance: -20).");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
finalIncomingDamage = incomingDamage;
|
||||
Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений.");
|
||||
break;
|
||||
|
||||
default:
|
||||
finalIncomingDamage = 0;
|
||||
Console.WriteLine("Ошибка: Выбран неизвестный тип атаки!");
|
||||
break;
|
||||
}
|
||||
|
||||
Console.WriteLine("Получено урона: " + finalIncomingDamage);
|
||||
|
||||
hp = hp - finalIncomingDamage;
|
||||
|
||||
if (hp <= 0)
|
||||
{
|
||||
Console.WriteLine("Пикачу нокаутирован!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Пикачу выдержал удар! Остаток HP: " + hp);
|
||||
}
|
||||
|
||||
Console.WriteLine("======================================================================");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
string stage;
|
||||
string name;
|
||||
string category;
|
||||
string attack1Name;
|
||||
string attack1Desc;
|
||||
string attack2Name;
|
||||
string attack2Desc;
|
||||
string weakness;
|
||||
string resistance;
|
||||
|
||||
Console.WriteLine("======================================================================");
|
||||
Console.WriteLine("ИНИЦИАЛИЗАЦИЯ КАРТОЧКИ ПОКЕМОНА");
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
|
||||
Console.Write("Введите стадию развития: ");
|
||||
stage = Console.ReadLine();
|
||||
|
||||
Console.Write("Введите имя покемона: ");
|
||||
name = Console.ReadLine();
|
||||
|
||||
Console.Write("Введите вид покемона: ");
|
||||
category = Console.ReadLine();
|
||||
|
||||
Console.Write("Введите название 1-й атаки: ");
|
||||
attack1Name = Console.ReadLine();
|
||||
|
||||
Console.Write("Введите эффект 1-й атаки: ");
|
||||
attack1Desc = Console.ReadLine();
|
||||
|
||||
Console.Write("Введите базовый урон 1-й атаки: ");
|
||||
int attack1BaseDamage = int.Parse(Console.ReadLine());
|
||||
|
||||
Console.Write("Введите название 2-й атаки: ");
|
||||
attack2Name = Console.ReadLine();
|
||||
|
||||
Console.Write("Введите эффект 2-й атаки: ");
|
||||
attack2Desc = Console.ReadLine();
|
||||
|
||||
Console.Write("Введите базовый урон 2-й атаки: ");
|
||||
int attack2BaseDamage = int.Parse(Console.ReadLine());
|
||||
|
||||
Console.Write("Введите уязвимость: ");
|
||||
weakness = Console.ReadLine();
|
||||
|
||||
Console.Write("Введите устойчивость: ");
|
||||
resistance = Console.ReadLine();
|
||||
|
||||
Console.Write("Введите текущее HP: ");
|
||||
int hp = int.Parse(Console.ReadLine());
|
||||
|
||||
string enemyName = "Булбазавр";
|
||||
int enemyHp = 70;
|
||||
int enemyBaseDamage = 15;
|
||||
|
||||
int roundNumber = 1;
|
||||
bool isEnemyDebuffed = false;
|
||||
|
||||
Console.Clear();
|
||||
|
||||
Console.WriteLine("======================================================================");
|
||||
Console.WriteLine("[" + stage + "] " + name + " ОЖ: " + hp);
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
Console.WriteLine("Вид: " + category);
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
Console.WriteLine("[Атака 1] " + attack1Name + " Урон: " + attack1BaseDamage);
|
||||
Console.WriteLine("Эффект: " + attack1Desc);
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("[Атака 2] " + attack2Name + " Урон: " + attack2BaseDamage + "+");
|
||||
Console.WriteLine("Эффект: " + attack2Desc);
|
||||
Console.WriteLine("----------------------------------------------------------------------");
|
||||
Console.WriteLine("Слабость: " + weakness + " | Устойчивость: " + resistance);
|
||||
Console.WriteLine("======================================================================");
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Приготовьтесь к дуэли!");
|
||||
|
||||
for (int i = 3; i >= 1; i--)
|
||||
{
|
||||
Console.WriteLine(i + "...");
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("=== СТАРТ ДУЭЛИ: " + name + " (HP: " + hp + ") VS " + enemyName + " (HP: " + enemyHp + ") ===");
|
||||
|
||||
while (hp > 0 && enemyHp > 0)
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("--- Раунд " + roundNumber + " ---");
|
||||
|
||||
int actionChoice;
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Выберите действие (1 - " + attack1Name + ", 2 - " + attack2Name + "): ");
|
||||
actionChoice = int.Parse(Console.ReadLine());
|
||||
|
||||
if (actionChoice != 1 && actionChoice != 2)
|
||||
{
|
||||
Console.WriteLine("Ошибка! Выберите 1 или 2.");
|
||||
}
|
||||
|
||||
} while (actionChoice != 1 && actionChoice != 2);
|
||||
|
||||
int playerDamage = 0;
|
||||
|
||||
if (actionChoice == 1)
|
||||
{
|
||||
Console.Write("[" + attack1Name + "] Проверка спецэффекта (1 - Сработал, 0 - Нет): ");
|
||||
int effect = int.Parse(Console.ReadLine());
|
||||
|
||||
playerDamage = attack1BaseDamage;
|
||||
|
||||
if (effect == 1)
|
||||
{
|
||||
isEnemyDebuffed = true;
|
||||
Console.WriteLine("Результат: Спецэффект сработал! " + enemyName + " потерял возможность атаковать!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Результат: Спецэффект не сработал.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Write("[" + attack2Name + "] Проверка условия спецэффекта (1 - Успех, 0 - Нет): ");
|
||||
int effect = int.Parse(Console.ReadLine());
|
||||
|
||||
if (effect == 1)
|
||||
{
|
||||
playerDamage = attack2BaseDamage + 10;
|
||||
Console.WriteLine("Результат: Условие выполнено! Нанесен усиленный урон: " + playerDamage);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerDamage = attack2BaseDamage;
|
||||
Console.WriteLine("Результат: Базовый урон: " + playerDamage);
|
||||
}
|
||||
}
|
||||
|
||||
enemyHp = enemyHp - playerDamage;
|
||||
|
||||
if (enemyHp <= 0)
|
||||
{
|
||||
enemyHp = 0;
|
||||
Console.WriteLine(enemyName + " нокаутирован!");
|
||||
break;
|
||||
}
|
||||
|
||||
if (isEnemyDebuffed == true)
|
||||
{
|
||||
Console.WriteLine(enemyName + " пропускает ход из-за эффекта атаки!");
|
||||
isEnemyDebuffed = false;
|
||||
roundNumber++;
|
||||
continue;
|
||||
}
|
||||
|
||||
Console.Write("Выберите тип атаки противника (1 - Уязвимость, 2 - Устойчивость, 3 - Обычный): ");
|
||||
int attackType = int.Parse(Console.ReadLine());
|
||||
|
||||
int finalIncomingDamage;
|
||||
|
||||
switch (attackType)
|
||||
{
|
||||
case 1:
|
||||
finalIncomingDamage = enemyBaseDamage * 2;
|
||||
Console.WriteLine("Расчёт: Уязвимость (" + weakness + ")! Урон удваивается (x2).");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
finalIncomingDamage = enemyBaseDamage - 20;
|
||||
|
||||
if (finalIncomingDamage < 0)
|
||||
{
|
||||
finalIncomingDamage = 0;
|
||||
}
|
||||
|
||||
Console.WriteLine("Расчёт: Устойчивость (" + resistance + ")! Урон уменьшается на 20.");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
finalIncomingDamage = enemyBaseDamage;
|
||||
Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений.");
|
||||
break;
|
||||
|
||||
default:
|
||||
finalIncomingDamage = 0;
|
||||
Console.WriteLine("Ошибка: Выбран неизвестный тип атаки!");
|
||||
break;
|
||||
}
|
||||
|
||||
hp = hp - finalIncomingDamage;
|
||||
|
||||
if (hp <= 0)
|
||||
{
|
||||
hp = 0;
|
||||
Console.WriteLine(name + " нокаутирован!");
|
||||
break;
|
||||
}
|
||||
|
||||
Console.WriteLine("Итог раунда: " + name + " HP: " + hp + " | " + enemyName + " HP: " + enemyHp);
|
||||
|
||||
roundNumber++;
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("======================================================================");
|
||||
Console.WriteLine("=== ДУЭЛЬ ОКОНЧЕНА ===");
|
||||
|
||||
if (hp > 0)
|
||||
{
|
||||
Console.WriteLine("Победитель: " + name + "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Победитель: " + enemyName + "!");
|
||||
}
|
||||
|
||||
Console.WriteLine("======================================================================");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user