Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<iomanip>` 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.
4 changes: 2 additions & 2 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down Expand Up @@ -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 }}

Expand Down
140 changes: 102 additions & 38 deletions NumberGuess/NumberGuess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,124 @@
#include <cstdlib> // For rand() and srand()
#include <ctime> // For time()
#include <string>
#include <fstream>
#include <iomanip>

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<unsigned int>(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;
}
1 change: 1 addition & 0 deletions NumberGuess/highscore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
999
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform {}
Loading