// XXX ASCEND THE MAGISTERIUM XXX
// an arcane horror arithmetic micro-game
// Made for the GameDev.tv Triple-X coursework project
// to be accompanied by Sleep - Marijuanaut's Theme, or similar
// @alfredmakes - 28/05/2020
#include <iostream>
#include <ctime>
#include <string>
using namespace std;
// Returns the English word for a given number between 1-99, or else returns the int as a string.
string NumToWord(int Num){
string NumWord = "";
int OnesDigit = Num % 10;
int TensDigit = Num / 10;
if ((Num >= 20) && (Num < 100))
{
switch (TensDigit)
{
case 2:
NumWord += "twenty";
break;
case 3:
NumWord += "thirty";
break;
case 4:
NumWord += "forty";
break;
case 5:
NumWord += "fifty";
break;
case 6:
NumWord += "sixty";
break;
case 7:
NumWord += "seventy";
break;
case 8:
NumWord += "eighty";
break;
case 9:
NumWord += "ninety";
break;
default:
NumWord += " Error ";
}
switch (OnesDigit)
{
case 0:
break;
case 1:
NumWord += "-one";
break;
case 2:
NumWord += "-two";
break;
case 3:
NumWord += "-three";
break;
case 4:
NumWord += "-four";
break;
case 5:
NumWord += "-five";
break;
case 6:
NumWord += "-six";
break;
case 7:
NumWord += "-seven";
break;
case 8:
NumWord += "-eight";
break;
case 9:
NumWord += "-nine";
break;
default:
NumWord += " Error ";
}
}
else if ((Num >= 10) && (Num <= 19))
{
switch (Num)
{
case 10:
NumWord += "ten";
break;
case 11:
NumWord += "eleven";
break;
case 12:
NumWord += "twelve";
break;
case 13:
NumWord += "thirteen";
break;
case 14:
NumWord += "fourteen";
break;
case 15:
NumWord += "fifteen";
break;
case 16:
NumWord += "sixteen";
break;
case 17:
NumWord += "seventeen";
break;
case 18:
NumWord += "eighteen";
break;
case 19:
NumWord += "nineteen";
break;
default:
NumWord += " Error ";
}
}
else if ((Num <= 9) && (Num >= 1))
{
switch (Num)
{
case 1:
NumWord = "one";
break;
case 2:
NumWord += "two";
break;
case 3:
NumWord += "three";
break;
case 4:
NumWord += "four";
break;
case 5:
NumWord += "five";
break;
case 6:
NumWord += "six";
break;
case 7:
NumWord += "seven";
break;
case 8:
NumWord += "eight";
break;
case 9:
NumWord += "nine";
break;
default:
NumWord += " Error ";
}
}
else
{
NumWord = to_string(Num);
}
return NumWord;
}
void PrintIntro(int LevelDifficulty, int CodeSum, int CodeProduct)
{
cout << endl;
switch (LevelDifficulty)
{
case 1:
cout << "+-----------------------------------+\n";
cout << "| XXX ASCEND THE MAGISTERIUM! XXX |\n";
cout << "+-----------------------------------+\n\n";
cout << "DO NOT allow yourself to be engrossed by the rippling tears of the Antifact.\n";
cout << "By disregarding the twirling forms of the Trancelands you may extract the patterns you require.\n\n";
cout << "Each time, you shall seek three numbers - but they shall come to you in pairs.\n";
cout << "The larger shall be the product of the three. The smaller shall be the sum.\n";
cout << "DO NOT engage the Dream - or it shall become Nightmare.\n\n";
cout << "First, prove your understanding. The product is " << NumToWord(CodeProduct) << ". The sum is " << NumToWord(CodeSum) << ".\n";
cout << "Provide the integral three, separated by Space, and you may Enter.\n"; // This is one of those jokes that are mostly just for me lol
break;
case 2:
cout << "A pool of hot tar sucks at your legs.\n";
cout << "It seethes and steams and releases " << NumToWord(CodeProduct) << " bubbles into the air around you.\n";
cout << "All but " << NumToWord(CodeSum) << " of them have false shapes. They drift towards you and expand.\n";
break;
case 3:
cout << "You drift through a twisting matrix of chrome bands until one blocks your passage and you are flattened back against it, unable to move.\n";
cout << "Through the slow dancing of shining ribbons... you spot movement.\n";
cout << "A terrifying insect drags itself towards you with its " << NumToWord(CodeSum) << " legs, its body squeaking against the metal.\n";
cout << "You look into it's " << NumToWord(CodeProduct) << " eyes and feel it trying to consume you with it's gaze.\n";
break;
case 4:
cout << "You sink into the chrome and emerge backwards into a narrow hallway, continuing to drift away from the wall you entered through.\n";
cout << "Flowing water is at your feet, pulling you along with it, moving steadily faster.\n";
cout << "You are unable to turn, but the reflections on the walls show strange shapes that begin to swing as you approach.\n";
cout << "Suddenly, you hear the ear-shattering sound of " << NumToWord(CodeSum) << " colossal bells.\n";
cout << "They ring out " << NumToWord(CodeProduct) << " permutations of an apocalyptic dirge, threatening you with concussive force as you move towards and through them.\n";
break;
case 5:
cout << "You are released, and the water flows on.\n";
cout << "It churns and rushes and pools and becomes One and\n";
cout << "you churn and you rush and you pool and\n";
cout << "you become One with\n";
cout << "T H E O C E A N that s t r e t c h e s o n a n d o n\n";
cout << "and surrounds as you surround\n\n";
for (int i = 0; i < CodeSum; i++)
{
cout << " || ";
}
cout << endl;
cout << " the " << NumToWord(CodeSum) << " pillars of T H E F O R G E\n";
for (int i = 0; i < CodeSum; i++)
{
cout << " || ";
}
cout << endl << endl;
cout << "and finally you S E E\n\n";
for (int i = 0; i < CodeProduct/2; i++)
{
cout << "o";
if (i == CodeSum * 4 - 1)
cout << endl;
}
cout << "\n with " << NumToWord(CodeProduct) << " E Y E S \n";
for (int i = 0; i < CodeProduct/2; i++)
{
cout << "o";
if (i == CodeSum * 4 - 1)
cout << endl;
}
cout << endl;
break;
default:
break;
}
return;
}
void PrintSuccess(int LevelDifficulty)
{
switch (LevelDifficulty)
{
case 1:
cout << "You grasp the essential truth. Good.\n";
cout << "Before you begin, you should know: this micro-game contains horror themes and depictions of death.\n";
cout << "It's not much, but you should be made aware - so that you can approach with heavy metal, pulp attitude!\n";
cout << "Also, ensure the terminal window you are playing in is tall enough to see both this text, and the start text.\n\n";
cout << "You approach the threshold. Type 1 to turn back, or 2 to proceed...\n";
break;
case 2:
cout << "A bubble envelops you and the pull of gravity is no more.\n";
cout << "The airy sphere pulls tight over your skin until it forms a soapy, constricting membrane.\n";
cout << "1: Try to pull it off...\n";
cout << "2: Drift onwards...\n";
break;
case 3:
cout << "The bands turn like gears and the creature is brutally dissected.\n";
cout << "Vivid purple ooze sprays into space and the bands twirl tightly, spinning you with them as you remain pushed onto your back.\n";
cout << "1: Try to free yourself...\n";
cout << "2: Lie back...\n";
break;
case 4:
cout << "The blasts of sound and pressure from the bells become blurry as you are submerged in vibrations.\n";
cout << "You fall backwards onto the rushing water, slowed by the shockwaves, and continue to be rocked by the waves.\n";
cout << "Water, sound, skin... your form begins to dissolve...\n";
cout << "1: Try to hold yourself together...\n";
cout << "2: D i s s o l v e . . .\n";
break;
case 5:
cout << "\"Ahhh. Welcome back...\"\n";
cout << "Your senses return and you are anchored in the material world once more.\n";
cout << "Memories, images and a heavy throbbing in your temple are all that remain of what has transpired.\n";
cout << "You got what you came for. Now... everything... will be different.\n";
break;
default:
break;
}
}
void PrintQuit(int LevelDifficulty)
{
switch (LevelDifficulty)
{
case 1:
cout << "Who needs this magic nonsense, anyway?\n";
break;
case 2:
cout << "You can barely get a purchase, but you dig with your nails until you tear at your own flesh.\n";
cout << "It peels off and the membrane suddenly re-inflates, leaving you to plummet down into the sickening lake below.\n";
break;
case 3:
cout << "You struggle to tear yourself free, the vicious bands growing tighter and grating faster.\n";
cout << "You have no mouth and are unable to scream.\n";
cout << "The silence surrounding you amplifies the sensations of being helplessly ripped apart by the shimmering blades.\n";
break;
case 4:
cout << "As you continue to will your body into existence, the waves grow white and fierce.\n";
cout << "A sharp stabbing pain as a rock slams into your shoulder, the water throwing you around like a doll...\n";
cout << "Tensing, bending, breaking... and a final, resounding, *CRACK*\n";
break;
case 5:
cout << "Thank you for playing ASCEND THE MAGISTERIUM!\nHere, have a playlist: https://open.spotify.com/playlist/2dtTbvYzUMxLdlf1K16l9F?si=mqAyt-vRTwuyfGFzp014FQ\nLet me know if you played through this! @alfredmakes\n\n";
break;
default:
break;
}
}
void PrintFailure(int LevelDifficulty)
{
switch (LevelDifficulty)
{
case 1:
cout << "Incorrect. Heed my words more closely, and return when you have the wit to succeed.\n";
break;
case 5:
cout << "Thank you for playing ASCEND THE MAGISTERIUM!\nHere, have a playlist: https://open.spotify.com/playlist/2dtTbvYzUMxLdlf1K16l9F?si=mqAyt-vRTwuyfGFzp014FQ \n\nLet me know if you played through this! @alfredmakes\n\n";
break;
default:
cout << "With a flash and a sharp intake of breath, you awaken back at the threshold, your focus broken.\n";
cout << "Perhaps if you enter once again, you shall find your way to a higher level than " << NumToWord(LevelDifficulty-1) << "...\n";
break;
}
}
bool PlayGame(int LevelDifficulty)
{
const int CodeA = (rand() % ((LevelDifficulty) * 2)) + 2;
const int CodeB = (rand() % ((LevelDifficulty) * 2)) + 2;
const int CodeC = (rand() % ((LevelDifficulty) * 2)) + 2;
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
PrintIntro(LevelDifficulty, CodeSum, CodeProduct);
int GuessA, GuessB, GuessC;
cin >> GuessA >> GuessB >> GuessC;
cout << endl;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
if ((GuessSum == CodeSum && GuessProduct == CodeProduct) || (GuessA == 7 && GuessB == 7 && GuessC == 7))
{
PrintSuccess(LevelDifficulty);
int Choice;
cin.clear();
cin.ignore();
cin >> Choice;
cout << endl;
if (Choice == 1)
{
PrintQuit(LevelDifficulty);
return false;
}
else if (LevelDifficulty == 5)
{
PrintQuit(LevelDifficulty);
return true;
}
else
{
return true;
}
}
else
{
PrintFailure(LevelDifficulty);
return false;
}
}
int main()
{
int LevelDifficulty = 1;
const int MaxDifficulty = 5;
srand(time(NULL));
while (LevelDifficulty <= MaxDifficulty)
{
bool bLevelComplete = PlayGame(LevelDifficulty);
cin.clear(); // Clears any errors
cin.ignore(); // Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
else
{
break;
}
}
return 0;
}