diff --git a/.vscode/settings.json b/.vscode/settings.json index 6b03945..a5de478 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@ ".fantomasignore": "ignore", "iostream": "cpp", "ostream": "cpp" - } + }, + "C_Cpp.errorSquiggles": "disabled" } \ No newline at end of file diff --git a/MeetingProfessorOak.cpp b/MeetingProfessorOak.cpp index ae364f9..903f34d 100644 --- a/MeetingProfessorOak.cpp +++ b/MeetingProfessorOak.cpp @@ -1,84 +1,84 @@ -#include +// #include -using namespace std; +// using namespace std; -enum class PokemonChoice{ - Bulbasaur, - Charmander, - Squirtle, - Invalid_Choice +// enum class PokemonChoice{ +// Bulbasaur, +// Charmander, +// Squirtle, +// Invalid_Choice -}; +// }; -int main() { - string player_name; - PokemonChoice chosen_pokemon; +// int main() { +// string player_name; +// PokemonChoice chosen_pokemon; - cout << "What's up, kid! I'm Professor Oak, the Pokémon Professor!" << endl; +// cout << "What's up, kid! I'm Professor Oak, the Pokémon Professor!" << endl; - cout << "Wait... who are you again? Oh right, you must be the new trainer!" << endl; +// cout << "Wait... who are you again? Oh right, you must be the new trainer!" << endl; - cout << "Ah yes, before we begin, tell me your name, young one." << endl; +// cout << "Ah yes, before we begin, tell me your name, young one." << endl; - cin >> player_name; +// cin >> player_name; - cout << player_name << "?! Haha, that's a great name! It reminds me of when I was your age... but let's not get into that." << endl; +// cout << player_name << "?! Haha, that's a great name! It reminds me of when I was your age... but let's not get into that." << endl; - cout << "Hmm, looks like you don't have any Pokémon yet, do you?" << endl; +// cout << "Hmm, looks like you don't have any Pokémon yet, do you?" << endl; - cout << "Don't worry! Every great journey begins with a first step—and a Pokémon partner!" << endl; +// cout << "Don't worry! Every great journey begins with a first step—and a Pokémon partner!" << endl; - int playerChoice; - cout << "\nI've got three amazing Pokémon right here in front of me. Each one has a unique bond with nature. Choose wisely!" << endl; +// int playerChoice; +// cout << "\nI've got three amazing Pokémon right here in front of me. Each one has a unique bond with nature. Choose wisely!" << endl; - cout << "Here are your choices:\n"; +// cout << "Here are your choices:\n"; - cout << "1) Bulbasaur.\n2) Charmander.\n3) Squirtle.\n" << endl; +// cout << "1) Bulbasaur.\n2) Charmander.\n3) Squirtle.\n" << endl; - cout << "So, " << player_name << ", which Pokémon will be your loyal companion? Enter 1, 2, or 3: "; - cin >> playerChoice ; - cout<<"\n"; +// cout << "So, " << player_name << ", which Pokémon will be your loyal companion? Enter 1, 2, or 3: "; +// cin >> playerChoice ; +// cout<<"\n"; - switch (playerChoice) - { - case 1: - chosen_pokemon = PokemonChoice::Bulbasaur; - break; - case 2: - chosen_pokemon = PokemonChoice::Charmander; - break; - case 3: - chosen_pokemon = PokemonChoice::Squirtle; - break; +// switch (playerChoice) +// { +// case 1: +// chosen_pokemon = PokemonChoice::Bulbasaur; +// break; +// case 2: +// chosen_pokemon = PokemonChoice::Charmander; +// break; +// case 3: +// chosen_pokemon = PokemonChoice::Squirtle; +// break; - default: - chosen_pokemon = PokemonChoice::Invalid_Choice; - break; - } +// default: +// chosen_pokemon = PokemonChoice::Invalid_Choice; +// break; +// } - switch (chosen_pokemon) - { - case PokemonChoice::Bulbasaur: - cout << "You chose Bulbasaur! A wise choice indeed. This little guy will be your steady partner through thick and thin, trust me." << endl; - cout << "Bulbasaur looks up at you with big, trusting eyes, ready for an adventure!" << endl; - break; - case PokemonChoice::Charmander: - cout << "You chose Charmander! A fiery choice, full of energy and potential. Watch out, though, that tail flame means business!" << endl; - cout << "Charmander lets out a cheerful growl, its tail flame burning brightly as it anticipates the challenges ahead." << endl; - break; - case PokemonChoice::Squirtle: - cout << "You chose Squirtle! A cool, composed choice. This little turtle will help you navigate through any stormy waters you encounter." << endl; - cout << "Squirtle gives you a confident nod, ready to splash into battle whenever you are!" << endl; - default: - cout << "Professor Oak: Hmm, that doesn't seem right. Let me choose for you...\n"; - chosen_pokemon = PokemonChoice::Charmander; - cout << "Professor Oak: Just kidding! Let's go with Charmander, the fiery dragon in the making!\n"; - break; - break; - } +// switch (chosen_pokemon) +// { +// case PokemonChoice::Bulbasaur: +// cout << "You chose Bulbasaur! A wise choice indeed. This little guy will be your steady partner through thick and thin, trust me." << endl; +// cout << "Bulbasaur looks up at you with big, trusting eyes, ready for an adventure!" << endl; +// break; +// case PokemonChoice::Charmander: +// cout << "You chose Charmander! A fiery choice, full of energy and potential. Watch out, though, that tail flame means business!" << endl; +// cout << "Charmander lets out a cheerful growl, its tail flame burning brightly as it anticipates the challenges ahead." << endl; +// break; +// case PokemonChoice::Squirtle: +// cout << "You chose Squirtle! A cool, composed choice. This little turtle will help you navigate through any stormy waters you encounter." << endl; +// cout << "Squirtle gives you a confident nod, ready to splash into battle whenever you are!" << endl; +// default: +// cout << "Professor Oak: Hmm, that doesn't seem right. Let me choose for you...\n"; +// chosen_pokemon = PokemonChoice::Charmander; +// cout << "Professor Oak: Just kidding! Let's go with Charmander, the fiery dragon in the making!\n"; +// break; +// break; +// } - cout << "\nWell, " << player_name << ", your journey begins now. Go forth, explore the world of Pokémon with your mate " <<(chosen_pokemon == PokemonChoice::Charmander ? "Charmander" : chosen_pokemon == PokemonChoice::Bulbasaur ? "Bulbasaur" : "Squirtle")<< ", and remember—there's a whole world waiting for you!" << endl; +// cout << "\nWell, " << player_name << ", your journey begins now. Go forth, explore the world of Pokémon with your mate " <<(chosen_pokemon == PokemonChoice::Charmander ? "Charmander" : chosen_pokemon == PokemonChoice::Bulbasaur ? "Bulbasaur" : "Squirtle")<< ", and remember—there's a whole world waiting for you!" << endl; - return 0; -} +// return 0; +// } diff --git a/Player.cpp b/Player.cpp new file mode 100644 index 0000000..23c14b6 --- /dev/null +++ b/Player.cpp @@ -0,0 +1,47 @@ +#include "Player.hpp" +#include "PokemonChoice.hpp" +#include "PokemonType.hpp" +#include "Utility.hpp" +#include "iostream" +using namespace std; + Player :: Player(){ + name = "Trainer"; + chosenPokemon = Pokemon(); + } + + // Parameterized Constructor + Player :: Player(string p_name, Pokemon p_chosenPokemon){ + name = p_name; + chosenPokemon = p_chosenPokemon; + + } + + // // copy contructor + // Player :: Player(const Player &p) { + // name = p.name; + // chosenPokemon = p.chosenPokemon; + + // } + + void Player :: choosePokemon(int choice) { + switch ((PokemonChoice)choice) { + case PokemonChoice::CHARMANDER: + chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); + break; + case PokemonChoice::BULBASAUR: + chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); + break; + case PokemonChoice::SQUIRTLE: + chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); + break; + default: + chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); + break; + } + cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; + Utility::waitForEnter(); + + + + + } \ No newline at end of file diff --git a/Player.hpp b/Player.hpp new file mode 100644 index 0000000..59d1324 --- /dev/null +++ b/Player.hpp @@ -0,0 +1,16 @@ +#include +#include "Pokemon.hpp" +using namespace std; + +class Pokemon; + +class Player { +public: + string name; + Pokemon chosenPokemon; + + Player(); // Default constructor + Player(std::string p_name, Pokemon p_chosenPokemon); // Parameterized constructor + + void choosePokemon(int choice); // Method to choose a Pokemon +}; \ No newline at end of file diff --git a/Pokemon b/Pokemon new file mode 100644 index 0000000..06eb866 Binary files /dev/null and b/Pokemon differ diff --git a/Pokemon.cpp b/Pokemon.cpp new file mode 100644 index 0000000..7e7af81 --- /dev/null +++ b/Pokemon.cpp @@ -0,0 +1,33 @@ +#include "Pokemon.hpp" +#include +#include "PokemonType.hpp" +using namespace std; + +Pokemon::Pokemon() { + name = "Unknown"; + type = PokemonType::NORMAL; + health = 50; +} + +// Parameterized constructor +Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health) { + name = p_name; + type = p_type; + health = p_health; +} + +// Copy constructor +Pokemon::Pokemon(const Pokemon &other) { + name = other.name; + type = other.type; + health = other.health; +} + +// Destructor +Pokemon::~Pokemon() { + // Destructor logic (if any) goes here +} + +void Pokemon::attack() { + cout << name << " attacks with a powerful move!\n"; +} \ No newline at end of file diff --git a/Pokemon.hpp b/Pokemon.hpp new file mode 100644 index 0000000..2cf1160 --- /dev/null +++ b/Pokemon.hpp @@ -0,0 +1,25 @@ +#include +using namespace std; + +enum class PokemonType; + +class Pokemon { +public: + string name; + PokemonType type; + int health; + + // Default constructor + Pokemon(); + + // Parameterized constructor + Pokemon(string p_name, PokemonType p_type, int p_health); + + // Copy constructor + Pokemon(const Pokemon &other); + + // Destructor + ~Pokemon(); + + void attack(); +}; \ No newline at end of file diff --git a/PokemonChoice.hpp b/PokemonChoice.hpp new file mode 100644 index 0000000..ef6152f --- /dev/null +++ b/PokemonChoice.hpp @@ -0,0 +1,7 @@ +enum class PokemonChoice{ + CHARMANDER = 1, + BULBASAUR, + SQUIRTLE, + PIKACHU + +}; \ No newline at end of file diff --git a/PokemonType.hpp b/PokemonType.hpp new file mode 100644 index 0000000..e85f5e9 --- /dev/null +++ b/PokemonType.hpp @@ -0,0 +1,8 @@ + +enum class PokemonType{ + FIRE, + GRASS, + WATER, + ELECTRIC, + NORMAL +}; \ No newline at end of file diff --git a/Utility.cpp b/Utility.cpp new file mode 100644 index 0000000..4b25407 --- /dev/null +++ b/Utility.cpp @@ -0,0 +1,22 @@ +#include "Utility.hpp" +#include +#include +using namespace std; + +void Utility :: clearConsole(){ + #ifdef _WIN32 + system("cls"); +#else + (void)system("clear"); +#endif +} + +void Utility :: waitForEnter(){ + // cout << "(Press Enter to \033[34mcontinue\033[0m...)" << endl; + + + cin.get(); +} +void Utility :: clearInputBuffer(){ + cin.ignore(numeric_limits::max(), '\n'); +} \ No newline at end of file diff --git a/Utility.hpp b/Utility.hpp new file mode 100644 index 0000000..8bfb5e4 --- /dev/null +++ b/Utility.hpp @@ -0,0 +1,6 @@ +class Utility{ +public: + static void clearConsole(); + static void waitForEnter(); + static void clearInputBuffer(); +}; \ No newline at end of file diff --git a/main b/main deleted file mode 100755 index 6afdb54..0000000 Binary files a/main and /dev/null differ diff --git a/main.cpp b/main.cpp index 947bf86..e4b9bc7 100644 --- a/main.cpp +++ b/main.cpp @@ -1,249 +1,204 @@ -#include - +#include "Player.hpp" +#include "PokemonChoice.hpp" +#include "PokemonType.hpp" +#include "Utility.hpp" +#include +#include // Include this header to use std::numeric_limits +#include using namespace std; -void WaitforEnter(){ - // cout << "(Press Enter to \033[34mcontinue\033[0m...)" << endl; - - - cin.get(); -} -void clearConsole(){ -#ifdef _WIN32 - system("cls"); -#else - (void)system("clear"); -#endif -} -enum class PokemonType{ - FIRE, - GRASS, - WATER, - ELECTRIC, - NORMAL -}; - -enum class PokemonChoice{ - CHARMANDER = 1, - BULBASAUR, - SQUIRTLE, - PIKACHU - -}; -class Pokemon{ +// ProfessorOak class definition +class ProfessorOak { public: - string name; - PokemonType type; - int health; - - Pokemon(){ - name = "Unknown"; - type = PokemonType::NORMAL; - health = 50; - } - - // Parameterized Constructor - Pokemon(string p_name, PokemonType p_type, int p_health){ - name = p_name; - type = p_type; - health = p_health; - } - Pokemon(const Pokemon &other) { - name = other.name; - type = other.type; - health = other.health; - } - ~Pokemon() { - // Destructor message removed - } - void attack(){ - cout << name <<" attacks with a powerful move!" << endl; - } + string name; + + // Parameterized constructor + ProfessorOak(std::string p_name) { name = p_name; } + + void greetPlayer(Player &player) { + cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; + Utility::waitForEnter(); + cout << name + << ": My name is Oak. People call me the Pokemon Professor!\n"; + Utility::waitForEnter(); + cout << name << ": But enough about me. Let's talk about you!\n"; + Utility::waitForEnter(); + } + + void offerPokemonChoices(Player &player) { + cout + << name + << ": First, tell me, what’s your name? \t [Please Enter Your Name]\n"; + getline(cin, player.name); + cout << name << ": Ah, " << player.name + << "! What a fantastic name!\n"; + Utility::waitForEnter(); + cout << name + << ": You must be eager to start your adventure. But first, " + "you’ll need a Pokemon of your own!\n"; + Utility::waitForEnter(); + + // Presenting Pokemon choices + cout + << name + << ": I have three Pokemon here with me. They’re all quite feisty!\n"; + Utility::waitForEnter(); + cout << name << ": Choose wisely...\n"; + cout << "1. Charmander - The fire type. A real hothead!\n"; + cout << "2. Bulbasaur - The grass type. Calm and collected!\n"; + cout << "3. Squirtle - The water type. Cool as a cucumber!\n"; + + int choice; + cout + << name + << ": So, which one will it be? Enter the number of your choice: "; + cin >> choice; + + player.choosePokemon(choice); + Utility::waitForEnter(); + } + + // New method for the main quest conversation + void explainMainQuest(Player &player) { + // Clear the console + Utility::clearConsole(); + + cout << "Professor Oak: " << player.name + << "!, I am about to explain you about your upcoming grand " + "adventure.\n"; + Utility::waitForEnter(); + cout << "Professor Oak: You see, becoming a Pokémon Master is no easy " + "feat. It takes courage, wisdom, and a bit of luck!\n"; + Utility::waitForEnter(); + cout + << "Professor Oak: Your mission, should you choose to accept it—and " + "trust me, you really don’t have a choice—is to collect all the " + "Pokémon Badges and conquer the Pokémon League.\n"; + Utility::waitForEnter(); + + cout << "\n" + << player.name + << ": Wait... that sounds a lot like every other Pokémon game " + "out there...\n"; + Utility::waitForEnter(); + cout << "Professor Oak: Shhh! Don't break the fourth wall, " + << player.name << "! This is serious business!\n"; + Utility::waitForEnter(); + + cout << "\nProfessor Oak: To achieve this, you’ll need to battle wild " + "Pokémon, challenge gym leaders, and of course, keep your " + "Pokémon healthy at the PokeCenter.\n"; + Utility::waitForEnter(); + cout << "Professor Oak: Along the way, you'll capture new Pokémon to " + "strengthen your team. Just remember—there’s a limit to how " + "many Pokémon you can carry, so choose wisely!\n"; + Utility::waitForEnter(); + + cout << "\n" + << player.name << ": Sounds like a walk in the park... right?\n"; + Utility::waitForEnter(); + cout << "Professor Oak: Hah! That’s what they all say! But beware, " + "young Trainer, the path to victory is fraught with " + "challenges. And if you lose a battle... well, let’s just say " + "you'll be starting from square one.\n"; + Utility::waitForEnter(); + + cout << "\nProfessor Oak: So, what do you say? Are you ready to " + "become the next Pokémon Champion?\n"; + Utility::waitForEnter(); + cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; + Utility::waitForEnter(); + + cout + << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; + Utility::waitForEnter(); + cout << "Professor Oak: But first... let's just pretend I didn't " + "forget to set up the actual game loop... Ahem, onwards!\n"; + Utility::waitForEnter(); + } }; -class Player{ - public: - string name; - Pokemon chosenPokemon; - - Player(){ - name = "Trainer"; - chosenPokemon = Pokemon(); +// Function to handle the main game loop +void gameLoop(Player &player) { + int choice; + bool keepPlaying = true; + + while (keepPlaying) { + // Clear console before showing options + Utility::clearConsole(); + + // Display options to the player + cout << "\nWhat would you like to do next, " << player.name << "?\n"; + cout << "1. Battle Wild Pokémon\n"; + cout << "2. Visit PokeCenter\n"; + cout << "3. Challenge Gyms\n"; + cout << "4. Enter Pokémon League\n"; + cout << "5. Quit\n"; + cout << "Enter your choice: "; + cin >> choice; + + Utility::clearInputBuffer(); // Clear the input buffer + + // Process the player's choice and display the corresponding message + switch (choice) { + case 1: + cout << "You look around... but all the wild Pokémon are on " + "vacation. Maybe try again later?\n"; + break; + case 2: + cout + << "You head to the PokeCenter, but Nurse Joy is out on a coffee " + "break. Guess your Pokémon will have to tough it out for now!\n"; + break; + case 3: + cout << "You march up to the Gym, but it's closed for renovations. " + "Seems like even Gym Leaders need a break!\n"; + break; + case 4: + cout << "You boldly step towards the Pokémon League... but the " + "gatekeeper laughs and says, 'Maybe next time, champ!'\n"; + break; + case 5: + cout << "You try to quit, but Professor Oak's voice echoes: " + "'There's no quitting in Pokémon training!'\n"; + cout << "Are you sure you want to quit? (y/n): "; + char quitChoice; + cin >> quitChoice; + if (quitChoice == 'y' || quitChoice == 'Y') { + keepPlaying = false; + } + break; + default: + std::cout << "That's not a valid choice. Try again!\n"; + break; } - // Parameterized Constructor - Player(string p_name, Pokemon p_chosenPokemon){ - name = p_name; - chosenPokemon = p_chosenPokemon; + // Wait for Enter key before the screen is cleared and the menu is shown + // again + Utility::waitForEnter(); + } - } - - // copy contructor - Player(const Player &p) { - name = p.name; - chosenPokemon = p.chosenPokemon; - + cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; } - void choosePokemon(int choice) { - switch ((PokemonChoice)choice) { - case PokemonChoice::CHARMANDER: - chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); - break; - case PokemonChoice::BULBASAUR: - chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); - break; - case PokemonChoice::SQUIRTLE: - chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); - break; - default: - chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); - break; - } - cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; - WaitforEnter(); - - - - - } -}; -class ProfessorOak{ - public: - string name; +int main() { + // Create Pokemon and Player objects for the game + Pokemon charmander("Charmander", PokemonType::FIRE, + 100); // Using parameterized constructor - ProfessorOak(){ + // Continue with the main flow of the game + ProfessorOak professor("Professor Oak"); + Player player("Ash", charmander); - } - ProfessorOak(string p_name) { - name = p_name; - } - void greetPlayer(Player &player){ - cout << "What's up, kid! I'm Professor Oak, the Pokémon Professor!" << endl; - WaitforEnter(); - cout << "Wait... who are you again? Oh right, you must be the new trainer!" << endl; - WaitforEnter(); - cout << "Ah yes, before we begin, tell me your name, young one." << endl; - WaitforEnter(); - cin >> player.name; - - cout << player.name << "?! Haha, that's a great name! It reminds me of when I was your age... but let's not get into that." << endl; - } + // Greet the player and offer Pokemon choices + professor.greetPlayer(player); + professor.offerPokemonChoices(player); - void offerPokemonChoices(Player &player){ - int playerChoice; - cout << "Hmm, looks like you don't have any Pokémon yet, do you?" << endl; - - cout << "Don't worry! Every great journey begins with a first step—and a Pokémon partner!" << endl; - - cout << "\nI've got three amazing Pokémon right here in front of me. Each one has a unique bond with nature. Choose wisely!" << endl; - - WaitforEnter(); - cout << "Here are your choices:\n"; - - cout << "1) Bulbasaur.\n2) Charmander.\n3) Squirtle.\n" << endl; - - cout << "So, " << player.name << ", which Pokémon will be your loyal companion? Enter 1, 2, or 3: "; - cin >> playerChoice ; - cout<<"\n"; - player.choosePokemon(playerChoice); - WaitforEnter(); - - } + // Explain the main quest + professor.explainMainQuest(player); - void explainMainQuest(Player &player){ - - cout<<"Professor Oak: Ah, "<> choice; - - cin.ignore(numeric_limits::max(), '\n'); - switch (choice) - { - case 1: - cout<< "You look around... but all the wild Pokemon are on vacation. Maybe try again later?\n"; - break; - case 2: - cout<< "You head to the PokeCenter, but Nurse Joy is out on a coffee break. Guess your Pokemon will have to tough it out for now!\n"; - break; - case 3: - cout<< "You march up to the Gym, but it's closed for renovations. Seems like even Gym Leaders need a break!\n"; - break; - case 4: - cout<< "You boldly step towards the Pokemon League... but the gatekeeper laughs and says, 'Maybe next time, champ!'\n"; - break; - case 5: - cout<< "You try to quit, but Professor Oak's voice echoes: 'There's no quitting in Pokemon training!'\n"; - cout << "Are you sure you want to quit? (y/n): "; - char quitChoice; - cin >> quitChoice; - if (quitChoice == 'y' || quitChoice == 'Y') { - keepPlaying = false; - } - break; - default:cout << "That's not a valid choice. Try again!\n"; - break; - } - WaitforEnter(); - } - cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; - - } - int main(){ - - Pokemon charmander("Charmander", PokemonType::FIRE, 100); // Using parameterized constructor - - - ProfessorOak professor("Professor Oak"); - Player player("Ash", charmander); - - - professor.greetPlayer(player); - professor.offerPokemonChoices(player); + // Start the main game loop + gameLoop(player); - clearConsole(); - professor.explainMainQuest(player); - - - gameLoop(player); - - return 0; - - -} \ No newline at end of file + return 0; +} diff --git a/tempCodeRunnerFile.cpp b/tempCodeRunnerFile.cpp new file mode 100644 index 0000000..83e15de --- /dev/null +++ b/tempCodeRunnerFile.cpp @@ -0,0 +1 @@ +#include "Utility.hpp" \ No newline at end of file