diff --git a/.Jules/palette.md b/.Jules/palette.md index 96bd45d..eaed5e0 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -5,3 +5,7 @@ ## 2025-02-28 - Structured CLI Reports **Learning:** Dense numerical data in CLI output is hard to parse. Using ASCII box-drawing characters and alignment to create a "dashboard" or "invoice" style summary significantly improves readability and perceived quality. **Action:** When summarizing simulation or batch job results, always format the final report as a structured table or box rather than a list of print statements. + +## 2025-03-03 - C++ Game Flow and Persistence +**Learning:** Implementing a "play-again" loop in C++ using a `do-while` loop improves game flow by avoiding the need for repeated program execution. ANSI color constants and `` can be used in C++ to achieve the "Palette" aesthetic with structured results boxes and colorful feedback. +**Action:** Use file-based persistence (e.g., `fstream`) to store high scores across sessions, providing users with a sense of progression and competition. diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 540e804..5900a75 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -38,7 +38,7 @@ # 3. Reference the GitHub secret in step using the `hashicorp/setup-terraform` GitHub Action. # Example: # - name: Setup Terraform -# uses: hashicorp/setup-terraform@v1 +# uses: hashicorp/setup-terraform@v3 # with: # cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} @@ -70,7 +70,7 @@ jobs: # Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token - name: Setup Terraform - uses: hashicorp/setup-terraform@v1 + uses: hashicorp/setup-terraform@v3 with: cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} diff --git a/NumberGuess/NumberGuess.cpp b/NumberGuess/NumberGuess.cpp index c82e2f8..139444b 100644 --- a/NumberGuess/NumberGuess.cpp +++ b/NumberGuess/NumberGuess.cpp @@ -2,60 +2,124 @@ #include // For rand() and srand() #include // For time() #include +#include +#include using namespace std; +// ANSI Color Codes +const string RESET = "\033[0m"; +const string RED = "\033[31m"; +const string GREEN = "\033[32m"; +const string YELLOW = "\033[33m"; +const string BLUE = "\033[34m"; +const string MAGENTA = "\033[35m"; +const string CYAN = "\033[36m"; +const string BOLD = "\033[1m"; + +const string HIGHSCORE_FILE = "NumberGuess/highscore.txt"; + +int loadHighScore() { + ifstream file(HIGHSCORE_FILE); + int highScore = 999; + if (file.is_open()) { + file >> highScore; + file.close(); + } + return highScore; +} + +void saveHighScore(int score) { + ofstream file(HIGHSCORE_FILE); + if (file.is_open()) { + file << score; + file.close(); + } +} + void showEasterEgg() { - cout << "\n[!] EASTER EGG ACTIVATED: THE ZEN MODE" << endl; + cout << MAGENTA << "\n[!] EASTER EGG ACTIVATED: THE ZEN MODE" << RESET << endl; cout << "Inspired by the Word 1.1a secret found 29 years later." << endl; cout << "EiJackGH Lab - Saying YES in 2026." << endl; - cout << "========================================" << endl; + cout << MAGENTA << "========================================" << RESET << endl; +} + +void printHeader() { + cout << CYAN << "╔════════════════════════════════════════╗" << RESET << endl; + cout << CYAN << "║ " << BOLD << "EI-JACK LAB: NUMBER GUESSER" << RESET << CYAN << " ║" << RESET << endl; + cout << CYAN << "╚════════════════════════════════════════╝" << RESET << endl; } int main() { // Seed the randomizer srand(static_cast(time(0))); - int secretNumber = rand() % 100 + 1; - string input; - int guess = 0; - int attempts = 0; - - cout << "--- EI-JACK LAB: NUMBER GUESSER V1.0 ---" << endl; - cout << "I'm thinking of a number between 1 and 100." << endl; - cout << "(Hint: Type 'zen' to see the credits)" << endl << endl; - - while (guess != secretNumber) { - cout << "Enter your guess: "; - cin >> input; - - // Check for Easter Egg - if (input == "zen" || input == "ZEN") { - showEasterEgg(); - continue; - } + string playAgainInput; + char playAgain; + int highScore = loadHighScore(); - // Convert string to integer for the game logic - try { - guess = stoi(input); - } catch (...) { - cout << "Invalid input. Please enter a number." << endl; - continue; - } + do { + int secretNumber = rand() % 100 + 1; + string input; + int guess = 0; + int attempts = 0; - attempts++; + printHeader(); + cout << YELLOW << "Current High Score: " << BOLD << (highScore == 999 ? "N/A" : to_string(highScore)) << RESET << " attempts" << endl; + cout << "I'm thinking of a number between " << BOLD << "1 and 100" << RESET << "." << endl; + cout << "(Hint: Type 'zen' to see the credits)" << endl << endl; - if (guess > secretNumber) { - cout << ">>> Too high! Try again." << endl; - } else if (guess < secretNumber) { - cout << ">>> Too low! Try again." << endl; - } else { - cout << "\nCONGRATULATIONS!" << endl; - cout << "You found it in " << attempts << " attempts." << endl; + while (guess != secretNumber) { + cout << "Enter your guess: "; + if (!(cin >> input)) break; + + // Check for Easter Egg + if (input == "zen" || input == "ZEN") { + showEasterEgg(); + continue; + } + + // Convert string to integer for the game logic + try { + guess = stoi(input); + } catch (...) { + cout << RED << "Invalid input. Please enter a number." << RESET << endl; + continue; + } + + attempts++; + + if (guess > secretNumber) { + cout << RED << ">>> Too high! 📈 Try again." << RESET << endl; + } else if (guess < secretNumber) { + cout << BLUE << ">>> Too low! 📉 Try again." << RESET << endl; + } else { + cout << "\n" << GREEN << BOLD << "🎉 CONGRATULATIONS! 🎉" << RESET << endl; + + cout << "╔════════════════════════════════════════╗" << endl; + cout << "║ " << BOLD << "GAME SUMMARY" << RESET << " ║" << endl; + cout << "╠════════════════════════════════════════╣" << endl; + cout << "║ Attempts: " << setw(28) << left << attempts << " ║" << endl; + + if (attempts < highScore) { + highScore = attempts; + saveHighScore(highScore); + // Adjusted padding for emoji width (Emoji 🏆 is 2-char wide in many terminals) + cout << "║ " << GREEN << BOLD << "NEW HIGH SCORE! 🏆" << RESET << setw(20) << "" << " ║" << endl; + } + + cout << "╚════════════════════════════════════════╝" << endl; + } } - } - cout << "----------------------------------------" << endl; - system("pause"); // Essential for Dev-C++ to keep the window open + cout << "\nDo you want to play again? (y/n): "; + if (!(cin >> playAgainInput)) break; + playAgain = playAgainInput[0]; + cout << endl; + + } while (playAgain == 'y' || playAgain == 'Y'); + + cout << CYAN << "Thanks for playing! See you next time at EiJack Lab! 👋" << RESET << endl; + return 0; } diff --git a/NumberGuess/highscore.txt b/NumberGuess/highscore.txt new file mode 100644 index 0000000..a6905f8 --- /dev/null +++ b/NumberGuess/highscore.txt @@ -0,0 +1 @@ +999 diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..75db792 --- /dev/null +++ b/main.tf @@ -0,0 +1 @@ +terraform {}