My Treasure Hunter TripleX game

#include <iostream>
#include <ctime>

void PrintIntroduction( int PasswordCodeSum, int PasswordCodeMultiplication, int Difficulty)
{
    std::cout << R"("               
                    s$P*.s$$$s.`*T$$b T TP$P.d$P .sd$s.                
                .s$P .s$$$$$$$b. T$$b T:P d$$P.d$$$$$$bs.             
               d$$P d$$$$P'`T$$$b $$$;:$bd$$$$$$b`T$$*$$$b.           
              d$$P d$$$P' .+. *$$:$$$;.$$$P^*""*^b.$$b T$$$b          
             d$P .d$$$b.s$$$$$b TP^TP dP',d$$$$$s.`T$$b T$$$b         
            d$P d$$P T$$$P*""*^b.b d,P^*"*^T$$$$$$$b`T$b$$$$$.        
           ,$P d$P .$$$P'       `'*`        `T$$$$$$$b`T$$$$$$         
           :$ d$P d$$$P                       `T$$$$$$b TPT$$$b        
          :$$d$$ d$$$P                          T$$$$$$b T.`T$$;       
          :$$$$$d$$$P                            T$$$$ $b T.T$$:       
          $$$$$P$$$$                              T$$$$T$b T `T$       
          $P$$$;$$$;                               T$^$b Tb b :$       
          $`$$$ $$$;                                T.T$b TY$,:$       
          $:$$$ $$$'                                `$ T$; $$;'$       
          $;$$$;$$$                                  `b T; $$$ $       
          $:T$$;$$$  .d$$s.                    .s$$b..$;:$;$$$.T       
         / __`*:$$$ *'   `*Tb._            _.dP*'   `*$;:$:$P__ \      
        ..' .`.:$$$         `*Ts'        `sP*'        $$:$$P'. `,,     
        ;  /   ,$$;   .+s**s.   `.           .s**s+.  T$:PP'  \  :     
        : ,   /:$$;   \ *ss* \    ;         / *ss* /    +: \   . ;     
         .`  :  $$;,  .+s$$$s+.            .+s$$$s+.  .* ;  ;  ',      
          \   *.:$$,*d$P*"$$$T$b  ,+**+,  d$P*"$$$T$b*   .*    /       
           \    `$$;:$; +:$$$:$$;*      *:$; +:$$$:$$;  :     /        
                 $$; T$b._$$$d$P          T$b._$$$d$P   ;              
             `._.:$$, `*T$$$P*'            `*T$$$P*'    :._.'          
                 |$$;             '                     |P$$b.         
                 ;`$$,           :.     ,               :b.`T$b        
                 ` T$$b._        `*.__.*'               d$$b T$b       
                  . *TP*'           ""                 d$$$$b.:$;      
                   \                                  dP T$$$$$$$      
                    \          .+*"*--*"*+.          d$b. T$$^$$$      
                     `.       :._.--..--._.;       .'$$$$; $$ $$$      
                       ;.      `.        .'      .'  $$$$$ $P $$;      
                       : `.      `*----*'      .'    $$$$$ $b $P       
                       |   `.                .'      $$$$$Y$$dP        
                       :     `.            .'        :T$$P$$P,db.      
                      /        `-.      .-'          dbT d$Pd$$$$b.    
                     /            `****'            d$$$PT$$$b T$$$b   
                   .'                              d$$$P db`T$b T$$$b  
                _.'                               :$$$P.d$$b:$$$`$$$$; 
           _.-*' `.                               $$$$:$$$$$;$$$:$$$$$ 
                   `-.                            :$$$;$$$$$$$$$;$$$$$ 
                      `-.                        .-T$$$$P$$$$$P d$$$$; 
                         `.     `.     .*      .'   T$$$b`T$P.sd$$$$P  
                           `.     `-  '      .'      `T$$b$$$$$$$$P'   
                             `.            .'          `T.T$$$$P$$$b.  
                               `.        .'             :$$$$P'd$$$$$;  
                                 `.    .'               $$$$$:d$;$$$$$.
                                   `..'                 :$$$$;$$$b`T$$;
                                                         T$$$:$$$$; $$$
                                                          T$$$T$$$;d$$;
                                                           `T$b`T$$$$P 
                                                             `*b T$P'
    )" << "\n\n";
    std::cout << R"(
        ____________ΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆ
        __________ΒΆΒΆΒΆ____ΒΆΒΆΒΆ_____ΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆ
        ________ΒΆΒΆΒΆ__ΒΆΒΆ__ΒΆΒΆ_ΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆΒΆ___ΒΆΒΆΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆΒΆΒΆ
        ______ΒΆΒΆΒΆ__ΒΆΒΆΒΆ__ΒΆΒΆ__ΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆΒΆ___ΒΆΒΆΒΆΒΆΒΆΒΆ__ΒΆΒΆΒΆΒΆΒΆΒΆ
        ____ΒΆΒΆΒΆ___ΒΆΒΆΒΆ___ΒΆΒΆ_ΒΆΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆΒΆ____ΒΆΒΆΒΆΒΆΒΆΒΆ___ΒΆΒΆΒΆΒΆΒΆ
        ___ΒΆΒΆ___ΒΆΒΆΒΆΒΆΒΆ__ΒΆΒΆ__ΒΆΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆΒΆ____ΒΆΒΆΒΆΒΆΒΆΒΆΒΆ____ΒΆΒΆΒΆΒΆΒΆ
        _ΒΆΒΆ____ΒΆΒΆΒΆΒΆΒΆ___ΒΆΒΆ__ΒΆΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆΒΆ_____ΒΆΒΆΒΆΒΆΒΆΒΆ_____ΒΆΒΆΒΆΒΆΒΆΒΆ
        ΒΆΒΆΒΆΒΆΒΆ_____ΒΆΒΆ__ΒΆΒΆ__ΒΆΒΆΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆΒΆ_____ΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆ
        __ΒΆΒΆΒΆΒΆΒΆΒΆΒΆ____ΒΆΒΆΒΆ__ΒΆΒΆΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆΒΆ___ΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆ
        ___ΒΆΒΆΒΆ___ΒΆΒΆΒΆΒΆΒΆΒΆ__________ΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆ
        _____ΒΆΒΆ__ΒΆ___ΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆ__ΒΆΒΆΒΆ
        _______ΒΆΒΆ_ΒΆΒΆΒΆ_ΒΆΒΆ_________ΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆΒΆ___ΒΆΒΆΒΆΒΆ
        ________ΒΆΒΆ__ΒΆΒΆ_ΒΆΒΆ__ΒΆΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆ______ΒΆΒΆΒΆΒΆ___ΒΆΒΆΒΆ
        __________ΒΆΒΆ_ΒΆΒΆ_ΒΆΒΆ__ΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆ_____ΒΆΒΆΒΆΒΆ__ΒΆΒΆΒΆ
        ___________ΒΆΒΆ_ΒΆΒΆ_ΒΆΒΆ_ΒΆΒΆΒΆΒΆ__ΒΆΒΆ____ΒΆΒΆΒΆΒΆ__ΒΆΒΆΒΆ
        _____________ΒΆΒΆ_ΒΆ_ΒΆΒΆ_ΒΆΒΆΒΆ__ΒΆΒΆ___ΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆ
        _______________ΒΆ_ΒΆ_ΒΆΒΆ_ΒΆΒΆ__ΒΆΒΆ__ΒΆΒΆΒΆΒΆ_ΒΆΒΆΒΆ
        ________________ΒΆΒΆ__ΒΆ__ΒΆ__ΒΆΒΆ__ΒΆΒΆΒΆΒΆΒΆΒΆ
        __________________ΒΆ__ΒΆ____ΒΆΒΆ_ΒΆΒΆΒΆΒΆΒΆΒΆ
        ___________________ΒΆΒΆ_ΒΆ___ΒΆΒΆΒΆΒΆΒΆΒΆΒΆ
        _____________________ΒΆΒΆΒΆ__ΒΆΒΆΒΆΒΆΒΆΒΆ
        ______________________ΒΆΒΆΒΆ_ΒΆΒΆΒΆΒΆ
        ________________________ΒΆΒΆΒΆΒΆΒΆ
        __________________________ΒΆ

    )" << "\n\n";

    std::cout << R"(
         /$$      /$$           /$$                                                           
        | $$  /$ | $$          | $$                                                           
        | $$ /$$$| $$  /$$$$$$ | $$  /$$$$$$$  /$$$$$$  /$$$$$$/$$$$   /$$$$$$                
        | $$/$$ $$ $$ /$$__  $$| $$ /$$_____/ /$$__  $$| $$_  $$_  $$ /$$__  $$               
        | $$$$_  $$$$| $$$$$$$$| $$| $$      | $$  \ $$| $$ \ $$ \ $$| $$$$$$$$               
        | $$$/ \  $$$| $$_____/| $$| $$      | $$  | $$| $$ | $$ | $$| $$_____/               
        | $$/   \  $$|  $$$$$$$| $$|  $$$$$$$|  $$$$$$/| $$ | $$ | $$|  $$$$$$$               
        |__/     \__/ \_______/|__/ \_______/ \______/ |__/ |__/ |__/ \_______/               
                                                                                      
                                                                                      
                                                                                      
           /$$                                                                                
          | $$                                                                                
         /$$$$$$    /$$$$$$   /$$$$$$   /$$$$$$   /$$$$$$$ /$$   /$$  /$$$$$$   /$$$$$$       
        |_  $$_/   /$$__  $$ /$$__  $$ |____  $$ /$$_____/| $$  | $$ /$$__  $$ /$$__  $$      
          | $$    | $$  \__/| $$$$$$$$  /$$$$$$$|  $$$$$$ | $$  | $$| $$  \__/| $$$$$$$$      
          | $$ /$$| $$      | $$_____/ /$$__  $$ \____  $$| $$  | $$| $$      | $$_____/      
          |  $$$$/| $$      |  $$$$$$$|  $$$$$$$ /$$$$$$$/|  $$$$$$/| $$      |  $$$$$$$      
           \___/  |__/       \_______/ \_______/|_______/  \______/ |__/       \_______/      
                                                                                      
                                                                                      
                                                                                      
         /$$                             /$$                                                  
        | $$                            | $$                                                  
        | $$$$$$$  /$$   /$$ /$$$$$$$  /$$$$$$    /$$$$$$   /$$$$$$                           
        | $$__  $$| $$  | $$| $$__  $$|_  $$_/   /$$__  $$ /$$__  $$                          
        | $$  \ $$| $$  | $$| $$  \ $$  | $$    | $$$$$$$$| $$  \__/                          
        | $$  | $$| $$  | $$| $$  | $$  | $$ /$$| $$_____/| $$                                
        | $$  | $$|  $$$$$$/| $$  | $$  |  $$$$/|  $$$$$$$| $$                                
        |__/  |__/ \______/ |__/  |__/   \___/   \_______/|__/                                
                                                                                      
    )" << "\n\n";

    std::cout << "You are now a Treasure Hunter try to get the precious treasure" << std::endl;
    std::cout << "To get the treasure you need to input the correct password for level " << Difficulty <<"\n\n";

    std::cout << "There are 3 numbers in the password code" << std::endl;
    std::cout << "The password codes add-up to: " << PasswordCodeSum << std::endl;
    std::cout << "The password codes mutiply to give: " << PasswordCodeMultiplication << "\n\n";
}

bool PlayGame(int Difficulty)
{
    int PasswordCodeA{ rand() % Difficulty + Difficulty }, PasswordCodeB{ rand() % Difficulty + Difficulty }, PasswordCodeC{ rand() % Difficulty + Difficulty };
    std::cout << PasswordCodeA << " " << PasswordCodeB << " " << PasswordCodeC;
    int PasswordCodeSum{ PasswordCodeA + PasswordCodeB + PasswordCodeC };
    int PasswordCodeMultiplication{ PasswordCodeA * PasswordCodeB * PasswordCodeC };

    int GuessA{}, GuessB{}, GuessC{};
    int GuessSum{}, GuessMultiplication{};

    PrintIntroduction(PasswordCodeSum, PasswordCodeMultiplication, Difficulty);

    std::cout << "Please enter your guess password codes: ";
    std::cin >> GuessA;
    std::cin >> GuessB;
    std::cin >> GuessC;

    GuessSum = GuessA + GuessB + GuessC;
    GuessMultiplication = GuessA * GuessB * GuessC;

    if (GuessSum == PasswordCodeSum && GuessMultiplication == PasswordCodeMultiplication)
    {
        std::cout << "Proceed to next level!" << std::endl;
        return true;
    }
    else
    {
        std::cout << "Wrong answer please try it again!\n\n";
        return false;
    }
}

int main()
{
    int LevelDifficulty{ 1 };
    constexpr int MaxLevel{ 5 };

    srand(time(NULL));

    while (LevelDifficulty <= MaxLevel) // Loop 
    {
        bool bLevelComplete{ PlayGame(LevelDifficulty) };
        std::cin.clear(); // Clear any errors
        std::cin.ignore(); // Discard the buffer

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
    }

    std::cout << "You have won an Acient Precious Treasure!" << std::endl;

    return 0;
}

Sorry for long code

1 Like

WOW :star_struck: Very impressive!

Privacy & Terms