TripleX - Cyberpunk Slicer

Here is my finished TripleX game, Cyberpunk Slicer.

ASCII text generated at: ASCII TEXT
ASCII art based on art from http://www.asciiworld.com

This is a 10 level game with a little bit of story for each level, and some art for about half of them.

I wanted to scale the difficulty up a bit, and ensure that later levels would be more challenging than earlier. to do this, I added a multiplier to the difficulty variable when using it to generate the codes. Initially I hard coded this value to 3, but later made it a variable (between 1 and 5) that the player can select at the beginning of the game. When playtesting this version with a wider range of possible values, I found it helpful to know the range at later levels, so I start providing that to the player after level 5.

I wanted to make sure that level 10 (final level) was the most challenging. This gave me the idea to have a code with more numbers. To establish that the length of the code can change, I made level 1 a 2 number code. Level 10 is 5 numbers, but level 8 is optional, and if you do it it will provide an advantage that will help on level 10. This difficulty assumes that you are writing things down to factor the product out and try different combinations to sum correctly. I can’t imagine doing the higher levels in my head.

I beat the game on challenge 3. On challenge 5 I made it to level 10, but I skipped level 8 to make it as hard as possible, and got stuck. After trying for a while, I wrote a little guess and check program and ran it in another terminal. It found the answer in a couple seconds, which was nice, but made me feel a little foolish for how long I tried solving it myself.

I was having an issue where excess characters submitted by the player were not being cleared from the buffer. I looked around online and it seems like I was able to resolve this by replacing ‘cin.ignore()’ with ‘cin.ignore(256, ‘\n’)’, though I don’t fully understand why.

#include <iostream>
#include <ctime>
#include <string>
using namespace std;

void PrintIntroduction()
{

	std::cout << "\n\n" << R"(
   _____      _                                 _    
  / ____|    | |                               | |   
 | |    _   _| |__   ___ _ __ _ __  _   _ _ __ | | __
 | |   | | | | '_ \ / _ \ '__| '_ \| | | | '_ \| |/ /
 | |___| |_| | |_) |  __/ |  | |_) | |_| | | | |   < 
  \_____\__, |_.__/ \___|_|  | .__/ \__,_|_| |_|_|\_\
         __/ |               | |                     
        |___/                |_|                     
      _______        _____ _______ _______  ______   
       |______ |        |   |       |______ |_____/  
       ______| |_____ __|__ |_____  |______ |    \_  
	)";
	std::cout << std::endl;
	std::cout << std::endl;
	std::cout << "You're a slicer with a reputation of being someone who can get the job done quick and quiet. Your fixer has brought you on for a job to secure top secret Militech hardware for the client.\n";
	cout << "You will be working with Stitch and Crash, a couple of mercs that 8-ball has paired you up with in the past.\n";
	std::cout << "You will need to hack into Militech security system to clear a path for the rest of the team by identifying the correct codes.\n";
	cout << "Security will be tight. Be sure to carefully enter the numbers separated by spaces.\n\n";


}

//Create arrays for the setup and completion of levels, as well as for art.
string Setup(int level)
{
string Story[] = {"0",
"There is a single guard posted at a side entrance to the building.\nThe facility is located within Night City, which means there are plenty of opportunities to create a distraction. \nA car parked in the alley should do nicely, and it's civilian so it should be easy.",
"Stitch hands you the guard's badge.\nAfter scanning it, you should be able to work your way into Militech's system, though it will be better protected than civilian systems like the one you just cracked. \nFirst, you need to do something about the camera above the door.",
"Next is the door. Getting it open would be easy with the keycard lifted from the guard, but the access would be registered by the central security system. \nIt wouldn't be able to ID you, but three unknown individuals entering the building would be sure to trigger a security response. \nYou set to work bypassing the system.",
"You will need to access the local security system in order to locate and gain access to the target. \nFollowing Stitch's lead, the team makes its way through the facility until you spot an access point for the system. \nThree militech soldiers occupy the station. Two of them sit in chairs surveying the monitors and chatting while the third patrols the area. \nYou need to take them out quietly. You scan the guards looking for an advantage, and find it in one of them sitting at the monitors.",
"",
"You make your way across the floor to the vicinity of the elevator. It's positioned at the back of a large room serving as a warehouse and loading dock.\nA couple trucks sit parked by large steel doors. The room is filled with crates and various military equipment ready for shipping.\nThere are 5 guards patrolling the area, and you will need some time at the elevator controls. Crash and Stitch will need to clear the room.\n\"You got those?\" Crash asks in a hushed, gruff tone, motioning to the lights overhead.\nYou nod and set to work on the lights.",
"You join your team at the elevator, stepping over a limp guard as you approach the panel and jack in.",
"Crash hands you an auto-Shotgun, Stitch a set of laser pistols.",
"You reach the corner of the bunker where the target is located.\nA large section of the level is closed off, with a large opening currently blocked by a wall of red light.\nYou set to clearing the path.",
"You see the prototype exo-suit that you are after. All that's left is to power it up and pilot it out to the van. \nAs you approach the suit you hear someone call out, \"You bastards! I won't let my life's work be taken by the likes of you!\" /nYou see a thin man with dark hair and glasses piloting a second prototype mech, nearly identical to your target, but a little rougher, maybe the previous iteration. \nThe man cries out as he sends a stream of bullets hurling across the room. \nThe three of you dodge behind a desk.",
"\"Time to see what these things can do.\" Crash says, readying his new shotgun. \nStitch produces his pistols and the two of them dash out from behind the desk, guns blazing. \nThe new weapons pack a surprising punch. Crash and Stitch manage to do some damage to the mech, taking out the targeting system.\nEven still, they are cornered and pinned now, without your help, they will not last much longer. \nWith the engineer distracted, you set to work on your target. \nThe security is very tight, but you recognize some of the routines from when you were unlocking the prototype guns, which should make this a little easier.",
"\"Alright, we'll take care of this, you get the target ready for transport\" Crash says.\n He and Stitch both dash out, drawing the fire of the other mech. \nWith attention off of you, you make your way to the target. As you do, you hear Stitch cry out in pain. \nYou can't see them, but Crash and Stitch appear to have been cornered and pinned by the engineer, and Stitch sounds to be hurt. \nTheir only hope is that you get this other mech online right now."
};

return Story[level];
}

string Success(int level)
{
	string Story[] = {"0",
	"The vehicle's headlights begin to flash out of sequence, windshield wipers sporadically activate at variable speeds, the horn emits a long low squeal. \nThe guard takes notice and makes his way over to investigate. \nOnce he is out of view of the camera above the door, Stitch descends upon him from the neighboring rooftop.\nYou silence the car while Stitch drags the guard to a nearby dumpster, propping him up against it out of sight.",
	"You manage to quickly access the camera system. \nYou roll the feed back to a few minutes earlier when the guard was still standing watch and clip a section of it to play on loop. \nHopefully this was all done before anyone took notice of him leaving his post.",
	"Success. \nThe panel next to the door shuts off and the door slides open. The three of you make your way inside and you reactivate the door.\nIt slides shut and the panel lights back up as though nothing had happened.",
	"Sparks erupt from the guard's eyes as he cries out in pain. \n\"Aargh! I can't see!\". \nThe others both turn to look as he cries out, and your team immediately leaps into action. \nStitch takes out the patrol, muffling his cry as he brings him to the ground. \nCrash charges on ahead, placing one massive hand onto each of the seated guards' heads and quickly brings their skulls together with a loud thud. \nThey slump down in their chairs and you push one aside as you make your way up and jack into the terminal.",
	"You're in.\nThe target is in the R&D bunker, only accessible by a secure elevator on the other side of the building. \nIt looks like there are a number of other prototype weapons in the bunker, mainly advanced rifles and other small arms.\nIn addition to finding the info you needed, you have a better idea of how Militech's security works.\nYou should now be able to tell the minimum and maximum range for the code numbers when slicing into Militech systems.",
	"You look up to Crash and Stitch, \"You've got 90 seconds.\"\nYou execute the blackout. The room suddenly falls dark save for a few pockets of dim illumination from independently powered devices.\n\"Plenty of time.\" Crash replies. \nYou see him and Stitch each raise a hand to their temple, causing their eyes to briefly pulse a bright white, then settle back to how they had looked before, but slightly illuminated.\nThey dash in opposite directions. Over the 90 seconds you hear a few thuds and what might have been a muffled yell.\nAs the lights flash back on, you see your team standing at the elevator, surveying the area for any further threat.",
	"The panel turns green as the heavy door raises. You all make your way in and ride the elevator to the subterranean R&D level.\nAs you step out, you spot a stash of the prototype small arms you saw on the security terminal upstairs.\nThey might come in handy, but you will need to slice into them to attune them to your team, and you run the risk of the weapon's AI alerting Militech security.",
	"You unlock the guns, register your teammates as their operators, and take them off of the Militech targeting network.",
	"The field of light blinks off and you make your way through to find your prize.",
	"The mech lights up and the cockpit pops open. You jump in, jack in, and set the targeting system onto the other mech as quick as you can. \nIt only takes a moment for you to acquire a lock and shoot a barrage on small rockets, bringing the other mech to the ground.",
	"As the gunfire from the engineer ceases, Crash and Stitch make their way out from cover. The three of you load into the elevator. \nExpecting company, Stitch drops a smoke grenade as the elevator approaches the ground floor and flings two more out the door as it opens. \nYou are met with gunshots, but the smoke is clouding the room, so most of them miss their mark completely, the others bounce off of the armor plating of the mech. \nYou charge straight through with Crash and Stitch on your six. \nAnother barrage of small rockets creates an opening where one of the large metal dock doors had been. \nYou make your way out in the confusion and easily neutralize the guards posted outside. \nAs you approach the street, a Van pulls up. \nCrash helps you pilot the mech into the back while Stitch takes the driver's seat from the van's AI.\n\nGreat work, the team has made it out with the goods!",
	"You call out to your team, \"you alright back there?\"\n\"Still breathing, but S is hit. We need to get out of here fast.\" \nCrash makes his way out from behind cover, propping Stitch up and helping him cover the distance to the elevator.\nThe engineer almost certainly triggered some sort of alarm. \nCrash positions himself and Stitch behind the mech as you ready for the door to open onto the dock. \nAs the door opens, gunfire erupts from the dock. \nThe bullets bounce harmlessly off of the mech as the targeting computer scans the room and locks on to nearly a dozen soldiers. \nYou give the command to open fire. \nMachine guns mounted on each arm of the mech fire short bursts of bullets at each of the acquired targets \nThere is still shouting and scattered gunfire. More soldiers are likely on the way, you need to move now. \nYou fire a barrage of small rockets at one of the large loading dock doors, clearing a path. \nYou scoop Stitch up into the arms of the mech and charge for the fresh opening. Crash follows behind, watching your back.\nAs you approach the street, your Van pulls up. \nCrash runs ahead to open the rear door for you before taking the driver's seat. \n\nGood work, you've made it out with the target. \nYou'll need to get stitch to a doctor ASAP though, and then lay low for a while."
	};

return Story[level];
}

string Art(int level)
{
	string Art[] = {"0",
R"(
                _____________________
               (---------------------)
            _/~~~~~~~~~~~~~~~~~~~~~~~~~\
          /~                             ~\
        .~                                 ~
    ()\/_____                           _____\/()
   .-''      ~~~~~~~~~~~~~~~~~~~~~~~~~~~     ``-.
.-~              __________________              ~-.
`~~/~~~~~~~~~~~~TTTTTTTTTTTTTTTTTTTT~~~~~~~~~~~~\~~'
| | | #### #### || | | | [] | | | || #### #### | | |
;__\|___________|++++++++++++++++++|___________|/__;
 (~~====___________________________________====~~~)
  \------_____________[CHOOMBA]___________-------/
     |      ||         ~~~~~~~~       ||      |
      \_____/                          \_____/
)",
R"(
      __________________
 \\   |             >0< |     /
  \\  |     Big         |====||
  |_==|     Brother     |====||
      |     Security    |     \
      -------------------
)",
"",
R"(
          _,.---,---.,_
      ,;~'             '~;, 
    ,;                     ;,      
   ;                         ; 
  ,'                         /'
 ,;                        /' ;,
 ; ;      .           .   '  ; |
 | ;   ______       ______  ##;<----- Reflex Tuner
 |  '/~"     ~" . "~     "~\'  |
 |  ~  ,-~~~^~, | ,~^~~~-,  ~  |
  |   |  ###   }:{   ###  | <------------- Ocular Scanner
  |   l  ###  / | \  ###  !   |    (Firmware outdated - VULNERABLE)
  .~  (__,.--" .^. "--.,__)  ~. 
  |    ----;' / | \ `;----
   \__.       \/^\/       .__/  
    V| \                 / |V 
     | |T~\___!___!___/~T| |  
     | |`IIII_I_I_I_IIII'| |  
     |  \,III I I I III,/  | 
      \   `~~~~~~~~~~'    /
        \   .       .   /
          \.    ^    ./   
            ^~~~^~~~^
)",
R"(
             ____________________________________________________
            /                                                    \
           |    _____________________________________________     |
           |   |,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,|    |
           |   |,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,|    |
           |   |,,,,,#,,,,,,,,,@@@@@@@@@@@@@@@,,,,,,,,,@,,,,,|    |
           |   |,,,,,@@,,,,,,,,,@@@@@@@@@@@@@,,,,,,,,,@@,,,,,|    |
           |   |,,,,,@@@,,,,,,,,,@@@@@@@@@@@,,,,,,,,,@@@,,,,,|    |
           |   |,,,,,@@@@,,,,,,,,,@@@@@@@@@,,,,,,,,,@@@@,,,,,|    |
           |   |,,,,,@@@@@,,,,,,,,,&@@@@@,,,,,,,,,,@@@@@,,,,,|    |
           |   |,,,,,@@@@@@,,,,,,,,,,@@@,,,,,,,,,,@@@@@@,,,,,|    |
           |   |,,,,,@@@@@@@#,,,,,,,,,@,,,,,,,,,&@@@@@@@,,,,,|    |
           |   |,,,,,@@@@@@@@@,,,,,,,,,,,,,,,,,@@@@@@@@@,,,,,|    |
           |   |,,,,,@@@@@@@@@@,,,,,,,,,,,,,,,@@@@@@@@@@,,,,,|    |
           |   |,,,,,@@@@@@@@@@@,,,,,,,,,,,,,@@@@@@@@@@@,,,,,|    |
           |   |,,,,,  _  _ _ _   _ ___ ____ ____ _  _  ,,,,,|    |
           |   |,,,,,  |\/| | |   |  |  |___ |    |__|  ,,,,,|    |
           |   |,,,,,  |  | | |__ |  |  |___ |___ |  |  ,,,,,|    |
           |   |_____________________________________________|    |
           |                                                      |
            \_____________________________________________________/
                   \_______________________________________/
                _______________________________________________
             _-'    .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.  --- `-_
          _-'.-.-. .---.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.--.  .-.-.`-_
       _-'.-.-.-. .---.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-`__`. .-.-.-.`-_
    _-'.-.-.-.-. .-----.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-----. .-.-.-.-.`-_
 _-'.-.-.-.-.-. .---.-. .-----------------------------. .-.---. .---.-.-.-.`-_
:-----------------------------------------------------------------------------:
`---._.-----------------------------------------------------------------._.---'
)",
"",
"",
"",
"",
R"(
      ___       ___
     [___] /~\ [___]
     |ooo|.\_/.|ooo|
     |888||   ||888|
    /|888||   ||888|\
  /_,|###||___||###|._\
 /~\  ~~~ /[_]\ ~~~  /~\
(O_O) /~~[_____]~~\ (O_O)
     (  |       |  )
    [~` ]       [ '~]
    |~~|         |~~|
    |  |         |  |
   _<\/>_       _<\/>_
  /_====_\     /_====_\	
)"};

	return Art[level];
}





int PlayGame(int Difficulty, int Challenge, bool GunsSkipped)
{	
	//Call the art and setup story for this level
	string Story = Art(Difficulty);
	std::cout << "\n\n" << Story <<"\n\n";
	
	Story = Setup(Difficulty);
	std::cout << Story <<"\n\n";

	//Level 10 has 2 supplemental story pieces depending on choice made at level 7
	if (Difficulty == 10 && !GunsSkipped)
	{
		Story = Setup(11);
		std::cout << Story <<"\n\n";	
	}
	else if (Difficulty == 10 && GunsSkipped)
	{
		Story = Setup(12);
		std::cout << Story <<"\n\n";
	}

	//create codes. Level 1 and level 10 are special cases that have a different number of codes.
	const int CodeA = rand() % (Difficulty * Challenge) + Difficulty;
	const int CodeB = rand() % (Difficulty * Challenge) + Difficulty;
	const int CodeC = rand() % (Difficulty * Challenge) + Difficulty;
	int CodeSum;
	int CodeProduct;

	if (Difficulty == 1)
	{
	CodeSum = CodeA + CodeB;
	CodeProduct = CodeA * CodeB;
	std::cout << "+ There are two numbers in the code.\n";
	}
	else if (Difficulty == 10)
	{
	const int CodeD = rand() % (Difficulty * Challenge) + Difficulty;
	const int CodeE = rand() % (Difficulty * Challenge) + Difficulty;
	CodeSum = CodeA + CodeB + CodeC + CodeD + CodeE;
	CodeProduct = CodeA * CodeB * CodeC * CodeD * CodeE;
	std::cout << "+++ There are five numbers in the code.\n";
	if (!GunsSkipped)
	{
		std::cout << "+++ The first number in the code is: " << CodeA <<".\n";
	}
	}
	else
	{
	CodeSum = CodeA + CodeB + CodeC;
	CodeProduct = CodeA * CodeB * CodeC;
	std::cout << "+ There are three numbers in the code.\n";
	}

	//Tell players the sum and product. After level 5, also tell them the range.
	std::cout << "+ The numbers Sum to: " << CodeSum << std::endl;
	std::cout << "+ The Product of the numbers is: " << CodeProduct << std::endl;
	if(Difficulty >= 6)
		{
			const int MaxValue = (Difficulty * Challenge) + Difficulty - 1;
			std::cout << "+ Min Value: " << Difficulty << "   Max Value: " << MaxValue << std::endl;
		}


	// Store player guess
	int GuessA, GuessB, GuessC, GuessD, GuessE, GuessSum, GuessProduct;

	if (Difficulty == 1)
	{
	std::cin >> GuessA >> GuessB;
	GuessSum = GuessA + GuessB;
	GuessProduct = GuessA * GuessB;
	}
	else if (Difficulty == 10)
	{
	std::cin >> GuessA >> GuessB >> GuessC >> GuessD >> GuessE;
	GuessSum = GuessA + GuessB + GuessC + GuessD + GuessE;
	GuessProduct = GuessA * GuessB * GuessC * GuessD * GuessE;
	}
	else
	{
	std::cin >> GuessA >> GuessB >> GuessC;
	GuessSum = GuessA + GuessB + GuessC;
	GuessProduct = GuessA * GuessB * GuessC;
	}

	// Check player guess
	std::cout << std::endl;
	if (GuessSum == CodeSum && GuessProduct == CodeProduct)
		{
		Story = Success(Difficulty);
		std::cout << Story;

		if (Difficulty == 10 && !GunsSkipped)
	{
		Story = Success(11);
		std::cout << Story <<"\n\n";	
	}
	else if (Difficulty == 10 && GunsSkipped)
	{
		Story = Success(12);
		std::cout << Story <<"\n\n";
	}

	if (Difficulty == 7)
	{	
		string Reply;
		bool Understood = false;
		while (Understood == false)
		{
		std::cout << "\n\nSlice into the prototype weapons? (Y)es or (N)o: ";
		std::cin >> Reply;
			if (Reply == "Y")
			{
				return 1;
			}
			else if (Reply == "N")
			{
				return 2;
			}
			else
			{
				std::cout << "\n\nCommand not understood. Please enter Y on N.";
				std::cin.clear(); //Clears any errors
				cin.ignore(256, '\n'); //Discards the buffer
			}
			}
		}
		return 1;
		}
	else
		{ 
		if (Difficulty == 1)
		{
			std::cout << "You attempt to slice into the car, but are not able to get past the manufacturer's firewall. \nTry again, and be careful not to get locked out.";
		}
		else if (Difficulty <= 7)
		{
			std::cout << "You triggered an alarm, get out of there now!";
		}
		else if (Difficulty == 8 || Difficulty == 9)
		{
			std::cout << "You've set off an alarm. There is only one way in or out, and it is locked down now. \nThis is bad...";
		}
		else if (Difficulty == 10)
		{
			std::cout << "You were locked out of the system! Without the mech, you are sitting ducks...";
		}

		return 0;
		}
}

int main()
{
	srand(time(NULL));
	int LevelDifficulty = 1;
	int const MaxDifficulty = 10;
	bool GunsSkipped = false; 
	int Challenge = 0;
	
	PrintIntroduction();
	
	//Have player select a challenge level
	while (!(Challenge >= 1 && Challenge <= 5)) 
	{
		std::cout << "Select a level of challenge between 1 and 5: ";
		std::cin >> Challenge;
		if (!(Challenge >= 1 && Challenge <= 5))
		{
			std::cout << "Submitted value out of range. Please enter an int value between 1 and 5.\n";
			std::cin.clear(); //Clears any errors
			cin.ignore(256, '\n'); //Discards the buffer
		}
	}

	std::cin.clear(); //Clears any errors
	cin.ignore(256, '\n'); //Discards the buffer

	while (LevelDifficulty <= MaxDifficulty) 
	{

		int LevelComplete = PlayGame(LevelDifficulty, Challenge, GunsSkipped);
		std::cin.clear(); //Clears any errors
		cin.ignore(256, '\n'); //Discards the buffer

		if (LevelComplete == 1)
		{
			++LevelDifficulty;
		}
		else if (LevelComplete == 2)
		{
			++LevelDifficulty;
			++LevelDifficulty;
			GunsSkipped = true;
		}
		else if (LevelComplete == 0 && LevelDifficulty == 1)
		{
		}
		else if (LevelComplete == 0 && LevelDifficulty >= 2)
		{
			std:cout << "\n\nGame over man, game over!";
			break;
		}
		
	}

	
	std::cout << std::endl;
	system("pause");
	return 0;
} 


4 Likes

Wow you went crazy above and beyond. Awesome job! It looks incredible and the story is cyberpunk which is my favorite.

Damn!

Privacy & Terms