Created
August 23, 2025 04:48
-
-
Save marakay675/c4253fb88c878b8268fabaadb3f2cf07 to your computer and use it in GitHub Desktop.
homework_Boss_fight
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace homework_Boss_fight | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Welcome to the Boss Fight!"); | |
Console.WriteLine("You are a hero with various skills to defeat the Boss."); | |
Console.WriteLine("You have the following skills:"); | |
Console.WriteLine("1. Normal Attack"); | |
Console.WriteLine("2. Fireball (uses mana)"); | |
Console.WriteLine("3. Explosion (can only be used after Fireball)"); | |
Console.WriteLine("4. Healing (restores health and mana, limited uses)"); | |
Console.WriteLine("Press enter to begin the fight!"); | |
Console.ReadLine(); | |
Console.Clear(); | |
Random random = new Random(); | |
int heroHealth = 100; | |
int heroMana = 50; | |
int maxRandomAttack = 20; | |
int minRandomAttack = 5; | |
int bossHealth = 250; | |
int bossAttack = 15; | |
int healingUses = 3; | |
int healthRestored = 20; | |
int manaRestored = 10; | |
bool fireballUsed = false; | |
int fireballManaCost = 25; | |
int fireballDamage = 30; | |
int explosionDamage = 50; | |
int choice1 = 1; | |
int choice2 = 2; | |
int choice3 = 3; | |
int choice4 = 4; | |
while (heroHealth > 0 && bossHealth > 0) | |
{ | |
int heroAttack = random.Next(minRandomAttack, maxRandomAttack); | |
Console.ForegroundColor = ConsoleColor.Red; | |
Console.Write($"Your health: {heroHealth}. "); | |
Console.ForegroundColor = ConsoleColor.Blue; | |
Console.Write($"Your mana: {heroMana}."); | |
Console.ForegroundColor = ConsoleColor.Green; | |
Console.WriteLine($" You have {healingUses} healing uses left. "); | |
Console.ResetColor(); | |
Console.WriteLine($"Boss's health: {bossHealth}."); | |
Console.WriteLine("Choose your action:"); | |
Console.WriteLine($"{choice1}. Normal Attack"); | |
Console.WriteLine($"{choice2}. Fireball (costs {fireballManaCost} mana)"); | |
Console.WriteLine($"{choice3}. Explosion (can only be used after Fireball)"); | |
Console.WriteLine($"{choice4}. Healing (restores {healthRestored} health and {manaRestored} mana, limited uses)"); | |
string actionChoice = Console.ReadLine(); | |
switch (actionChoice) | |
{ | |
case "1": | |
bossHealth -= heroAttack; | |
Console.WriteLine($"You dealt {heroAttack} damage to the Boss. Boss's health = {bossHealth}."); | |
break; | |
case "2": | |
if (heroMana < fireballManaCost) | |
{ | |
Console.WriteLine("Not enough mana to cast Fireball. You missed your turn!"); | |
break; | |
} | |
heroMana -= fireballManaCost; | |
bossHealth -= fireballDamage; | |
fireballUsed = true; | |
Console.WriteLine($"You cast Fireball and dealt {fireballDamage} damage to the Boss. Boss's health = {bossHealth}. Your mana = {heroMana}."); | |
break; | |
case "3": | |
if (fireballUsed == true) | |
{ | |
bossHealth -= explosionDamage; | |
fireballUsed = false; | |
Console.WriteLine($"You used Explosion and dealt {explosionDamage} damage to the Boss. Boss's health = {bossHealth}. Your mana = {heroMana}."); | |
} | |
else | |
{ | |
Console.WriteLine("You can only use Explosion after using Fireball. You missed your turn!"); | |
} | |
break; | |
case "4": | |
if (healingUses > 0) | |
{ | |
heroHealth += healthRestored; | |
heroMana += manaRestored; | |
if (heroHealth > 100) | |
{ | |
heroHealth = 100; | |
} | |
if (heroMana > 50) | |
{ | |
heroMana = 50; | |
} | |
healingUses--; | |
Console.WriteLine($"You used Healing. Your health = {heroHealth}. Your mana = {heroMana}. You have {healingUses} healing uses left."); | |
} | |
else | |
{ | |
Console.WriteLine("You have no healing uses left. You missed your turn!"); | |
} | |
break; | |
default: | |
Console.WriteLine("Invalid choice! You missed your turn."); | |
break; | |
} | |
if (bossHealth <= 0 && heroHealth <= 0) | |
{ | |
Console.WriteLine("Both you and the Boss have been defeated!"); | |
Console.WriteLine("It's a draw!"); | |
return; | |
} | |
if (bossHealth <= 0) | |
{ | |
Console.WriteLine("The Boss has been defeated! You are victorious!"); | |
return; | |
} | |
if (heroHealth > 0) | |
{ | |
heroHealth -= bossAttack; | |
Console.WriteLine($"The Boss attacked you and dealt {bossAttack} damage. Your health = {heroHealth}."); | |
} | |
if (heroHealth <= 0) | |
{ | |
Console.WriteLine("You have been defeated by the Boss!"); | |
return; | |
} | |
Console.WriteLine(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment