TripleX code so far

#include <iostream> //incluir biblioteca externa para print no terminal

void PrintIntroduction()
{
    std::cout <<"TTTTTTTTTTTTTTTTTTTTTTT                     iiii                     lllllll                   XXXXXXX       XXXXXXX !!! ";
    std::cout <<"\nT:::::::::::::::::::::T                    i::::i                    l:::::l                   X:::::X       X:::::X!!:!!";
    std::cout <<"\nT:::::::::::::::::::::T                     iiii                     l:::::l                   X:::::X       X:::::X!:::!";
    std::cout <<"\nT:::::TT:::::::TT:::::T                                              l:::::l                   X::::::X     X::::::X!:::!";
    std::cout <<"\nTTTTTT  T:::::T  TTTTTTrrrrr   rrrrrrrrr  iiiiiiippppp   ppppppppp    l::::l     eeeeeeeeeeee  XXX:::::X   X:::::XXX!:::!";
    std::cout <<"\n        T:::::T        r::::rrr:::::::::r i:::::ip::::ppp:::::::::p   l::::l   ee::::::::::::ee   X:::::X X:::::X   !:::!";
    std::cout <<"\n        T:::::T        r:::::::::::::::::r i::::ip:::::::::::::::::p  l::::l  e::::::eeeee:::::ee  X:::::X:::::X    !:::!";
    std::cout <<"\n        T:::::T        rr::::::rrrrr::::::ri::::ipp::::::ppppp::::::p l::::l e::::::e     e:::::e   X:::::::::X     !:::!";
    std::cout <<"\n        T:::::T         r:::::r     r:::::ri::::i p:::::p     p:::::p l::::l e:::::::eeeee::::::e   X:::::::::X     !:::!";
    std::cout <<"\n        T:::::T         r:::::r     rrrrrrri::::i p:::::p     p:::::p l::::l e:::::::::::::::::e   X:::::X:::::X    !:::!";
    std::cout <<"\n        T:::::T         r:::::r            i::::i p:::::p     p:::::p l::::l e::::::eeeeeeeeeee   X:::::X X:::::X   !!:!!";
    std::cout <<"\n        T:::::T         r:::::r            i::::i p:::::p    p::::::p l::::l e:::::::e         XXX:::::X   X:::::XXX !!! ";
    std::cout <<"\n      TT:::::::TT       r:::::r           i::::::ip:::::ppppp:::::::pl::::::le::::::::e        X::::::X     X::::::X     ";
    std::cout <<"\n      T:::::::::T       r:::::r           i::::::ip::::::::::::::::p l::::::l e::::::::eeeeeeeeX:::::X       X:::::X !!! ";
    std::cout <<"\n      T:::::::::T       r:::::r           i::::::ip::::::::::::::pp  l::::::l  ee:::::::::::::eX:::::X       X:::::X!!:!!";
    std::cout <<"\n      TTTTTTTTTTT       rrrrrrr           iiiiiiiip::::::pppppppp    llllllll    eeeeeeeeeeeeeeXXXXXXX       XXXXXXX !!! ";
    std::cout <<"\n                                                  p:::::p                                                                ";
    std::cout <<"\n                                                  p:::::p                                                                ";
    std::cout <<"\n                                                 p:::::::p                                                               ";
    std::cout <<"\n                                                 p:::::::p                                                               ";
    std::cout <<"\n                                                 p:::::::p                                                               ";
    std::cout <<"\n                                                 ppppppppp                                                         \n\n\n";
    
    // Print welcome message to terminal
    std::cout  <<"                     #==============================================================================#\n";
    std::cout  <<"                     #             Ola sobrevivente, voce precisa escapar de uma caixa.             #\n"; //print terminal primeira msg
    std::cout  <<"                     #         A caixa esta trancada, voce avista alguns cadeados na porta.         #\n";
    std::cout  <<"                     #   Voce nao sabe onde esta, nem o motivo, mas precisa sair dai com urgencia.  #\n";
    std::cout  <<"                     #                                 Boa sorte!                                   #\n";
    std::cout  <<"                     #==============================================================================#\n\n\n";
}

