Last active
May 16, 2023 16:44
-
-
Save Strelok78/ef3b24d40b9ff85f5c2c0ffecd1d5366 to your computer and use it in GitHub Desktop.
Here is a boss who has a certain number of lives and a certain retaliatory damage. You have 4 spells to deal damage to the boss. The program ends only after the death of the boss or the death of the user.
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
namespace MyCode | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
const string CommandDefenseAura = "1"; | |
const string CommandLayOnHands = "2"; | |
const string CommandMagicPower = "3"; | |
const string CommandUseWarhammer = "4"; | |
const string CommandUseSmite = "5"; | |
Random random = new Random(); | |
int lowHealthPoints = 0; | |
int bossMaxHealthPoints = 250; | |
int bossMinHealthPoints = 100; | |
int bossHealthPoints = random.Next(bossMinHealthPoints, bossMaxHealthPoints); | |
int bossDamage; | |
int bossMaxDamage = 20; | |
int heroMinHealthPoints = 10; | |
int heroMaxHealthPoints = 80; | |
int heroHealthPoints = random.Next(heroMinHealthPoints, heroMaxHealthPoints); | |
int heroWarhammerMaxDamage = 10; | |
int heroWarhammerDamage; | |
int heroHeal = 15; | |
int heroSmiteDamage = 10; | |
int magicExtraDamage = 10; | |
int heroDefenseAura = 0; | |
int heroSmiteCounter = 5; | |
bool heroMagicWeaponIsActive = false; | |
bool defenseAuraIsActive = false; | |
bool enteredTextIsUnknown = false; | |
string enteredCommand; | |
string menu = $"{CommandDefenseAura} - to use Defense Aura, Aura gives you a bubble defense for 3 rounds (you don not get damage for 3 rounds)\n" + | |
$"{CommandLayOnHands} - to use healing spell and restore {heroHeal} HP\n" + | |
$"{CommandMagicPower} - to add Magic Power ({magicExtraDamage} Damage) to your Warhammer\n" + | |
$"{CommandUseWarhammer} - to attack using Warhammer (up to {heroWarhammerMaxDamage} Damage)\n" + | |
$"{CommandUseSmite} - to use Smite Damage ({heroSmiteDamage} Damage), but only {heroSmiteCounter} times\n" + | |
$"Type any Key to show menu again.\n"; | |
Console.WriteLine($"You are in a final room of the dungeon!\n" + | |
$"You are The Mighty Paladin and you have to kill the dungeon boss!\n" + | |
$"For that you can use next spells:\n" + menu); | |
while (heroHealthPoints >= lowHealthPoints && bossHealthPoints >= lowHealthPoints) | |
{ | |
heroWarhammerDamage = random.Next(heroWarhammerMaxDamage); | |
bossDamage = random.Next(bossMaxDamage); | |
Console.WriteLine($"You have {heroHealthPoints} HP, Boss have {bossHealthPoints} HP"); | |
Console.WriteLine("Enter your command!"); | |
enteredCommand = Console.ReadLine(); | |
switch (enteredCommand) | |
{ | |
case CommandDefenseAura: | |
int maxDefensLength = 3; | |
defenseAuraIsActive = true; | |
heroDefenseAura = maxDefensLength; | |
break; | |
case CommandLayOnHands: | |
if (heroDefenseAura > 0) | |
{ | |
heroHealthPoints += heroHeal; | |
heroDefenseAura--; | |
} | |
else | |
{ | |
Console.WriteLine("You cant use Lay On Hands spell without Defense Aura on you!\n"); | |
} | |
break; | |
case CommandMagicPower: | |
Console.WriteLine("You are praying to God to enhance your weapon power for the next time you use Warhammer (this round you can't attack!)\n"); | |
heroMagicWeaponIsActive = true; | |
break; | |
case CommandUseWarhammer: | |
if (heroMagicWeaponIsActive) | |
{ | |
bossHealthPoints -= heroWarhammerDamage + magicExtraDamage; | |
heroMagicWeaponIsActive = false; | |
Console.WriteLine($"Boss get {heroSmiteDamage} + {magicExtraDamage} damage"); | |
} | |
else | |
{ | |
bossHealthPoints -= heroWarhammerDamage; | |
Console.WriteLine($"Boss get {heroWarhammerDamage} damage"); | |
} | |
break; | |
case CommandUseSmite: | |
if (heroSmiteCounter > 0) | |
{ | |
bossHealthPoints -= heroSmiteDamage; | |
heroSmiteCounter--; | |
Console.WriteLine($"Boss get {heroSmiteDamage} damage"); | |
Console.WriteLine($"You have left {heroSmiteCounter} Smites!\n"); | |
} | |
else | |
{ | |
Console.WriteLine("Smite is unavailable!\n"); | |
} | |
break; | |
default: | |
Console.WriteLine(menu); | |
enteredTextIsUnknown = true; | |
break; | |
} | |
if (enteredTextIsUnknown == true) | |
{ | |
if (defenseAuraIsActive) | |
{ | |
Console.WriteLine($"Defense Aura is Active! You have {heroDefenseAura} rounds of Defense Aura left\n"); | |
} | |
else | |
{ | |
heroHealthPoints -= bossDamage; | |
Console.WriteLine($"Hero get {bossDamage} damage"); | |
} | |
if (heroHealthPoints > heroMaxHealthPoints) | |
{ | |
heroHealthPoints = heroMaxHealthPoints; | |
heroDefenseAura = 0; | |
Console.WriteLine("Your HP is on Max, Defense is deactivated!"); | |
} | |
if (heroDefenseAura == 0) | |
{ | |
defenseAuraIsActive = false; | |
} | |
} | |
else | |
{ | |
enteredTextIsUnknown = false; | |
} | |
} | |
if (heroHealthPoints <= lowHealthPoints && bossHealthPoints <= lowHealthPoints) | |
{ | |
Console.WriteLine("WOW! It is a draw!"); | |
} | |
else if (heroHealthPoints <= lowHealthPoints) | |
{ | |
Console.WriteLine("Hero is dead! You lose!"); | |
} | |
else if (bossHealthPoints <= lowHealthPoints) | |
{ | |
Console.WriteLine("Boss is dead! You win!"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment