using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
static void NewGame(Hero hero)
{
Console.Clear();
Console.WriteLine("Welcome traveler!\n");
string playerName;
{
playerName = Ask("What is your name, adventurer? ");
} while (!AskYesOrNo($"So, {playerName} it is? ")) ;
hero.Name = playerName;
hero.Location = "tableroom";
TableRoom(hero);
}
Hero hero = new Hero();
while (hero.Location != "quit")
{
if (hero.Location == "newgame")
{
NewGame(hero);
}
else if (hero.Location == "tableroom")
{
TableRoom(hero);
}
else if (hero.Location == "corridor")
{
Corridor(hero);
}
else if (hero.Location == "lockedroom")
{
LockedRoom(hero);
}
else if (hero.Location == "thirdroom")
{
ThirdRoom(hero);
}
else if (hero.Location == "lobby")
{
Lobby(hero);
}
else if (hero.Location == "backoutside")
{
BackOutside(hero);
}
else if (hero.Location == "bossfight")
{
BossFight(hero);
}
else if (hero.Location == "win")
{
Win(hero);
}
else if (hero.Location == "lose")
{
Lose(hero);
}
else if (hero.Location == "gameover")
{
GameOver(hero);
}
else
{
Console.Error.WriteLine($"You forgot to implement {hero.Location}!");
break;
}
}
}
static void TableRoom(Hero hero)
{
Console.Clear();
hero.Items.Add("Wooden Sword");
Console.WriteLine("You are equipped with a wooden sword, now go slay monsters.");
Console.WriteLine("In front of you is a stone table with two items on it.");
Console.WriteLine("You can only pick one!\n");
string keyKnife = Ask("Do you want the key or the knife?");
keyKnife = keyKnife.ToLower();
do
{
if (keyKnife == "key")
{
hero.Items.Add("key");
Console.Clear();
Console.WriteLine("You picked up the key.\n");
}
else if (keyKnife == "knife")
{
hero.Items.Add("knife");
Console.Clear();
Console.WriteLine("You picked up the knife.\n");
}
else
{
keyKnife = Ask("Invalid choice. Please select 'key' or 'knife': \n").ToLower();
}
} while (keyKnife != "key" && keyKnife != "knife");
hero.Location = "corridor";
}
static void Corridor(Hero hero)
{
Console.WriteLine("You exit the room and find yourself standing in a dark hallway");
Console.WriteLine("You can either enter another room on your right side, ");
Console.WriteLine("or continue down the hallway on your left.\n");
do
{
string leftOrRight = Ask("Do you want to go left or right? ");
leftOrRight = leftOrRight.ToLower();
if (hero.Items.Contains("key") && leftOrRight == "right")
{
hero.Location = "lockedroom";
hero.Items.Remove("key");
}
else if (hero.Items.Contains("knife") && leftOrRight == "right")
{
Console.Clear();
Console.WriteLine("You need a key to enter the door!\n");
continue;
}
else
{
hero.Location = "thirdroom";
}
} while (hero.Location == "corridor");
}
static void LockedRoom(Hero hero)
{
Console.Clear();
Console.WriteLine("You entered the locked room and find a shiny sword!");
if (AskYesOrNo("Do you want it instead of your wooden sword?"))
{
hero.Items.Remove("Wooden Sword");
hero.Items.Add("shinysword");
}
hero.Location = "thirdroom";
}
static void ThirdRoom(Hero hero)
{
Console.Clear();
Console.WriteLine("On the floor before you lies a lifeless corpse");
Console.WriteLine("Its hand is clasped around something shiny.\n");
if (AskYesOrNo("Do you want to loot the corpse?"))
{
Console.Clear();
Console.WriteLine("You picked up an old silver necklace.");
if (RollD6() >= 3)
{
Console.WriteLine("A warm feeling spreads over your body.");
hero.Items.Add("blessed amulet");
}
else
{
Console.WriteLine("A cold shiver runs down your spine.");
hero.Items.Add("cursed amulet");
}
}
else
{
Console.Clear();
}
Console.WriteLine("You leave the corpse and continue into the next room.");
Console.Read();
hero.Location = "lobby";
}
static void Lobby(Hero hero)
{
Console.Clear();
Console.WriteLine("You see the exit door but there's zombie running towards you.\n");
while (true)
{
string response = Ask("Do you fight the zombie or exit?\n");
response = response.ToLower();
if (response == "fight")
{
if (hero.Items.Contains("Wooden Sword"))
{
if (RollD6() >= 3)
{
hero.Health = 60;
}
else
{
hero.Health = 50;
}
Console.Clear();
hero.Items.Add("axe");
Console.WriteLine("The wooden sword made it difficult to kill the zombie.");
Console.WriteLine("You are now at " + hero.Health +
"hp.");
}
else if (hero.Items.Contains("shinysword"))
{
Console.Clear();
Console.WriteLine("The Shiny Sword killed the zombie immediately.");
}
Console.WriteLine("\nThe zombie dropped an axe on the ground.");
if (AskYesOrNo("Do you want to pick up the axe?"))
{
if (hero.Items.Contains("Wooden Sword"))
{
Console.Clear();
hero.Items.Remove("Wooden Sword");
hero.Items.Add("axe");
Console.WriteLine("You picked up the axe and dropped the wooden sword.");
Console.WriteLine("You walk to the exit.");
Console.Read();
}
else if (hero.Items.Contains("shinysword"))
{
Console.Clear();
hero.Items.Remove("shinysword");
hero.Items.Add("axe");
Console.WriteLine("You picked up the axe and dropped the shiny sword.");
Console.WriteLine("You walk to the exit.");
Console.Read();
}
}
}
else if (response == "exit")
{
Console.WriteLine("You run out the door.");
Console.Read();
}
else
{
Console.WriteLine("Input 'fight' or 'exit'");
continue;
}
break;
}
hero.Location = "backoutside";
}
static void BackOutside(Hero hero)
{
Console.Clear();
Console.WriteLine("On the grass you see an object glowing.");
if (AskYesOrNo("Do you want to pick it up?"))
{
Console.Clear();
hero.Items.Add("medkit");
Console.WriteLine("A medkit was added to your inventory.");
if (AskYesOrNo("Do you want to use it now?"))
{
if (hero.Health < 100)
{
Console.Clear();
Console.WriteLine("The medkit brought your HP up to 100!");
hero.Health = 100;
hero.Items.Remove("medkit");
Console.Read();
}
else
{
Console.Clear();
Console.WriteLine("You can't use the medkit since your HP is already full!");
Console.Read();
}
}
}
Console.Clear();
Console.WriteLine("Far away you see a minotaur running towards you.");
Console.Read();
hero.Location = "bossfight";
}
static void BossFight(Hero hero)
{
Minotaur boss = new Minotaur();
bool amulet = true;
double damage = 0;
double blessed = 1;
double cursed = 1;
string response;
while (true)
{
if (amulet == true)
{
if (hero.Items.Contains("blessed amulet"))
{
Console.WriteLine("You have the power of the blessed amulet which makes you do more damage!");
blessed = 1.25;
}
else if (hero.Items.Contains("cursed amulet"))
{
Console.WriteLine("You have the curse of the cursed amulet which makes you do less damage!");
cursed = 0.75;
}
damage = blessed * cursed;
Console.WriteLine("Get ready to fight!");
Console.Read();
amulet = false;
}
Console.Clear();
Console.WriteLine("The Minotaur is charging towards you!");
Console.WriteLine("Current stats: You have " + hero.Health + "HP, The Minotaur has " + boss.Health + "HP.");
if (hero.Items.Contains("medkit"))
{
response = Ask("Do you fight, dodge, heal or throw your weapon at him?");
response = response.ToLower();
}
else
{
response = Ask("Do you fight, dodge, or throw your weapon at him?");
response = response.ToLower();
}
if (response == "fight")
{
Console.Clear();
if (RollD6() > 3)
{
Console.WriteLine("The attack was successfull!");
if (hero.Items.Contains("Wooden Sword"))
{
boss.Health = boss.Health - (50 * damage);
Console.WriteLine("Your Wooden Sword dealt " + (50 * damage) + " damage!");
}
else if (hero.Items.Contains("shinysword"))
{
boss.Health = boss.Health - (150 * damage);
Console.WriteLine("The Shiny Sword dealt " + (150 * damage) + " damage!");
}
else if (hero.Items.Contains("axe"))
{
boss.Health = boss.Health - (100 * damage);
Console.WriteLine("The Axe dealt " + (100 * damage) + " damage!");
}
else
{
if (hero.Items.Contains("knife"))
{
if (RollD6() > 3)
{
boss.Health = boss.Health - (30 * damage);
Console.WriteLine("The Knife dealt " + (30 * damage) + " damage!");
}
else
{
boss.Health = boss.Health - (25 * damage);
Console.WriteLine("The Knife dealt " + (25 * damage) + " damage!");
}
}
else
{
boss.Health = boss.Health - (15 * damage);
Console.WriteLine("You picked up a rock on the ground and dealt " + (15 * damage) + " damage!");
}
}
Console.Read();
}
else
{
int hp = heroHealth();
Console.WriteLine("The attack failed and you lost " + hp + "hp!");
hero.Health = hero.Health - hp;
Console.Read();
}
}
else if (response == "dodge")
{
Console.Clear();
if (RollD6() > 2)
{
Console.WriteLine("The Dodge was successfull!");
if (hero.Items.Contains("Wooden Sword"))
{
boss.Health = boss.Health - (40 * damage);
Console.WriteLine("You get a free hit with the Wooden Sword and deal " + (40 * damage) + " damage!");
}
else if (hero.Items.Contains("shinysword"))
{
boss.Health = boss.Health - (100 * damage);
Console.WriteLine("You get a free hit with the Shiny Sword and deal " + (100 * damage) + " damage!");
}
else if (hero.Items.Contains("axe"))
{
boss.Health = boss.Health - (75 * damage);
Console.WriteLine("You get a free hit with the Axe and deal " + (75 * damage) + " damage!");
}
else
{
if (hero.Items.Contains("knife"))
{
if (RollD6() > 3)
{
boss.Health = boss.Health - (20 * damage);
Console.WriteLine("You get a free hit the Knife deal " + (20 * damage) + " damage!");
}
else
{
boss.Health = boss.Health - (15 * damage);
Console.WriteLine("You get a free hit the Knife deal " + (15 * damage) + " damage!");
}
}
else
{
boss.Health = boss.Health - (10 * damage);
Console.WriteLine("You pick up a rock and get a free hit for " + (10 * damage) + " damage!");
}
}
Console.Read();
}
else
{
int hp = heroHealth();
Console.WriteLine("The Minotaur caught you off guard and dealt " + hp + "hp");
hero.Health = hero.Health - hp;
Console.Read();
}
}
else if (response == "heal")
{
Console.Clear();
if (hero.Health >= 100)
{
Console.WriteLine("You are full hp and can't use the medkit!");
}
else
{
Console.WriteLine("You used the medkit and is back to 100hp!");
hero.Health = 100;
hero.Items.Remove("medkit");
}
Console.Read();
}
else if (response == "throw")
{
Console.Clear();
if (RollD6() <= 2)
{
Console.WriteLine("The throw was successfull!");
if (hero.Items.Contains("Wooden Sword"))
{
boss.Health = boss.Health - 250;
Console.WriteLine("Your Wooden Sword is lost but you dealt 250 damage!");
hero.Items.Remove("Wooden Sword");
}
else if (hero.Items.Contains("shinysword"))
{
boss.Health = boss.Health - 400;
Console.WriteLine("Your Shiny Sword is lost but you dealt 400 damage!");
hero.Items.Remove("shinysword");
}
else if (hero.Items.Contains("axe"))
{
boss.Health = boss.Health - 350;
Console.WriteLine("Your Axe is lost but you dealt 350 damage!");
hero.Items.Remove("axe");
}
else
{
if (hero.Items.Contains("knife"))
{
boss.Health = boss.Health - 100;
Console.WriteLine("You threw your knife and dealt 100 damage!");
Console.WriteLine("You pick up the knife again.");
}
else
{
boss.Health = boss.Health - 75;
Console.WriteLine("You threw a rock and dealt 75 damage!");
}
}
Console.Read();
}
else
{
int hp = heroHealth();
Console.WriteLine("The Minotaur dodged the attack and dealt " + hp + "hp.");
if (hero.Items.Contains("Wooden Sword"))
{
Console.WriteLine("Your Wooden Sword is lost!");
hero.Items.Remove("Wooden Sword");
}
else if (hero.Items.Contains("shinysword"))
{
Console.WriteLine("Your Shiny Sword is lost!");
hero.Items.Remove("shinysword");
}
else if (hero.Items.Contains("axe"))
{
Console.WriteLine("Your Axe is lost!");
hero.Items.Remove("axe");
}
else
{
if (hero.Items.Contains("knife"))
{
if (hero.Knife == true)
{
Console.WriteLine("You pick up your knife again.");
hero.Knife = false;
}
}
}
hero.Health = hero.Health - hp;
Console.Read();
}
}
if (boss.Health <= 0 && hero.Health > 0)
{
hero.Location = "win";
break;
}
else if (hero.Health <= 0 && boss.Health > 0)
{
hero.Location = "lose";
break;
}
}
}
static void Win(Hero hero)
{
Console.Clear();
Console.WriteLine("You eliminated the Minotaur!");
Console.WriteLine("\nYou get away from the castle as soon as you can and go home.");
Console.Read();
hero.Location = "gameover";
}
static void Lose(Hero hero)
{
Console.Clear();
Console.WriteLine("You got eliminated from the Minotaur and lost!");
Console.Read();
hero.Location = "gameover";
}
static void GameOver(Hero hero)
{
if (AskYesOrNo("\nYou want to restart?"))
{
hero.Name = "";
hero.Location = "newgame";
hero.Items.Clear();
hero.Knife = true;
hero.Health = 100;
}
else
{
Environment.Exit(0);
}
}
static int heroHealth()
{
int health = 0;
int number = RollD6();
if (number == 1)
{
health = 10;
}
else if (number == 2)
{
health = 12;
}
else if (number == 3)
{
health = 14;
}
else if (number == 4)
{
health = 16;
}
else if (number == 5)
{
health = 18;
}
else if (number == 6)
{
health = 20;
}
return health;
}
static int RollD6()
{
Random random = new Random();
int roll = random.Next(1, 7);
return roll;
}
static string Ask(string question)
{
string response = "";
while (response == "")
{
Console.WriteLine(question);
response = Console.ReadLine().Trim();
}
return response;
}
static bool AskYesOrNo(string question)
{
while (true)
{
string response = Ask(question).ToLower();
switch (response)
{
case "yes":
case "ok":
return true;
case "no":
return false;
}
}
}
}
class Hero
{
public string Name = "";
public double Health = 100;
public List<string> Items = new List<string>();
public string Location = "newgame";
public bool Knife = true;
}
class Minotaur
{
public double Health = 500;
public List<string> Items = new List<string>();
}