bool PlayGame(int Difficulty)
{
    //declare 3 number code
    const int CodeA = rand() % 10; //variavel CodeA, protegida com const para nao ser alterada
    const int CodeB = rand() % 10;
    const int CodeC = rand() % 10;

    const int CodeSum = CodeA + CodeB + CodeC; //soma das variaveis
    const int CodeProduct = CodeA * CodeB * CodeC; //multiplicacao das variaveis

    //print CodeSum and CodeProduct to the terminal
    std::cout  <<"Aqui tem um cadeado de 3 digitos numericos de Dificuldade " << Difficulty;
    std::cout  <<".\nTem uma etiqueta presa a ele com uma dica.\n";
    std::cout  <<"Os digitos somados resulta em: " << CodeSum; // print da soma
    std::cout  <<"\nOs digitos multiplicados resulta em: " << CodeProduct;// print da multiplicacao
    std::cout  <<"\nDigite a combinacao correta um digito por vez: \n";


    //declarar as variaveis para armazenar entrada no terminal
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    //verifica se o playes esta certo
    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "Uhuull, conseguiu abrir o cadeado! \n\n\n";
        return true;
    }
    else
    {
        std::cout << "Ops... Tente novamente!\n\n\n";
        return false;
    }
}

int main() // funcao princial, agrupar argumentos
{
    PrintIntroduction();

    int LevelDifficulty = 1;
    const int MaxLevelDifficulty = 5;

    while (LevelDifficulty <= MaxLevelDifficulty) // Loop game until all levels completed
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear();// Clear any errors
        std::cin.ignore();// Discards the buffer

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
        
    }

    std::cout << "Parabens, conseguiu abrir todos cadeados.\n\n";
    std::cout << "        GGGGGGGGGGGGG                                                                   OOOOOOOOO                                                                   \n";
    std::cout << "     GGG::::::::::::G                                                                 OO:::::::::OO                                                                 \n";
    std::cout << "   GG:::::::::::::::G                                                               OO:::::::::::::OO                                                               \n";
    std::cout << "  G:::::GGGGGGGG::::G                                                              O:::::::OOO:::::::O                                                              \n";
    std::cout << " G:::::G       GGGGGG  aaaaaaaaaaaaa      mmmmmmm    mmmmmmm       eeeeeeeeeeee    O::::::O   O::::::Ovvvvvvv           vvvvvvv eeeeeeeeeeee    rrrrr   rrrrrrrrr   \n";
    std::cout << "G:::::G                a::::::::::::a   mm:::::::m  m:::::::mm   ee::::::::::::ee  O:::::O     O:::::O v:::::v         v:::::vee::::::::::::ee  r::::rrr:::::::::r  \n";
    std::cout << "G:::::G                aaaaaaaaa:::::a m::::::::::mm::::::::::m e::::::eeeee:::::eeO:::::O     O:::::O  v:::::v       v:::::ve::::::eeeee:::::eer:::::::::::::::::r \n";
    std::cout << "G:::::G    GGGGGGGGGG           a::::a m::::::::::::::::::::::me::::::e     e:::::eO:::::O     O:::::O   v:::::v     v:::::ve::::::e     e:::::err::::::rrrrr::::::r\n";
    std::cout << "G:::::G    G::::::::G    aaaaaaa:::::a m:::::mmm::::::mmm:::::me:::::::eeeee::::::eO:::::O     O:::::O    v:::::v   v:::::v e:::::::eeeee::::::e r:::::r     r:::::r\n";
    std::cout << "G:::::G    GGGGG::::G  aa::::::::::::a m::::m   m::::m   m::::me:::::::::::::::::e O:::::O     O:::::O     v:::::v v:::::v  e:::::::::::::::::e  r:::::r     rrrrrrr\n";
    std::cout << "G:::::G        G::::G a::::aaaa::::::a m::::m   m::::m   m::::me::::::eeeeeeeeeee  O:::::O     O:::::O      v:::::v:::::v   e::::::eeeeeeeeeee   r:::::r            \n";
    std::cout << " G:::::G       G::::Ga::::a    a:::::a m::::m   m::::m   m::::me:::::::e           O::::::O   O::::::O       v:::::::::v    e:::::::e            r:::::r            \n";
    std::cout << "  G:::::GGGGGGGG::::Ga::::a    a:::::a m::::m   m::::m   m::::me::::::::e          O:::::::OOO:::::::O        v:::::::v     e::::::::e           r:::::r            \n";
    std::cout << "   GG:::::::::::::::Ga:::::aaaa::::::a m::::m   m::::m   m::::m e::::::::eeeeeeee   OO:::::::::::::OO          v:::::v       e::::::::eeeeeeee   r:::::r            \n";
    std::cout << "     GGG::::::GGG:::G a::::::::::aa:::am::::m   m::::m   m::::m  ee:::::::::::::e     OO:::::::::OO             v:::v         ee:::::::::::::e   r:::::r            \n";
    std::cout << "        GGGGGG   GGGG  aaaaaaaaaa  aaaammmmmm   mmmmmm   mmmmmm    eeeeeeeeeeeeee       OOOOOOOOO                vvv            eeeeeeeeeeeeee   rrrrrrr            \n";

    return 0; //retorno sucesso, fim da funcao
}
1 Like

Looking good :ok_hand:

Privacy & Terms