Created
July 23, 2019 18:49
-
-
Save ericewers/6a248f648e1ddb8e26d3edf3f08ffb73 to your computer and use it in GitHub Desktop.
A Hero's Journey
This file contains 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
/* | |
* A Hero's Journey | |
* By Eric Ewers, 7-21-2019 | |
*/ | |
using System; | |
using System.Collections.Generic; | |
namespace Adventure | |
{ | |
public static class Game | |
{ | |
// SETTINGS | |
static int Scenarios = 3; | |
static string CharacterName; | |
// PART ONE | |
static string[] PartOne = | |
{ | |
// 0 - Description and Choice | |
"The old man offers to introduce you to some of the locals in the village, where you might be able to find some food and shelter. Do you accept his offer (A) or be on your way (B)?", | |
// 1 - Choice 1 | |
"You kindly accept the old man's offer and follow him up the hill to the nearby village, where you are greeted with cold blank stares. \n" + | |
"The old man stops at a rustic stone structure with ivy crawling up the sides and a rotting wooden door. He beckons you to enter.", | |
// 2 - Choice 1 - Question | |
"Do you enter (A) or instead decide to explore the village (B)?", | |
// 3 - Choice 1A | |
"You slowly open the door and walk inside...people are still staring at you with fear in their eyes. The bartender however, greets you with a smile and hands you a drink on the house.", | |
// 4 - Choice 1B | |
"You decide to explore what the village has to offer first. You find a key, a rock, and a small slingshot. You return to the stone structure you were once at.", | |
// 5 - Choice 2 | |
"You kindly decline the old man's offer. He gives you some bread before you turn around and walk down the hill, stomach still grumbling. \n" + | |
"As you reach the bottom of the hill, your skin begins to crawl as a black shadowy figure emerges out of the bushes.", | |
// 6 - Choice 2 - Question | |
"Do you attempt to fight the creature (A) or sneak away before it notices you (B)?", | |
// 7 - Choice 2A | |
"You have nothing to fight with and the creature quickly punches you in the throat and takes your bread. You die a most horrible death!", | |
// 8 - Choice 2B | |
"You successfully sneak away unnoticed. Whew! But then you realize the creature starts to walk up the hill to the village. You have killed everyone you idiot!" | |
}; | |
// PART TWO | |
static string[] PartTwo = | |
{ | |
// 0 - Branch - PartOne - Choice 1A/B | |
"A loud commotion starts in the distance, down the hill from the village. Do you check it out (A) or ignore it (B)?", | |
// 1 - Choice 1 | |
"You quickly slurp your unfinished beer and run out of the saloon towards the bottom of the hill. \n" + | |
"Your skin begins to crawl as a black shadowy figure emerges out of the bushes.", | |
// 2 - Choice 1A | |
"Luckily, you have a slingshot. You load the rock into the slingshot, aim it at the creature, and it goes down with a crash. You've saved the village!", | |
// 3 - Choice 1B | |
"You have nothing to fight with and the creature quickly punches you in the throat. You die a most horrible death!", | |
// 4 - Choice 2 | |
"The creature makes it's way up the hill to the village as you cower in the corner of the saloon. You hear everyone die around you, but you survive to see another day. You have just killed everyone you idiot!" | |
}; | |
// PART THREE | |
static string[] PartThree = | |
{ | |
}; | |
// INVENTORY | |
static List<string> Inventory = new List<string>(); | |
// START GAME | |
public static void StartGame() | |
{ | |
GameTitle(); | |
// Introduction | |
Console.WriteLine("You awake to find yourself in a comfy large bed inside of a wooden hut with a straw roof, sunlight peaking through. \n" + | |
"Your nose is greeted with the fresh aroma of cooked onions and you can feel the warmth from a nearby wood stove. \n" + | |
"There is a slab of red meat on a small platform sitting next to the fire. \n" + | |
"You're still cold, wet and can hear a low rumble coming from your stomach. \n" + | |
"An old weathered man seems to appear out of nowhere, looking straight at you from the chair by the fire. \n" + | |
"You begin to wonder if he had been there all along."); | |
//Console.WriteLine("You are carrying " + string.Join(", ", objects) + "."); | |
NameCharacter(); | |
Choice(); | |
EndGame(); | |
} | |
// END GAME | |
public static void EndGame() | |
{ | |
Console.WriteLine("Congratulations, " + CharacterName + ", you've reached the end!"); | |
// Check Inventory | |
if (Inventory.Count > 0) | |
{ | |
Console.ForegroundColor = ConsoleColor.Cyan; | |
Console.WriteLine("You found some items on your journey:"); | |
Console.ForegroundColor = ConsoleColor.DarkYellow; | |
foreach (string item in Inventory) | |
{ | |
Console.WriteLine(item); | |
} | |
Console.ResetColor(); | |
} | |
} | |
// CHOICE | |
static void Choice() | |
{ | |
for (int i = 1; i <= Scenarios; i++) | |
{ | |
string input; ; | |
switch (i) | |
{ | |
// Part One | |
case 1: | |
// go to village or be on your way | |
Console.WriteLine(PartOne[0]); | |
Console.ForegroundColor = ConsoleColor.Green; | |
Console.Write("Enter your choice: "); | |
input = Console.ReadLine(); | |
input = input.ToUpper(); | |
Console.ResetColor(); | |
// Choice 1 | |
if (input != "A" && input != "B") | |
{ | |
goto case 1; | |
} | |
if (input == "A") | |
{ | |
// go to village | |
Console.WriteLine(PartOne[1]); | |
Console.ForegroundColor = ConsoleColor.Green; | |
// enter or explore village? | |
Console.Write(PartOne[2]); | |
input = Console.ReadLine(); | |
input = input.ToUpper(); | |
Console.ResetColor(); | |
// Choice 1A | |
if (input != "A" && input != "B") | |
{ | |
goto case 1; | |
} | |
if (input == "A") | |
{ | |
// enter | |
Console.WriteLine(PartOne[3]); | |
Inventory.Add("beer"); | |
} | |
else | |
{ | |
// explore village | |
Console.WriteLine(PartOne[4]); | |
Inventory.Add("key"); | |
Inventory.Add("rock"); | |
Inventory.Add("slingshot"); | |
// enter | |
Console.WriteLine(PartOne[3]); | |
Inventory.Add("beer"); | |
} | |
} | |
// Choice 2 | |
else | |
{ | |
// be on your way | |
Console.WriteLine(PartOne[5]); | |
Inventory.Add("bread"); | |
Console.ForegroundColor = ConsoleColor.Green; | |
// fight creature or sneak away | |
Console.Write(PartOne[6]); | |
input = Console.ReadLine(); | |
input = input.ToUpper(); | |
Console.ResetColor(); | |
// Choice 2A | |
if (input != "A" && input != "B") | |
{ | |
goto case 1; | |
} | |
if (input == "A") | |
{ | |
// fight | |
Console.WriteLine(PartOne[7]); | |
Inventory.Remove("bread"); | |
return; | |
} | |
else | |
{ | |
// sneak away | |
Console.WriteLine(PartOne[8]); | |
return; | |
} | |
} | |
break; | |
// Part Two | |
case 2: | |
// follow commotion | |
Console.WriteLine(PartTwo[0]); | |
Console.ForegroundColor = ConsoleColor.Green; | |
Console.Write("Enter your choice: "); | |
input = Console.ReadLine(); | |
input = input.ToUpper(); | |
Console.ResetColor(); | |
if (input != "A" && input != "B") | |
{ | |
goto case 2; | |
} | |
if (input == "A") | |
{ | |
// check it out | |
Console.WriteLine(PartTwo[1]); | |
Console.ForegroundColor = ConsoleColor.Green; | |
// fight creature or sneak away | |
Console.Write(PartOne[6]); | |
input = Console.ReadLine(); | |
input = input.ToUpper(); | |
Console.ResetColor(); | |
// Choice 1A | |
if (input != "A" && input != "B") | |
{ | |
goto case 2; | |
} | |
if (input == "A") | |
{ | |
if (Inventory.Contains("slingshot")) | |
{ | |
// fight and save village | |
Console.WriteLine(PartTwo[2]); | |
Inventory.Remove("rock"); | |
Inventory.Remove("slingshot"); | |
} | |
else | |
{ | |
// fight and die | |
Console.WriteLine(PartTwo[3]); | |
Inventory.Remove("bread"); | |
} | |
} | |
else | |
{ | |
// fight and sneak away | |
Console.WriteLine(PartOne[8]); | |
} | |
} | |
else | |
{ | |
// survive, but kill everyone | |
Console.WriteLine(PartTwo[4]); | |
} | |
break; | |
// Part Three | |
case 3: | |
break; | |
default: | |
break; | |
} | |
} | |
} | |
// CHARACTER NAME | |
static void NameCharacter() | |
{ | |
Dialog("What's your name traveler?"); | |
CharacterName = Console.ReadLine(); | |
// Capitalize first letter of name | |
// CharacterName = CharacterName.ToUpper(); | |
// str[0] = Char.ToUpper(str[0]); | |
if (CharacterName == "") | |
{ | |
NameCharacter(); | |
} | |
else | |
{ | |
Dialog("Great! It's nice to meet you " + CharacterName + "."); | |
} | |
} | |
// GAME TITLE | |
static void GameTitle() | |
{ | |
string Title = "A Hero's Journey"; | |
Console.Title = Title; | |
Console.ForegroundColor = ConsoleColor.Cyan; | |
Console.WriteLine(Title); | |
Console.ResetColor(); | |
Console.WriteLine("Press enter to start"); | |
Console.ReadKey(); | |
// Enter Key Event Handler Goes Here | |
Console.Clear(); | |
} | |
// DIALOG TEXT | |
static void Dialog(string message, string color = null) | |
{ | |
if (color == null) | |
{ | |
Console.ForegroundColor = ConsoleColor.Cyan; | |
} | |
else if (color == "red") | |
{ | |
Console.ForegroundColor = ConsoleColor.Red; | |
} | |
else if (color == "green") | |
{ | |
Console.ForegroundColor = ConsoleColor.Green; | |
} | |
else if (color == "yellow") | |
{ | |
Console.ForegroundColor = ConsoleColor.Yellow; | |
} | |
else if (color == "white") | |
{ | |
Console.ForegroundColor = ConsoleColor.White; | |
} | |
Console.WriteLine(message); | |
Console.ResetColor(); | |
} | |
} | |
class Program | |
{ | |
static void Main() | |
{ | |
Game.StartGame(); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment