TripleX - Progress So Far

I haven’t opted for my own story, but i’ve taken some liberties with the code :slight_smile:
Please throw me any feedback or room for improvement/observations, I’m keen to learn more!

Cheers!
Ten

#include <iostream>

using std::cout; using std::cin; using std::endl;

void PrintIntroduction (int &Difficulty)
{
    std::string ascii =
"                       .,,uod8B8bou,,.\n\
                  ..,uod8BBBBBBBBBBBBBBBBRPFT?l!i:.\n\
             ,=m8BBBBBBBBBBBBBBBRPFT?!||||||||||||||\n\
             !...:!TVBBBRPFT||||||||||!!^^\"\"\'   ||||\n\
             !.......:!?|||||!!^^\"\'            ||||\n\
             !.........||||                     ||||\n\
             !.........||||  ##                 ||||\n\
             !.........||||                     ||||\n\
             !.........||||                     ||||\n\
             !.........||||                     ||||\n\
             !.........||||                     ||||\n\
             `.........||||                    ,||||\n\
              .;.......||||               _.-!!|||||\n\
       .,uodWBBBBb.....||||       _.-!!|||||||||!:'\n\
    !YBBBBBBBBBBBBBBb..!|||:..-!!|||||||!iof68BBBBBb....\n\
    !..YBBBBBBBBBBBBBBb!!||||||||!iof68BBBBBBRPFT?!::   `.\n\
    !....YBBBBBBBBBBBBBBbaaitf68BBBBBBRPFT?!:::::::::     `.\n\
    !......YBBBBBBBBBBBBBBBBBBBRPFT?!::::::;:!^\"`;:::       `.\n\
    !........YBBBBBBBBBBRPFT?!::::::::::^''...::::::;         iBBbo.\n\
    `..........YBRPFT?!::::::::::::::::::::::::;iof68bo.      WBBBBbo.\n\
      `..........:::::::::::::::::::::::;iof688888888888b.     `YBBBP^'\n\
        `........::::::::::::::::;iof688888888888888888888b.     `\n\
          `......:::::::::;iof688888888888888888888888888888b.\n\
            `....:::;iof688888888888888888888888888888888899fT!\n\
              `..::!8888888888888888888888888888888899fT|!^\"\'\n\
                `\' !!988888888888888888888888899fT|!^\"\'\n\
                    `!!8888888888888888899fT|!^\"\'\n\
                      `!988888888899fT|!^\"\'\n\
                        `!9899fT|!^\"\'\n\
                          `!^\"\'\"\n";
    
    cout << ascii << endl;
    cout << "You are a secret agent breaking into a level " << Difficulty;
    cout << " secure computer containing nuclear launch codes!\nYou need to enter the correct number sequences to steal the launch codes...\n" << endl;
}

bool PlayGame (int &Difficulty)
{
    PrintIntroduction(Difficulty);

    const int CodeNumbers[3] = {2, 4, 8};

    const int CodeSum = CodeNumbers[0] + CodeNumbers[1] + CodeNumbers[2];
    const int CodeProduct = CodeNumbers[0] * CodeNumbers[1] * CodeNumbers[2];

    cout << "There are 3 numbers in the code:" << endl;
    cout << "The codes add up to: " << CodeSum << endl;
    cout << "The product of the codes is: " << CodeProduct << endl;

    int PlayerGuess[3];
    cin >> PlayerGuess[0] >> PlayerGuess[1] >> PlayerGuess[2];

    const int GuessSum = PlayerGuess[0] + PlayerGuess[1] + PlayerGuess[2];
    const int GuessProduct = PlayerGuess[0] * PlayerGuess[1] * PlayerGuess[2];
    
    cout << "You entered : ";
    for(int Guess : PlayerGuess)
    {
        cout << Guess << ", ";
    }
    
    if(GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        cout << "\nYou break through this firewall!" << endl;
        return true;
    } else
    {
        cout << "\nYou've been detected! Try again!\n" << endl;
        system("pause");
        system(("CLS"));
        return false;
    }
}

int main(int argc, char* argv[])
{
    int LevelDifficulty = 1;
    const int MaxDifficulty = 5;

    while(LevelDifficulty <= MaxDifficulty)
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        cin.clear();
        cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

        if(bLevelComplete)
        {
            ++LevelDifficulty;
        }
    }

    cout << "Codes Retrieved!\nXF00-XBAR-XFOO\nGood Work!" << endl;

    return 0;
}

2 Likes

Awesome job!

Here my work so far

#include <iostream>

void PrintIntroduction(int Difficulty)
{   
    std::cout << std::endl << std::endl;                                         
    std::cout << "................................................................................\n";
    std::cout << "...................................=:......~,...................................\n";
    std::cout << "...................................~:...,=.::...................................\n";
    std::cout << "...........................+:+.........?7=.~....~:...~,=........................\n";
    std::cout << ".....................==....~=:~.....:..=~+.~....+...I,~.........................\n";
    std::cout << ".....................:,=....?.+........:,.=?...=,..=~?~,........................\n";
    std::cout << ".......................?.....:,:+...~..+~..........,.?I+........................\n";
    std::cout << "........................?~....,I~...+=.+,.~...:....=:~.=.+....=+................\n";
    std::cout << ".................?........:....:,:+=:=.~,I,..~..:.:=+.~:....=+~?................\n";
    std::cout << ".................:,~,......=?..+~??.I,.=:==..I.+:7=.~,....++?...................\n";
    std::cout << "...........~:~?...=,.~......:=..?~?.?,.+:~,.=~~=,~.,=...+~+,?...................\n";
    std::cout << "..........+??:+~~.:+:7:~.7I..:,+?,=:+,?7~.==,++II,:...,.~.......................\n";
    std::cout << "............~7=+I..~+:~77:=...,,~:~=+==:=?+~=+,?+~:=::~==?......................\n";
    std::cout << ".................===~.==,:7==:+:+:.:~~~:,,~~:,I+I,:=+~?.........................\n";
    std::cout << "...........?+........I+:.:,~~~I+?+:..:==~?,~++I+:,~?............I:..:...........\n";
    std::cout << "...........+===.:~.....~I=~~,,==+7=I=.,=~++I=,=,~?~........:+::=+I+=+:=.........\n";
    std::cout << "...................+:,:,=?=,,=+~..I,.:~.,++I?,.::~???,~,,==+~,,:.:=,:~=.........\n";
    std::cout << "...............:+,~,=?=,=:??,=~=+,I:+:+,,.I+,=,,:+::=I.~==+:~~..................\n";
    std::cout << "........................?:==~:~:=.~+?I~:::,..,+?,~7:?...........................\n";
    std::cout << "..........I=I.?I?~+=I~:=,~:==:???..+~,:,..=~~.~:I?~,~...........................\n";
    std::cout << ".........?+.~~:7=.......+=+~~?~?.~,:~,=..:.::~.=~.,.~I:++=~.....................\n";
    std::cout << "...................=~:=+=+:~I~:++~+??,?,.~:::?~?~:++,7=+,:~:..~=.:?:++,.........\n";
    std::cout << "..............I,,,~:~=?....=..~~7.~?=I~~~?~:.~??:.=~.?+:..?,:+.....=+:~=........\n";
    std::cout << "........~::.=+...........~:+,?7:~+=+~+=+?.:,::++~==.~:....=:~?,,~+..............\n";
    std::cout << "......................+,=+~:++?,:~.+::?=.=+::,.?=,+,:=~,?.......:=+.............\n";
    std::cout << "....................:,?,=...====.,=~=7I=:,??.~,~~,.+,:..=.,~....................\n";
    std::cout << ".................,,..I=.....~,.,=~~,,:,~,,,=I.+,+.~I..+:...+,.+.................\n";
    std::cout << ".............I~..~.:.......:~=.=~:~~:,=+,=,?~,~....I:...,+...++:.=..............\n";
    std::cout << ".............=,=.=........:.~~=.,?:.:~.+I..==+:+:=...:~...+.:...:+..............\n";
    std::cout << ".............,?:........~..:,=,~=++.~,~==..~:~=:=+.:..:.....~=?.................\n";
    std::cout << ".......................:=..:..,:,:..:.+:+...=,,~:..~:.........+.................\n";
    std::cout << "......................~7,:....:~~+..~++..+..+~,.I,,..,..........................\n";
    std::cout << ".......................:~:,..?,=,?.:+.:.=,..+~~.~,=,~=+.........................\n";
    std::cout << "......................,,....++?,~..:,.~..=...~=.,+~,:=,:~.......................\n";
    std::cout << ".......................:...?+~=....:..=..:....=:.=.,,=..........................\n";
    std::cout << ".............................+=....:....I~.....=~=..............................\n";
    std::cout << "...................................,.....?......................................\n";
    std::cout << "................................................................................\n";
    std::cout << "................................................................................\n";
    std::cout << "\n";

    std::cout << "\n\nEn uno de los ultimos laboratorios en el piso " << Difficulty;
    std::cout << " aun queda esperanza\n\nLos virus han extinguido casi por completo la especie humana\n\n";
}

bool PlayGame(int Difficulty)
{
    PrintIntroduction(Difficulty);

    std::cout << "Eres una cientifica descifrando un virus... \n";
    std::cout << "Necesitas introducir un codigo para continuar al siguiente..\n";
    
    
    // Declare 3 number code
    const int CodeA = 4;
    const int CodeB = 3;
    const int CodeC = 2;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeMul = CodeA * CodeB * CodeC;

    // Print sum and product to the terminal
    std::cout << "+ Hay tres numeros en el codigo";
    std::cout << "\n+ Los codigos suman: " << CodeSum;
    std::cout << "\n+ Los codigos multiplicados dan: " << CodeMul << std::endl;
    
    // Store player guess
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;
     
    int GuessSum = GuessA + GuessB + GuessC;
    int GuessMul = GuessA * GuessB * GuessC;

    // Check if player guess is correct
    if (GuessSum == CodeSum && GuessMul == CodeMul)
    {
        std::cout <<"\nGanaste, pasas a descifrar el siguiente virus";
        return true;
    }
    else
    {
        std::cout <<"\nPerdiste, vuelve a intentarlo";
        return false;
    }
}

int main()
{
    int LevelDifficulty = 1;
    const int MaxLevel = 7;

    while (LevelDifficulty <= MaxLevel)
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear(); // Clears any errors
        std::cin.ignore(); // Discards the buffer
        if (bLevelComplete)     
        {
            ++LevelDifficulty;
            
        }
        
    }

    std::cout << "\n\nFelicidades, encontraste todas las curas!!!\n";

    return 0;
}
1 Like

I love how you made a Spanish version!

thank you! :3

Privacy & Terms