From f9310914a5efd2275efd785161c12b3387922f1f Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Wed, 9 Jul 2025 10:48:38 +0530 Subject: [PATCH 01/25] Added greeting message and name input to main() --- Pokemon/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index c2bc7bfc..6a01d1af 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,6 +1,17 @@ #include +using namespace std; int main() { + string player_name; + cout<< "Enter your Name" << endl; + + cin >> player_name; + + cout << "Great Start " << player_name << ", looks like you have understood the main() function properly now!" << endl; return 0; } + + + + From cd8736172a155841e7e648c1c81bda222136c1ec Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Wed, 9 Jul 2025 12:51:26 +0530 Subject: [PATCH 02/25] Giving the choice to with adding their name --- Pokemon/main.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 6a01d1af..ddf4909f 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -7,7 +7,27 @@ int main() { cin >> player_name; - cout << "Great Start " << player_name << ", looks like you have understood the main() function properly now!" << endl; + cout <<"Welcome to the Pokemon world " << player_name << "!,I am Professor Oak \n"; + cout << "Choose your Pokemon\n"; + cout << "1.Bulbasaur\n2.Charmander\n3.Squirtle\n"; + + int choice; + cin >> choice; + + if (choice == 1) { + cout << "your mate is Bulbasaur\n"; + } + else if (choice == 2) { + cout << "your mate is Charmander\n"; + } + else if (choice == 3) { + cout << "Your mate is Squirtle\n"; + } + else { + cout << "It's an invalid choice\n"; + } + + cout << "Ah, an excellent choice!\nBut beware, Trainer,this is only the beginning.\nYour journey is about to unfold.\nNow let’s see if you’ve got what it takes to keep going!\nGood luck, and remember… Choose wisely!"; return 0; } From 479c3a8b15e79e867442b0accae12a58d90d5c4a Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Fri, 18 Jul 2025 12:37:30 +0530 Subject: [PATCH 03/25] Enum done --- Pokemon/main.cpp | 223 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 202 insertions(+), 21 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index ddf4909f..32af6d8a 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,37 +1,218 @@ #include +#include using namespace std; -int main() { - string player_name; - cout<< "Enter your Name" << endl; - - cin >> player_name; +// Define an enum for Pokemon choices +enum class PokemonChoice { + Charmander = 1, + Bulbasaur, + Squirtle, + InvalidChoice +}; - cout <<"Welcome to the Pokemon world " << player_name << "!,I am Professor Oak \n"; - cout << "Choose your Pokemon\n"; - cout << "1.Bulbasaur\n2.Charmander\n3.Squirtle\n"; +enum class PokemonType { + Fire, + Electric, + Water, + Earth, + Normal +}; - int choice; - cin >> choice; +enum class HealingItems { + Potion, + Elixir +}; + +enum class BattleItems { + Potion, + Elixir +}; + +class Pokemon { +public: + string name; + PokemonType type; + int health; + + //created 2 constructors + Pokemon(){ - if (choice == 1) { - cout << "your mate is Bulbasaur\n"; } - else if (choice == 2) { - cout << "your mate is Charmander\n"; + + Pokemon(string p_name, PokemonType p_type, int p_health) { + name = p_name; + type = p_type; + health = p_health; } - else if (choice == 3) { - cout << "Your mate is Squirtle\n"; + + void attack() { cout << name << " attack with a powerful move!\n"; } +}; + +class Player { +public: + //Attributes + string name; + Pokemon chosenPokemon; + + //Method to choose pokemon + void choosePokemon(int choice) { + switch ((PokemonChoice)choice) { + case PokemonChoice::Charmander: + chosenPokemon = Pokemon("Charmander", PokemonType::Fire, 100); + break; + case PokemonChoice::Bulbasaur: + chosenPokemon = Pokemon("Bulbasaur", PokemonType::Earth, 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"; + } - else { - cout << "It's an invalid choice\n"; +}; + +//Professor oak class definition +class ProfessorOak { +public: + string name; + + //method to greet player + void greetPlayer(Player& player) { + cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; + cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; + cout << name << ": But enough about me. Let's talk about you!\n"; } - cout << "Ah, an excellent choice!\nBut beware, Trainer,this is only the beginning.\nYour journey is about to unfold.\nNow let’s see if you’ve got what it takes to keep going!\nGood luck, and remember… Choose wisely!"; + //Method to ask the player to choose a pokemon + void offerPokemonChoices(Player& player) { + cout << name << ": First, tell me, what’s your name?\n"; + getline(cin, player.name); + cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; + cout << name << ": You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; - return 0; -} + //Presenting Pokemon choices + cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; + cout << name << ": Choose wisely...\n"; std::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\n"; + cin >> choice; + player.choosePokemon(choice); + } +}; + +int main() { + + //Creating Obejcts of ProffessorOak,Pokemon and player class + ProfessorOak professor; + Pokemon placeholderPokemon; + Player player; + //Assigning values to PlaceholderPokemon attributes + placeholderPokemon.name = "Pikachu"; + placeholderPokemon.type = PokemonType::Electric; + placeholderPokemon.health = 40; + //Assigniong values to the player attribute + player.name = "Trainer"; + //Assigning values to the professorOak + professor.name = "Professor Oak"; + //Greet the player and offer Pokemon choices + professor.greetPlayer(player); + professor.offerPokemonChoices(player); + + //Conclude the first chapter + cout << "Professor Oak: " << player.chosenPokemon.name << " and you, " << player.name << ", are going to be the best of friends!\n"; + cout << "Professor Oak: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; + + + /*// Variables to store player name and chosen Pokemon + string player_name; + PokemonChoice chosen_pokemon = PokemonChoice::Charmander; // Default to an invalid choice + */ + //Using HealingItems + /*HealingItems HealPack = HealingItems::Elixir; + + //Using BattleItems + BattleItems BattlePack = BattleItems::Potion; + + cout << "Choose the Pack" << endl; + + switch (HealingItems) { + case 1: cout << "Healing Potion used! Your Pokémon recovers HP!\n"; + break; + case 2: cout << "Healing Elixir used! Your Pokémon recovers HP!\n"; + }*/ + /* + // Introduction by the Professor + cout << "Professor Oak: Hello there! Welcome to the world of Pokemon!\n"; + cout << "Professor Oak: My name is Oak. People call me the Pokemon Professor!\n"; + cout << "Professor Oak: But enough about me. Let's talk about you!\n"; + + // Taking player name as input + cout << "Professor Oak: First, tell me, what’s your name?\n"; + cin >> player_name; + + cout << "Professor Oak: Ah, " << player_name << "! What a fantastic name!\n"; + cout << "Professor Oak: You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; + + // Presenting Pokemon choices + cout << "Professor Oak: I have three Pokemon here with me. They’re all quite feisty!\n"; + cout << "Professor Oak: 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 << "Professor Oak: So, which one will it be? Enter the number of your choice: "; + cin >> choice; + + // Map the integer choice to the corresponding enum value + switch (choice) { + case 1: + chosen_pokemon = Charmander; + break; + case 2: + chosen_pokemon = Bulbasaur; + break; + case 3: + chosen_pokemon = Squirtle; + break; + default: + chosen_pokemon = InvalidChoice; + break; + } + + // Respond based on the chosen Pokemon + switch (chosen_pokemon) { + case Charmander: + cout << "Professor Oak: A fiery choice! Charmander is yours!\n"; + break; + case Bulbasaur: + cout << "Professor Oak: A fine choice! Bulbasaur is always ready to grow on you!\n"; + break; + case Squirtle: + cout << "Professor Oak: Splendid! Squirtle will keep you cool under pressure!\n"; + break; + default: + cout << "Professor Oak: Hmm, that doesn't seem right. Let me choose for you...\n"; + chosen_pokemon = Charmander; // Default to Charmander if invalid choice + cout << "Professor Oak: Just kidding! Let's go with Charmander, the fiery dragon in the making!\n"; + break; + } + + // Concluding the first chapter + cout << "Professor Oak: " << (chosen_pokemon == Charmander ? "Charmander" : chosen_pokemon == Bulbasaur ? "Bulbasaur" : "Squirtle") + << " and you, " << player_name << ", are going to be the best of friends!\n"; + cout << "Professor Oak: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; + */ + return 0; +} \ No newline at end of file From de466fa5dcd9661189ba024e665791182fe7efc6 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Fri, 18 Jul 2025 17:51:04 +0530 Subject: [PATCH 04/25] Function calls are done! --- Pokemon/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 32af6d8a..97b2988d 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -107,6 +107,20 @@ class ProfessorOak { } }; +void castSpell(int MagicLevel) { + cout << "Casting spell with magic level: "< Date: Mon, 21 Jul 2025 15:53:07 +0530 Subject: [PATCH 05/25] Cmstructor scroll done --- Pokemon/main.cpp | 264 +++++++++++++++++++---------------------------- 1 file changed, 109 insertions(+), 155 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 97b2988d..c4b24bd7 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -4,230 +4,184 @@ using namespace std; // Define an enum for Pokemon choices enum class PokemonChoice { - Charmander = 1, - Bulbasaur, - Squirtle, - InvalidChoice + CHARMANDER = 1, + BULBASAUR, + SQUIRTLE, + PIKACHU // Default choice }; +// Define an enum for Pokemon types enum class PokemonType { - Fire, - Electric, - Water, - Earth, - Normal -}; - -enum class HealingItems { - Potion, - Elixir -}; - -enum class BattleItems { - Potion, - Elixir + FIRE, + GRASS, + WATER, + ELECTRIC, + NORMAL // Added for the default constructor }; +// Pokemon class definition class Pokemon { public: + // Attributes string name; PokemonType type; int health; - //created 2 constructors - Pokemon(){ - + // Default constructor + Pokemon() { + name = "Unknown"; + type = PokemonType::NORMAL; + health = 50; + cout << "A new Pokemon has been created with the default constructor!\n"; } + // Parameterized constructor Pokemon(string p_name, PokemonType p_type, int p_health) { name = p_name; type = p_type; health = p_health; + cout << "A new Pokemon named " << name << " has been created!\n"; + } + + // Copy constructor + Pokemon(const Pokemon& other) { + name = other.name; + type = other.type; + health = other.health; + cout << "A new Pokemon has been copied from " << other.name << "!\n"; + } + + // Destructor + ~Pokemon() { + cout << name << " has been released.\n"; } - void attack() { cout << name << " attack with a powerful move!\n"; } + // Method to simulate attacking (just for demonstration) + void attack() { + cout << name << " attacks with a powerful move!\n"; + } }; +// Player class definition class Player { public: - //Attributes + // Attributes string name; Pokemon chosenPokemon; - //Method to choose pokemon + // Default constructor + Player() { + name = "Trainer"; + chosenPokemon = Pokemon(); // Using the default Pokemon constructor + cout << "A new player named " << name << " has been created!\n"; + } + + // Parameterized constructor + Player(std::string p_name, Pokemon p_chosenPokemon) { + name = p_name; + chosenPokemon = p_chosenPokemon; + cout << "Player " << name << " has been created!\n"; + } + + // Method to choose a Pokemon void choosePokemon(int choice) { switch ((PokemonChoice)choice) { - case PokemonChoice::Charmander: - chosenPokemon = Pokemon("Charmander", PokemonType::Fire, 100); + + case PokemonChoice::CHARMANDER: + chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); break; - case PokemonChoice::Bulbasaur: - chosenPokemon = Pokemon("Bulbasaur", PokemonType::Earth, 100); + case PokemonChoice::BULBASAUR: + chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); break; - case PokemonChoice::Squirtle: - chosenPokemon = Pokemon("Squirtle", PokemonType::Water, 100); + case PokemonChoice::SQUIRTLE: + chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); break; default: - chosenPokemon = Pokemon("Pikachu", PokemonType::Electric, 100); + chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); break; } - cout << "Player " << name << " chose" << chosenPokemon.name << "!\n"; + cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; } }; -//Professor oak class definition +// ProfessorOak class definition class ProfessorOak { public: + // Attributes string name; - //method to greet player + // Parameterized constructor + ProfessorOak(string p_name) { + name = p_name; + } + + // Method to greet the player void greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; cout << name << ": But enough about me. Let's talk about you!\n"; } - //Method to ask the player to choose a pokemon + // Method to ask the player to choose a Pokemon void offerPokemonChoices(Player& player) { cout << name << ": First, tell me, what’s your name?\n"; - getline(cin, player.name); + getline(std::cin, player.name); cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; cout << name << ": You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; - //Presenting Pokemon choices + // Presenting Pokemon choices cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; - cout << name << ": Choose wisely...\n"; std::cout << "1. Charmander - The fire type. A real hothead!\n"; + 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\n"; + cout << name << ": So, which one will it be? Enter the number of your choice: "; cin >> choice; + player.choosePokemon(choice); } }; -void castSpell(int MagicLevel) { - cout << "Casting spell with magic level: "<> player_name; - - cout << "Professor Oak: Ah, " << player_name << "! What a fantastic name!\n"; - cout << "Professor Oak: You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; - - // Presenting Pokemon choices - cout << "Professor Oak: I have three Pokemon here with me. They’re all quite feisty!\n"; - cout << "Professor Oak: 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 << "Professor Oak: So, which one will it be? Enter the number of your choice: "; - cin >> choice; - - // Map the integer choice to the corresponding enum value - switch (choice) { - case 1: - chosen_pokemon = Charmander; - break; - case 2: - chosen_pokemon = Bulbasaur; - break; - case 3: - chosen_pokemon = Squirtle; - break; - default: - chosen_pokemon = InvalidChoice; - break; - } - - // Respond based on the chosen Pokemon - switch (chosen_pokemon) { - case Charmander: - cout << "Professor Oak: A fiery choice! Charmander is yours!\n"; - break; - case Bulbasaur: - cout << "Professor Oak: A fine choice! Bulbasaur is always ready to grow on you!\n"; - break; - case Squirtle: - cout << "Professor Oak: Splendid! Squirtle will keep you cool under pressure!\n"; - break; - default: - cout << "Professor Oak: Hmm, that doesn't seem right. Let me choose for you...\n"; - chosen_pokemon = Charmander; // Default to Charmander if invalid choice - cout << "Professor Oak: Just kidding! Let's go with Charmander, the fiery dragon in the making!\n"; - break; - } - - // Concluding the first chapter - cout << "Professor Oak: " << (chosen_pokemon == Charmander ? "Charmander" : chosen_pokemon == Bulbasaur ? "Bulbasaur" : "Squirtle") - << " and you, " << player_name << ", are going to be the best of friends!\n"; - cout << "Professor Oak: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; - */ return 0; } \ No newline at end of file From 736cb67979431d28ece8eb72c076158896ff8b73 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Tue, 22 Jul 2025 14:15:20 +0530 Subject: [PATCH 06/25] Main quest done --- Pokemon/main.cpp | 154 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 29 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index c4b24bd7..3e3c9eb3 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -2,6 +2,20 @@ #include using namespace std; +// Function to clear the console +void clearConsole() { + // Platform-specific clear console command +#ifdef _WIN32 + system("cls"); +#else + (void)system("clear"); +#endif +} + +// Function to wait for user to press Enter +void waitForEnter() { + cin.get();//Wait for enter key +} // Define an enum for Pokemon choices enum class PokemonChoice { CHARMANDER = 1, @@ -32,7 +46,6 @@ class Pokemon { name = "Unknown"; type = PokemonType::NORMAL; health = 50; - cout << "A new Pokemon has been created with the default constructor!\n"; } // Parameterized constructor @@ -40,7 +53,6 @@ class Pokemon { name = p_name; type = p_type; health = p_health; - cout << "A new Pokemon named " << name << " has been created!\n"; } // Copy constructor @@ -48,12 +60,11 @@ class Pokemon { name = other.name; type = other.type; health = other.health; - cout << "A new Pokemon has been copied from " << other.name << "!\n"; } // Destructor ~Pokemon() { - cout << name << " has been released.\n"; + //Destructor message removed } // Method to simulate attacking (just for demonstration) @@ -73,14 +84,12 @@ class Player { Player() { name = "Trainer"; chosenPokemon = Pokemon(); // Using the default Pokemon constructor - cout << "A new player named " << name << " has been created!\n"; } // Parameterized constructor Player(std::string p_name, Pokemon p_chosenPokemon) { name = p_name; chosenPokemon = p_chosenPokemon; - cout << "Player " << name << " has been created!\n"; } // Method to choose a Pokemon @@ -119,8 +128,11 @@ class ProfessorOak { // Method to greet the player void greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; + waitForEnter(); cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; + waitForEnter(); cout << name << ": But enough about me. Let's talk about you!\n"; + waitForEnter(); } // Method to ask the player to choose a Pokemon @@ -128,7 +140,9 @@ class ProfessorOak { cout << name << ": First, tell me, what’s your name?\n"; getline(std::cin, player.name); cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; + waitForEnter(); cout << name << ": You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; + waitForEnter(); // Presenting Pokemon choices cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; @@ -143,33 +157,109 @@ class ProfessorOak { player.choosePokemon(choice); } + + void explainMainQuest(Player& player) { + cout << "Professor Oak: Oak-ay" << player.name << "!, I am about to explain you about your upcoming grand adventure.\n"; + 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"; + 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"; + waitForEnter(); + + cout << "\n" << player.name << ": Wait... that sounds a lot like every other Pokémon game out there...\n"; + waitForEnter(); + cout << "Professor Oak: Shhh! Don't break the fourth wall, " << player.name << "! This is serious business!\n"; + 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"; + 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"; + waitForEnter(); + + cout << "\n" << player.name << ": Sounds like a walk in the park... right?\n"; + 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"; + waitForEnter(); + + cout << "\nProfessor Oak: So, what do you say? Are you ready to become the next Pokémon Champion?\n"; + waitForEnter(); + cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; + waitForEnter(); + + cout << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; + waitForEnter(); + cout << "Professor Oak: But first... let's just pretend I didn't forget to set up the actual game loop... Ahem, onwards!\n"; + waitForEnter(); + } + + }; -int main() { - // Task 1: Test default and parameterized constructors - Pokemon defaultPokemon; // Using default constructor - Pokemon charmander("Charmander", PokemonType::FIRE, 100); // Using parameterized constructor +//Function to handle the main game loop +void gameloop(Player& player) { + int choice; + bool keepPlaying = true; + + while (keepPlaying) { + //Clear console before showing options + clearConsole(); - cout << "Pokemon Details:\n"; - cout << "Name: " << defaultPokemon.name << "\nType: " << (int)defaultPokemon.type << "\nHealth: " << defaultPokemon.health << "\n"; - cout << "Name: " << charmander.name << "\nType: " << (int)charmander.type << "\nHealth: " << charmander.health << "\n"; + // 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; - // Task 2: Test the copy constructor - Pokemon bulbasaur("Bulbasaur", PokemonType::GRASS, 100); // Create a Pokemon - Pokemon bulbasaurCopy = bulbasaur; // Copy the Pokemon - cout << "Original Pokemon Health: " << bulbasaur.health << "\n"; - cout << "Copied Pokemon Health: " << bulbasaurCopy.health << "\n"; + //Clear the newline character left in the buffer after cin >> choice + cin.ignore(numeric_limits::max(), '\n'); - // Modify the copy - bulbasaurCopy.health = 80; - cout << "After Modification:\n"; - cout << "Original Pokemon Health: " << bulbasaur.health << "\n"; - cout << "Copied Pokemon Health: " << bulbasaurCopy.health << "\n"; + // 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 is 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; + } + // Wait for Enter key before the screen is cleared and the menu is shown + // again + waitForEnter(); + } + cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; +} - // Task 3: Test the destructor - { - Pokemon squirtle("Squirtle", PokemonType::WATER, 100); // Pokemon will be destroyed at the end of this scope - } // Destructor will be called here +int main() { + // Create Pokemon and Player objects for the game + Pokemon charmander("Charmander", PokemonType::FIRE, 100); // Using parameterized constructor // Continue with the main flow of the game ProfessorOak professor("Professor Oak"); @@ -179,9 +269,15 @@ int main() { professor.greetPlayer(player); professor.offerPokemonChoices(player); - // Conclude the first chapter + //Explain the main quest + professor.explainMainQuest(player); + + //Start the main game loop + gameloop(player); + + /*// Conclude the first chapter cout << "Professor Oak: " << player.chosenPokemon.name << " and you, " << player.name << ", are going to be the best of friends!\n"; cout << "Professor Oak: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; - + */ return 0; } \ No newline at end of file From dd1ccfdaec8e24fa8d23bf682a1ef2d68311c02e Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Tue, 29 Jul 2025 00:22:34 +0530 Subject: [PATCH 07/25] head --- Pokemon/header.cpp | 1 + Pokemon/header.h | 6 ++ Pokemon/main.cpp | 159 ++++++++++++++++++++++++++------------------- 3 files changed, 99 insertions(+), 67 deletions(-) create mode 100644 Pokemon/header.cpp create mode 100644 Pokemon/header.h diff --git a/Pokemon/header.cpp b/Pokemon/header.cpp new file mode 100644 index 00000000..f5bec35f --- /dev/null +++ b/Pokemon/header.cpp @@ -0,0 +1 @@ +#include "header.h" diff --git a/Pokemon/header.h b/Pokemon/header.h new file mode 100644 index 00000000..82876bef --- /dev/null +++ b/Pokemon/header.h @@ -0,0 +1,6 @@ +#pragma once +class header +{ + +}; + diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 3e3c9eb3..704e23b8 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,4 +1,5 @@ #include +#include // Include this header to use numeric_limits #include using namespace std; @@ -14,10 +15,11 @@ void clearConsole() { // Function to wait for user to press Enter void waitForEnter() { - cin.get();//Wait for enter key + cin.get(); // Wait for Enter key } + // Define an enum for Pokemon choices -enum class PokemonChoice { +enum PokemonChoice { CHARMANDER = 1, BULBASAUR, SQUIRTLE, @@ -25,7 +27,7 @@ enum class PokemonChoice { }; // Define an enum for Pokemon types -enum class PokemonType { +enum PokemonType { FIRE, GRASS, WATER, @@ -36,7 +38,6 @@ enum class PokemonType { // Pokemon class definition class Pokemon { public: - // Attributes string name; PokemonType type; int health; @@ -44,12 +45,12 @@ class Pokemon { // Default constructor Pokemon() { name = "Unknown"; - type = PokemonType::NORMAL; + type = NORMAL; health = 50; } // Parameterized constructor - Pokemon(string p_name, PokemonType p_type, int p_health) { + Pokemon(std::string p_name, PokemonType p_type, int p_health) { name = p_name; type = p_type; health = p_health; @@ -64,19 +65,15 @@ class Pokemon { // Destructor ~Pokemon() { - //Destructor message removed + // Destructor message removed } - // Method to simulate attacking (just for demonstration) - void attack() { - cout << name << " attacks with a powerful move!\n"; - } + void attack() { std::cout << name << " attacks with a powerful move!\n"; } }; // Player class definition class Player { public: - // Attributes string name; Pokemon chosenPokemon; @@ -92,116 +89,144 @@ class Player { chosenPokemon = p_chosenPokemon; } - // Method to choose a Pokemon void choosePokemon(int choice) { - switch ((PokemonChoice)choice) { - - case PokemonChoice::CHARMANDER: - chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); + switch (choice) { + case CHARMANDER: + chosenPokemon = Pokemon("Charmander", FIRE, 100); break; - case PokemonChoice::BULBASAUR: - chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); + case BULBASAUR: + chosenPokemon = Pokemon("Bulbasaur", GRASS, 100); break; - case PokemonChoice::SQUIRTLE: - chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); + case SQUIRTLE: + chosenPokemon = Pokemon("Squirtle", WATER, 100); break; default: - chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); + chosenPokemon = Pokemon("Pikachu", ELECTRIC, 100); break; } - cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; + waitForEnter(); // Wait for user to press Enter before proceeding } }; // ProfessorOak class definition class ProfessorOak { public: - // Attributes string name; // Parameterized constructor - ProfessorOak(string p_name) { - name = p_name; - } + ProfessorOak(string p_name) { name = p_name; } - // Method to greet the player void greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; waitForEnter(); - cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; + cout << name + << ": My name is Oak. People call me the Pokemon Professor!\n"; waitForEnter(); cout << name << ": But enough about me. Let's talk about you!\n"; waitForEnter(); } - // Method to ask the player to choose a Pokemon void offerPokemonChoices(Player& player) { - cout << name << ": First, tell me, what’s your name?\n"; + cout + << name + << ": First, tell me, what’s your name? \t [Please Enter Your Name]\n"; getline(std::cin, player.name); - cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; + cout << name << ": Ah, " << player.name + << "! What a fantastic name!\n"; waitForEnter(); - cout << name << ": You must be eager to start your adventure. But first, you’ll need a Pokemon of your own!\n"; + cout << name + << ": You must be eager to start your adventure. But first, " + "you’ll need a Pokemon of your own!\n"; waitForEnter(); // Presenting Pokemon choices - cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; + cout + << name + << ": I have three Pokemon here with me. They’re all quite feisty!\n"; + 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: "; + cout + << name + << ": So, which one will it be? Enter the number of your choice: "; cin >> choice; player.choosePokemon(choice); + waitForEnter(); } + // New method for the main quest conversation void explainMainQuest(Player& player) { - cout << "Professor Oak: Oak-ay" << player.name << "!, I am about to explain you about your upcoming grand adventure.\n"; + // Clear the console + clearConsole(); + + cout << "Professor Oak: " << player.name + << "!, I am about to explain you about your upcoming grand " + "adventure.\n"; 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"; + cout << "Professor Oak: You see, becoming a Pokémon Master is no easy " + "feat. It takes courage, wisdom, and a bit of luck!\n"; 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"; + 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"; waitForEnter(); - cout << "\n" << player.name << ": Wait... that sounds a lot like every other Pokémon game out there...\n"; + cout << "\n" + << player.name + << ": Wait... that sounds a lot like every other Pokémon game " + "out there...\n"; waitForEnter(); - cout << "Professor Oak: Shhh! Don't break the fourth wall, " << player.name << "! This is serious business!\n"; + cout << "Professor Oak: Shhh! Don't break the fourth wall, " + << player.name << "! This is serious business!\n"; 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"; + 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"; 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"; + 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"; waitForEnter(); - cout << "\n" << player.name << ": Sounds like a walk in the park... right?\n"; + cout << "\n" + << player.name << ": Sounds like a walk in the park... right?\n"; 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"; + 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"; waitForEnter(); - cout << "\nProfessor Oak: So, what do you say? Are you ready to become the next Pokémon Champion?\n"; + cout << "\nProfessor Oak: So, what do you say? Are you ready to " + "become the next Pokémon Champion?\n"; waitForEnter(); cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; waitForEnter(); - cout << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; + cout + << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; waitForEnter(); - cout << "Professor Oak: But first... let's just pretend I didn't forget to set up the actual game loop... Ahem, onwards!\n"; + cout << "Professor Oak: But first... let's just pretend I didn't " + "forget to set up the actual game loop... Ahem, onwards!\n"; waitForEnter(); } - - }; -//Function to handle the main game loop -void gameloop(Player& player) { +// Function to handle the main game loop +void gameLoop(Player& player) { int choice; bool keepPlaying = true; while (keepPlaying) { - //Clear console before showing options + // Clear console before showing options clearConsole(); // Display options to the player @@ -214,9 +239,10 @@ void gameloop(Player& player) { cout << "Enter your choice: "; cin >> choice; - //Clear the newline character left in the buffer after cin >> choice + // Clear the newline character left in the buffer after cin >> choice cin.ignore(numeric_limits::max(), '\n'); + // Process the player's choice and display the corresponding message switch (choice) { case 1: @@ -238,28 +264,31 @@ void gameloop(Player& player) { break; case 5: cout << "You try to quit, but Professor Oak's voice echoes: " - "There is no quitting in Pokemon training!\n"; - cout << "Are you sure you want to quit?(y/n)"; + "'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'){ + if (quitChoice == 'y' || quitChoice == 'Y') { keepPlaying = false; } break; default: - cout << "That's not a valid choice.Try again!\n"; + cout << "That's not a valid choice. Try again!\n"; break; - } + } + // Wait for Enter key before the screen is cleared and the menu is shown // again waitForEnter(); } + cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; } int main() { // Create Pokemon and Player objects for the game - Pokemon charmander("Charmander", PokemonType::FIRE, 100); // Using parameterized constructor + Pokemon charmander("Charmander", FIRE, + 100); // Using parameterized constructor // Continue with the main flow of the game ProfessorOak professor("Professor Oak"); @@ -269,15 +298,11 @@ int main() { professor.greetPlayer(player); professor.offerPokemonChoices(player); - //Explain the main quest + // Explain the main quest professor.explainMainQuest(player); - //Start the main game loop - gameloop(player); + // Start the main game loop + gameLoop(player); - /*// Conclude the first chapter - cout << "Professor Oak: " << player.chosenPokemon.name << " and you, " << player.name << ", are going to be the best of friends!\n"; - cout << "Professor Oak: Your journey begins now! Get ready to explore the vast world of Pokemon!\n"; - */ return 0; -} \ No newline at end of file +} From 17c437945ff3a84bf9c73766b81762b381f0624c Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Tue, 29 Jul 2025 00:49:20 +0530 Subject: [PATCH 08/25] Can't understand the errord --- Pokemon/PokemonChoice.cpp | 1 + Pokemon/PokemonChoice.h | 7 +++++++ Pokemon/PokemonType.cpp | 1 + Pokemon/PokemonType.h | 8 ++++++++ Pokemon/main.cpp | 22 ++++------------------ 5 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 Pokemon/PokemonChoice.cpp create mode 100644 Pokemon/PokemonChoice.h create mode 100644 Pokemon/PokemonType.cpp create mode 100644 Pokemon/PokemonType.h diff --git a/Pokemon/PokemonChoice.cpp b/Pokemon/PokemonChoice.cpp new file mode 100644 index 00000000..3a124bf6 --- /dev/null +++ b/Pokemon/PokemonChoice.cpp @@ -0,0 +1 @@ +#include "PokemonChoice.h" diff --git a/Pokemon/PokemonChoice.h b/Pokemon/PokemonChoice.h new file mode 100644 index 00000000..5e3d29a4 --- /dev/null +++ b/Pokemon/PokemonChoice.h @@ -0,0 +1,7 @@ +// Define an enum for Pokemon choices +enum class PokemonChoice { + CHARMANDER = 1, + BULBASAUR, + SQUIRTLE, + PIKACHU // Default choice +}; \ No newline at end of file diff --git a/Pokemon/PokemonType.cpp b/Pokemon/PokemonType.cpp new file mode 100644 index 00000000..f5bec35f --- /dev/null +++ b/Pokemon/PokemonType.cpp @@ -0,0 +1 @@ +#include "header.h" diff --git a/Pokemon/PokemonType.h b/Pokemon/PokemonType.h new file mode 100644 index 00000000..f50f9252 --- /dev/null +++ b/Pokemon/PokemonType.h @@ -0,0 +1,8 @@ +// Define an enum for Pokemon types +enum class PokemonType { + FIRE, + GRASS, + WATER, + ELECTRIC, + NORMAL // Added for the default constructor +}; diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 704e23b8..32e771f0 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,6 +1,9 @@ +#include"PokemonType.h" +#include"PokemonChoice.h" #include #include // Include this header to use numeric_limits #include + using namespace std; // Function to clear the console @@ -18,23 +21,6 @@ void waitForEnter() { cin.get(); // Wait for Enter key } -// Define an enum for Pokemon choices -enum PokemonChoice { - CHARMANDER = 1, - BULBASAUR, - SQUIRTLE, - PIKACHU // Default choice -}; - -// Define an enum for Pokemon types -enum PokemonType { - FIRE, - GRASS, - WATER, - ELECTRIC, - NORMAL // Added for the default constructor -}; - // Pokemon class definition class Pokemon { public: @@ -285,7 +271,7 @@ void gameLoop(Player& player) { cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; } -int main() { +int main() {s // Create Pokemon and Player objects for the game Pokemon charmander("Charmander", FIRE, 100); // Using parameterized constructor From b075054f166474c79395278379d8f8a366f9a4a9 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Tue, 29 Jul 2025 18:26:43 +0530 Subject: [PATCH 09/25] assignment done --- Pokemon/main.cpp | 105 +++++++++++++++++++------------------------- Pokemon/utility.cpp | 19 ++++++++ Pokemon/utility.h | 9 ++++ 3 files changed, 72 insertions(+), 61 deletions(-) create mode 100644 Pokemon/utility.cpp create mode 100644 Pokemon/utility.h diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 32e771f0..323ccf25 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,26 +1,11 @@ -#include"PokemonType.h" -#include"PokemonChoice.h" +#include "PokemonChoice.h" +#include "PokemonType.h" +#include "utility.h" #include #include // Include this header to use numeric_limits #include - using namespace std; -// Function to clear the console -void clearConsole() { - // Platform-specific clear console command -#ifdef _WIN32 - system("cls"); -#else - (void)system("clear"); -#endif -} - -// Function to wait for user to press Enter -void waitForEnter() { - cin.get(); // Wait for Enter key -} - // Pokemon class definition class Pokemon { public: @@ -31,12 +16,12 @@ class Pokemon { // Default constructor Pokemon() { name = "Unknown"; - type = NORMAL; + type = PokemonType::NORMAL; health = 50; } // Parameterized constructor - Pokemon(std::string p_name, PokemonType p_type, int p_health) { + Pokemon(string p_name, PokemonType p_type, int p_health) { name = p_name; type = p_type; health = p_health; @@ -54,7 +39,7 @@ class Pokemon { // Destructor message removed } - void attack() { std::cout << name << " attacks with a powerful move!\n"; } + void attack() { cout << name << " attacks with a powerful move!\n"; } }; // Player class definition @@ -70,28 +55,28 @@ class Player { } // Parameterized constructor - Player(std::string p_name, Pokemon p_chosenPokemon) { + Player(string p_name, Pokemon p_chosenPokemon) { name = p_name; chosenPokemon = p_chosenPokemon; } void choosePokemon(int choice) { - switch (choice) { - case CHARMANDER: - chosenPokemon = Pokemon("Charmander", FIRE, 100); + switch ((PokemonChoice)choice) { + case PokemonChoice::CHARMANDER: + chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); break; - case BULBASAUR: - chosenPokemon = Pokemon("Bulbasaur", GRASS, 100); + case PokemonChoice::BULBASAUR: + chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); break; - case SQUIRTLE: - chosenPokemon = Pokemon("Squirtle", WATER, 100); + case PokemonChoice::SQUIRTLE: + chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); break; default: - chosenPokemon = Pokemon("Pikachu", ELECTRIC, 100); + chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); break; } cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; - waitForEnter(); // Wait for user to press Enter before proceeding + utility::waitForEnter(); // Wait for user to press Enter before proceeding } }; @@ -105,32 +90,32 @@ class ProfessorOak { void greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; - waitForEnter(); + utility::waitForEnter(); cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; - waitForEnter(); + utility::waitForEnter(); cout << name << ": But enough about me. Let's talk about you!\n"; - waitForEnter(); + utility::waitForEnter(); } void offerPokemonChoices(Player& player) { cout << name << ": First, tell me, what’s your name? \t [Please Enter Your Name]\n"; - getline(std::cin, player.name); + getline(cin, player.name); cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; - waitForEnter(); + utility::waitForEnter(); cout << name << ": You must be eager to start your adventure. But first, " "you’ll need a Pokemon of your own!\n"; - waitForEnter(); + utility::waitForEnter(); // Presenting Pokemon choices cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; - waitForEnter(); + 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"; @@ -143,66 +128,66 @@ class ProfessorOak { cin >> choice; player.choosePokemon(choice); - waitForEnter(); + utility::waitForEnter(); } // New method for the main quest conversation void explainMainQuest(Player& player) { // Clear the console - clearConsole(); + utility::clearConsole(); cout << "Professor Oak: " << player.name << "!, I am about to explain you about your upcoming grand " "adventure.\n"; - waitForEnter(); + 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"; - waitForEnter(); + 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"; - waitForEnter(); + utility::waitForEnter(); cout << "\n" << player.name << ": Wait... that sounds a lot like every other Pokémon game " "out there...\n"; - waitForEnter(); + utility::waitForEnter(); cout << "Professor Oak: Shhh! Don't break the fourth wall, " << player.name << "! This is serious business!\n"; - waitForEnter(); + 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"; - waitForEnter(); + 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"; - waitForEnter(); + utility::waitForEnter(); cout << "\n" << player.name << ": Sounds like a walk in the park... right?\n"; - waitForEnter(); + 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"; - waitForEnter(); + utility::waitForEnter(); cout << "\nProfessor Oak: So, what do you say? Are you ready to " "become the next Pokémon Champion?\n"; - waitForEnter(); + utility::waitForEnter(); cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; - waitForEnter(); + utility::waitForEnter(); cout << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; - waitForEnter(); + 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"; - waitForEnter(); + utility::waitForEnter(); } }; @@ -213,7 +198,7 @@ void gameLoop(Player& player) { while (keepPlaying) { // Clear console before showing options - clearConsole(); + utility::clearConsole(); // Display options to the player cout << "\nWhat would you like to do next, " << player.name << "?\n"; @@ -225,9 +210,7 @@ void gameLoop(Player& player) { cout << "Enter your choice: "; cin >> choice; - // Clear the newline character left in the buffer after cin >> choice - cin.ignore(numeric_limits::max(), '\n'); - + utility::clearInputBuffer(); // Clear the input buffer // Process the player's choice and display the corresponding message switch (choice) { @@ -265,15 +248,15 @@ void gameLoop(Player& player) { // Wait for Enter key before the screen is cleared and the menu is shown // again - waitForEnter(); + utility::waitForEnter(); } cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; } -int main() {s +int main() { // Create Pokemon and Player objects for the game - Pokemon charmander("Charmander", FIRE, + Pokemon charmander("Charmander", PokemonType::FIRE, 100); // Using parameterized constructor // Continue with the main flow of the game @@ -291,4 +274,4 @@ int main() {s gameLoop(player); return 0; -} +} \ No newline at end of file diff --git a/Pokemon/utility.cpp b/Pokemon/utility.cpp new file mode 100644 index 00000000..3ad2a280 --- /dev/null +++ b/Pokemon/utility.cpp @@ -0,0 +1,19 @@ +#include "utility.h" +#include +#include +using namespace std; + +void utility::clearConsole() { +#ifdef _WIN32 + system("cls"); +#else + system("clear"); +#endif +} + +void utility::waitForEnter() { + cin.get(); +} + +void utility::clearInputBuffer(){ +} \ No newline at end of file diff --git a/Pokemon/utility.h b/Pokemon/utility.h new file mode 100644 index 00000000..ca322012 --- /dev/null +++ b/Pokemon/utility.h @@ -0,0 +1,9 @@ +#pragma once +class utility +{ +public : + static void clearConsole(); + static void waitForEnter(); + static void clearInputBuffer(); +}; + From dad1bf509257497115f90a8d43009793e11af98e Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Wed, 30 Jul 2025 23:30:06 +0530 Subject: [PATCH 10/25] Deaking with some errors --- Pokemon/Pokemon.sln | 19 +++++++++++++++++++ Pokemon/Pokemon.vcxproj | 10 ++++++++++ Pokemon/Pokemon.vcxproj.filters | 26 ++++++++++++++++++++++++++ Pokemon/Pokemon.vcxproj.user | 4 ++++ Pokemon/PokemonChoice.cpp | 1 - Pokemon/PokemonType.cpp | 2 +- Pokemon/PokemonType.h | 2 +- Pokemon/main.cpp | 1 + Pokemon/player.cpp | 33 +++++++++++++++++++++++++++++++++ Pokemon/player.h | 17 +++++++++++++++++ 10 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 Pokemon/Pokemon.vcxproj.user create mode 100644 Pokemon/player.cpp create mode 100644 Pokemon/player.h diff --git a/Pokemon/Pokemon.sln b/Pokemon/Pokemon.sln index dea79cff..b117a60a 100644 --- a/Pokemon/Pokemon.sln +++ b/Pokemon/Pokemon.sln @@ -1,7 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36310.24 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Pokemon", "Pokemon.vcxproj", "{872261CB-D6AC-488B-91C5-1B44032596F2}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Header.h", "..\Header.h\Header.h.vcxproj", "{47FEE16B-AAEB-4576-91E7-3C9C5225D963}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -18,5 +23,19 @@ Global {872261CB-D6AC-488B-91C5-1B44032596F2}.Release|Win32.Build.0 = Release|Win32 {872261CB-D6AC-488B-91C5-1B44032596F2}.Release|x64.ActiveCfg = Release|x64 {872261CB-D6AC-488B-91C5-1B44032596F2}.Release|x64.Build.0 = Release|x64 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|Win32.ActiveCfg = Debug|Win32 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|Win32.Build.0 = Debug|Win32 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|x64.ActiveCfg = Debug|x64 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|x64.Build.0 = Debug|x64 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|Win32.ActiveCfg = Release|Win32 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|Win32.Build.0 = Release|Win32 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|x64.ActiveCfg = Release|x64 + {47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AA496C07-30CF-4C3C-ABFF-0573647E3200} EndGlobalSection EndGlobal diff --git a/Pokemon/Pokemon.vcxproj b/Pokemon/Pokemon.vcxproj index 9e6331ef..2f89b0e7 100644 --- a/Pokemon/Pokemon.vcxproj +++ b/Pokemon/Pokemon.vcxproj @@ -154,7 +154,11 @@ + + + + @@ -162,6 +166,12 @@ + + + + + + diff --git a/Pokemon/Pokemon.vcxproj.filters b/Pokemon/Pokemon.vcxproj.filters index 644f8bee..3ffc753b 100644 --- a/Pokemon/Pokemon.vcxproj.filters +++ b/Pokemon/Pokemon.vcxproj.filters @@ -18,5 +18,31 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/Pokemon/Pokemon.vcxproj.user b/Pokemon/Pokemon.vcxproj.user new file mode 100644 index 00000000..88a55094 --- /dev/null +++ b/Pokemon/Pokemon.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Pokemon/PokemonChoice.cpp b/Pokemon/PokemonChoice.cpp index 3a124bf6..e69de29b 100644 --- a/Pokemon/PokemonChoice.cpp +++ b/Pokemon/PokemonChoice.cpp @@ -1 +0,0 @@ -#include "PokemonChoice.h" diff --git a/Pokemon/PokemonType.cpp b/Pokemon/PokemonType.cpp index f5bec35f..8b137891 100644 --- a/Pokemon/PokemonType.cpp +++ b/Pokemon/PokemonType.cpp @@ -1 +1 @@ -#include "header.h" + diff --git a/Pokemon/PokemonType.h b/Pokemon/PokemonType.h index f50f9252..3806a62b 100644 --- a/Pokemon/PokemonType.h +++ b/Pokemon/PokemonType.h @@ -5,4 +5,4 @@ enum class PokemonType { WATER, ELECTRIC, NORMAL // Added for the default constructor -}; +}; \ No newline at end of file diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 323ccf25..c56f4c12 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,6 +1,7 @@ #include "PokemonChoice.h" #include "PokemonType.h" #include "utility.h" +#include "player.h" #include #include // Include this header to use numeric_limits #include diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp new file mode 100644 index 00000000..cfaaadf7 --- /dev/null +++ b/Pokemon/player.cpp @@ -0,0 +1,33 @@ +#include "player.h" +#include + +// Default constructor +player::player() { + name = "Trainer"; + chosenPokemon = Pokemon(); // Using the default Pokemon constructor +} + +// Parameterized constructor +player::player(string p_name, Pokemon p_chosenPokemon) { + 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(); // Wait for user to press Enter before proceeding +} \ No newline at end of file diff --git a/Pokemon/player.h b/Pokemon/player.h new file mode 100644 index 00000000..98562a80 --- /dev/null +++ b/Pokemon/player.h @@ -0,0 +1,17 @@ +#include +#include"PokemonChoice.h" +#include"PokemonType.h" +#include"utility.h" +using namespace std; +class player +{ +public: + string name; + Pokemon chosenPokemon; + + player();//default constructor + player(string p_name, Pokemon p_chosenPokemon);//Parameterized constructor + + void choosePokemon(int choice);//Method to choose pokemon +}; + From 04b7834da0925603817d9e66c5f7f967649532ee Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 00:26:38 +0530 Subject: [PATCH 11/25] facing errors in player.h and .cpp file --- Pokemon/main.cpp | 39 +-------------------------------------- Pokemon/player.cpp | 13 +++++++------ Pokemon/player.h | 26 +++++++++++++------------- 3 files changed, 21 insertions(+), 57 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index c56f4c12..8b21ed08 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,7 +1,6 @@ #include "PokemonChoice.h" #include "PokemonType.h" #include "utility.h" -#include "player.h" #include #include // Include this header to use numeric_limits #include @@ -43,43 +42,7 @@ class Pokemon { void attack() { cout << name << " attacks with a powerful move!\n"; } }; -// Player class definition -class Player { -public: - string name; - Pokemon chosenPokemon; - - // Default constructor - Player() { - name = "Trainer"; - chosenPokemon = Pokemon(); // Using the default Pokemon constructor - } - - // Parameterized constructor - Player(string p_name, Pokemon p_chosenPokemon) { - name = p_name; - chosenPokemon = p_chosenPokemon; - } - - 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"; - utility::waitForEnter(); // Wait for user to press Enter before proceeding - } -}; +#include "player.h" // ProfessorOak class definition class ProfessorOak { diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp index cfaaadf7..3da5011b 100644 --- a/Pokemon/player.cpp +++ b/Pokemon/player.cpp @@ -1,19 +1,19 @@ +// Player.cpp #include "player.h" -#include +#include "iostream" +using namespace std; -// Default constructor -player::player() { +Player::Player() { name = "Trainer"; chosenPokemon = Pokemon(); // Using the default Pokemon constructor } -// Parameterized constructor -player::player(string p_name, Pokemon p_chosenPokemon) { +Player::Player(string p_name, Pokemon p_chosenPokemon) { name = p_name; chosenPokemon = p_chosenPokemon; } -void player::choosePokemon(int choice) { +void Player::choosePokemon(int choice) { switch ((PokemonChoice)choice) { case PokemonChoice::CHARMANDER: chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); @@ -25,6 +25,7 @@ void player::choosePokemon(int choice) { chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); break; default: + chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); break; } diff --git a/Pokemon/player.h b/Pokemon/player.h index 98562a80..afb1568c 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,17 +1,17 @@ -#include -#include"PokemonChoice.h" -#include"PokemonType.h" -#include"utility.h" +// Player.h +#include +#include "PokemonType.h" +#include "PokemonChoice.h" +#include "utility.h" using namespace std; -class player -{ -public: - string name; - Pokemon chosenPokemon; - player();//default constructor - player(string p_name, Pokemon p_chosenPokemon);//Parameterized constructor +class Player { +public: + string name; + Pokemon chosenPokemon; - void choosePokemon(int choice);//Method to choose pokemon -}; + Player(); // Default constructor + Player(string p_name, Pokemon p_chosenPokemon); // Parameterized constructor + void choosePokemon(int choice); // Method to choose a Pokemon +}; \ No newline at end of file From 563d1aa1b955a62836622f187f0a7220f789fe80 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 01:08:32 +0530 Subject: [PATCH 12/25] #included --- Pokemon/player.cpp | 3 +++ Pokemon/player.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp index 3da5011b..359662aa 100644 --- a/Pokemon/player.cpp +++ b/Pokemon/player.cpp @@ -1,5 +1,8 @@ // Player.cpp #include "player.h" +#include "PokemonChoice.h" +#include "PokemonType.h" +#include "utility.h" #include "iostream" using namespace std; diff --git a/Pokemon/player.h b/Pokemon/player.h index afb1568c..7b7b7d57 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,8 +1,5 @@ // Player.h #include -#include "PokemonType.h" -#include "PokemonChoice.h" -#include "utility.h" using namespace std; class Player { From 3d8fd92ff8723eb9903a01e337acf460cf673e41 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 02:17:57 +0530 Subject: [PATCH 13/25] Good going --- Pokemon/Pokemon.cpp | 19 +++++++++++++++++++ Pokemon/Pokemon.h | 24 ++++++++++++++++++++++++ Pokemon/main.cpp | 4 ++-- Pokemon/player.h | 1 + 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 Pokemon/Pokemon.cpp create mode 100644 Pokemon/Pokemon.h diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp new file mode 100644 index 00000000..3b2c1b6a --- /dev/null +++ b/Pokemon/Pokemon.cpp @@ -0,0 +1,19 @@ +#include "Pokemon.h" +#include + +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 message removed +} + +void Pokemon::attack() { cout << name << " attacks with a powerful move!\n"; } \ No newline at end of file diff --git a/Pokemon/Pokemon.h b/Pokemon/Pokemon.h new file mode 100644 index 00000000..03e8fef3 --- /dev/null +++ b/Pokemon/Pokemon.h @@ -0,0 +1,24 @@ +#include +#include "PokemonType.h" +using namespace std; + +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/Pokemon/main.cpp b/Pokemon/main.cpp index 8b21ed08..6d2192c4 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -6,7 +6,7 @@ #include using namespace std; -// Pokemon class definition +/*/ Pokemon class definition class Pokemon { public: string name; @@ -40,7 +40,7 @@ class Pokemon { } void attack() { cout << name << " attacks with a powerful move!\n"; } -}; +};*/ #include "player.h" diff --git a/Pokemon/player.h b/Pokemon/player.h index 7b7b7d57..25fa68f2 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,5 +1,6 @@ // Player.h #include +#include "Pokemon.h" using namespace std; class Player { From 5c143c9fbbd83667a1fd0dc07901c63ff8fe230b Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 02:52:57 +0530 Subject: [PATCH 14/25] Can't understand the error,need help --- Pokemon/Pokemon.cpp | 1 + Pokemon/Pokemon.h | 3 ++- Pokemon/main.cpp | 45 +++++---------------------------------------- Pokemon/player.cpp | 1 + Pokemon/player.h | 3 ++- 5 files changed, 11 insertions(+), 42 deletions(-) diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp index 3b2c1b6a..ba7e8b34 100644 --- a/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon.cpp @@ -1,5 +1,6 @@ #include "Pokemon.h" #include +#include"PokemonType.h" Pokemon::Pokemon():name("unknown"),type(PokemonType::NORMAL),health(50){} // Parameterized constructor diff --git a/Pokemon/Pokemon.h b/Pokemon/Pokemon.h index 03e8fef3..f7f8a549 100644 --- a/Pokemon/Pokemon.h +++ b/Pokemon/Pokemon.h @@ -1,7 +1,8 @@ #include -#include "PokemonType.h" using namespace std; +enum class PokemonType; + class Pokemon { public: string name; diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 6d2192c4..eea74a8d 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,49 +1,14 @@ +class Player; +class Pokemon; +enum PokemonType; #include "PokemonChoice.h" -#include "PokemonType.h" -#include "utility.h" + +#include "Utility.h" #include #include // Include this header to use numeric_limits #include using namespace std; -/*/ Pokemon class definition -class Pokemon { -public: - string name; - PokemonType type; - int health; - - // Default constructor - 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; - } - - // Copy constructor - Pokemon(const Pokemon& other) { - name = other.name; - type = other.type; - health = other.health; - } - - // Destructor - ~Pokemon() { - // Destructor message removed - } - - void attack() { cout << name << " attacks with a powerful move!\n"; } -};*/ - -#include "player.h" - // ProfessorOak class definition class ProfessorOak { public: diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp index 359662aa..4b7c8cdb 100644 --- a/Pokemon/player.cpp +++ b/Pokemon/player.cpp @@ -2,6 +2,7 @@ #include "player.h" #include "PokemonChoice.h" #include "PokemonType.h" +#include "Pokemon.h" #include "utility.h" #include "iostream" using namespace std; diff --git a/Pokemon/player.h b/Pokemon/player.h index 25fa68f2..6a2beb0b 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,8 +1,9 @@ // Player.h #include -#include "Pokemon.h" using namespace std; +class Pokemon; + class Player { public: string name; From 3620d014fb89032e876d9a606ef0b8a4224f9781 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 31 Jul 2025 03:11:12 +0530 Subject: [PATCH 15/25] greetings --- Pokemon/main.cpp | 6 ++---- Pokemon/player.h | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index eea74a8d..d5349b7f 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,13 +1,11 @@ -class Player; -class Pokemon; -enum PokemonType; #include "PokemonChoice.h" - +#include "PokemonType.h" #include "Utility.h" #include #include // Include this header to use numeric_limits #include using namespace std; +#include "player.h" // ProfessorOak class definition class ProfessorOak { diff --git a/Pokemon/player.h b/Pokemon/player.h index 6a2beb0b..eb38a581 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -1,9 +1,7 @@ // Player.h #include +#include "Pokemon.h" using namespace std; - -class Pokemon; - class Player { public: string name; From d2a4cbf4da058c0476e7fda8bd1faa6ff3e02597 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Fri, 1 Aug 2025 18:08:28 +0530 Subject: [PATCH 16/25] We did it misty! --- Pokemon/Game.cpp | 70 +++++++++++++++++ Pokemon/Game.h | 9 +++ Pokemon/Grass.cpp | 14 ++++ Pokemon/Grass.h | 12 +++ Pokemon/main.cpp | 191 ++-------------------------------------------- 5 files changed, 112 insertions(+), 184 deletions(-) create mode 100644 Pokemon/Game.cpp create mode 100644 Pokemon/Game.h create mode 100644 Pokemon/Grass.cpp create mode 100644 Pokemon/Grass.h diff --git a/Pokemon/Game.cpp b/Pokemon/Game.cpp new file mode 100644 index 00000000..75afc5f8 --- /dev/null +++ b/Pokemon/Game.cpp @@ -0,0 +1,70 @@ +#include "Game.h" +#include "player.h" +#include "utility.h" + +Game::Game() { +} + +// Function to handle the main game loop +void Game::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: + cout << "That's not a valid choice. Try again!\n"; + break; + } + + // Wait for Enter key before the screen is cleared and the menu is shown + // again + utility::waitForEnter(); + } + + cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; +} + diff --git a/Pokemon/Game.h b/Pokemon/Game.h new file mode 100644 index 00000000..7189ee48 --- /dev/null +++ b/Pokemon/Game.h @@ -0,0 +1,9 @@ +#include +class Game +{ +public: + Game(); + // Function to handle the main game loop + void gameLoop(Player& player); +}; + diff --git a/Pokemon/Grass.cpp b/Pokemon/Grass.cpp new file mode 100644 index 00000000..4ddd09f0 --- /dev/null +++ b/Pokemon/Grass.cpp @@ -0,0 +1,14 @@ +#include "Grass.h" +#include"Pokemon.h" + +Grass forestGrass = { + "Forest", + {{"Pidgey", PokemonType::NORMAL, 40}, {"Caterpie", PokemonType::BUG, 35}}, + 70 +}; + +Grass caveGrass = { + "Cave", + {{"Zubat", PokemonType::POISON, 30}, {"Geodude", PokemonType::ROCK, 50}}, + 80 +}; \ No newline at end of file diff --git a/Pokemon/Grass.h b/Pokemon/Grass.h new file mode 100644 index 00000000..3c0c5c93 --- /dev/null +++ b/Pokemon/Grass.h @@ -0,0 +1,12 @@ +#include +#include +#include"Pokemon.h" +using namespace std; + +struct Grass{ + string environmentType; // Example: "Forest", "Cave", "Riverbank" + vector wildPokemonlist; // List of wild Pokémon that live in this grass + int encounterRate; // Likelihood of encountering a wild Pokémon, out of 100 + +}; + diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index d5349b7f..88776d2a 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,194 +1,16 @@ -#include "PokemonChoice.h" -#include "PokemonType.h" -#include "Utility.h" +#include"Game.h" +#include"player.h" +#include"ProfessorOak.h" #include #include // Include this header to use numeric_limits #include using namespace std; -#include "player.h" - -// ProfessorOak class definition -class ProfessorOak { -public: - string name; - - // Parameterized constructor - ProfessorOak(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(); - } -}; - -// 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: - cout << "That's not a valid choice. Try again!\n"; - break; - } - - // Wait for Enter key before the screen is cleared and the menu is shown - // again - utility::waitForEnter(); - } - - cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; -} int main() { - // Create Pokemon and Player objects for the game - Pokemon charmander("Charmander", PokemonType::FIRE, - 100); // Using parameterized constructor - + // Continue with the main flow of the game ProfessorOak professor("Professor Oak"); - Player player("Ash", charmander); + Player player; // Greet the player and offer Pokemon choices professor.greetPlayer(player); @@ -198,7 +20,8 @@ int main() { professor.explainMainQuest(player); // Start the main game loop - gameLoop(player); + Game game; + game.gameLoop(player); return 0; } \ No newline at end of file From dd4052683b8b7a22b75ca32843a1392c5ae62bbf Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Sat, 2 Aug 2025 01:52:32 +0530 Subject: [PATCH 17/25] identifier "WildPokemon" is undefined --- Pokemon/Game.cpp | 58 ++++++++++++++++++++------------ Pokemon/Game.h | 18 +++++----- Pokemon/Grass.cpp | 2 +- Pokemon/Grass.h | 2 +- Pokemon/WildEncounterManager.cpp | 12 +++++++ Pokemon/WildEncounterManager.h | 8 +++++ Pokemon/utility.cpp | 7 ++-- Pokemon/utility.h | 5 ++- 8 files changed, 75 insertions(+), 37 deletions(-) create mode 100644 Pokemon/WildEncounterManager.cpp create mode 100644 Pokemon/WildEncounterManager.h diff --git a/Pokemon/Game.cpp b/Pokemon/Game.cpp index 75afc5f8..48391b53 100644 --- a/Pokemon/Game.cpp +++ b/Pokemon/Game.cpp @@ -1,18 +1,28 @@ #include "Game.h" -#include "player.h" +#include "Player.h" +#include "PokemonType.h" #include "utility.h" +#include "WildEncounterManager.h" +#include +using namespace std; Game::Game() { + // Create a sample grass environment with actual Pokemon objects + forestGrass = { "Forest", + {Pokemon("Pidgey", PokemonType::NORMAL, 40), + Pokemon("Caterpie", PokemonType::BUG, 35), + Pokemon("Zubat", PokemonType::POISON, 30)}, + 70 }; } -// Function to handle the main game loop void Game::gameLoop(Player& player) { + int choice; bool keepPlaying = true; while (keepPlaying) { // Clear console before showing options - utility::clearConsole(); + Utility::clearConsole(); // Display options to the player cout << "\nWhat would you like to do next, " << player.name << "?\n"; @@ -24,30 +34,35 @@ void Game::gameLoop(Player& player) { cout << "Enter your choice: "; cin >> choice; - utility::clearInputBuffer(); // Clear the input buffer + 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"; + case 1: { + // Create a scope within case 1 + WildEncounterManager encounterManager; + Pokemon encounteredPokemon = encounterManager.getRandomPokemonFromGrass(forestGrass); + cout << "A wild " << encounteredPokemon.name << " appeared!\n"; break; - case 2: - cout - << "You head to the PokeCenter, but Nurse Joy is out on a coffee " + } + 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"; + } + 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: + } + 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"; + } + 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; @@ -55,16 +70,17 @@ void Game::gameLoop(Player& player) { keepPlaying = false; } break; - default: + } + default: { cout << "That's not a valid choice. Try again!\n"; break; } + } // Wait for Enter key before the screen is cleared and the menu is shown // again - utility::waitForEnter(); + Utility::waitForEnter(); } cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; -} - +} \ No newline at end of file diff --git a/Pokemon/Game.h b/Pokemon/Game.h index 7189ee48..e5d3602a 100644 --- a/Pokemon/Game.h +++ b/Pokemon/Game.h @@ -1,9 +1,11 @@ -#include -class Game -{ -public: - Game(); - // Function to handle the main game loop - void gameLoop(Player& player); -}; +#include "Grass.h" + +class Player; +class Game { +private: + Grass forestGrass; +public: + Game(); + void gameLoop(Player& player); +}; \ No newline at end of file diff --git a/Pokemon/Grass.cpp b/Pokemon/Grass.cpp index 4ddd09f0..7378afdd 100644 --- a/Pokemon/Grass.cpp +++ b/Pokemon/Grass.cpp @@ -1,5 +1,5 @@ #include "Grass.h" -#include"Pokemon.h" +#include"PokemonType.h" Grass forestGrass = { "Forest", diff --git a/Pokemon/Grass.h b/Pokemon/Grass.h index 3c0c5c93..0c0c9516 100644 --- a/Pokemon/Grass.h +++ b/Pokemon/Grass.h @@ -5,7 +5,7 @@ using namespace std; struct Grass{ string environmentType; // Example: "Forest", "Cave", "Riverbank" - vector wildPokemonlist; // List of wild Pokémon that live in this grass + vector wildPokemonList; // List of wild Pokémon that live in this grass int encounterRate; // Likelihood of encountering a wild Pokémon, out of 100 }; diff --git a/Pokemon/WildEncounterManager.cpp b/Pokemon/WildEncounterManager.cpp new file mode 100644 index 00000000..63bd053e --- /dev/null +++ b/Pokemon/WildEncounterManager.cpp @@ -0,0 +1,12 @@ +#include "WildEncounterManager.h" +#include // For rand() +#include // For time() + +WildEncounterManager::WildEncounterManager() { + srand(time(0)); // Seed the random number generator +} + +WildPokemon WildEncounterManager::getRandomPokemonFromGrass(const Grass& grass) { + int randomIndex = rand() % grass.wildPokemonList.size(); + return grass.wildPokemonList[randomIndex]; +} \ No newline at end of file diff --git a/Pokemon/WildEncounterManager.h b/Pokemon/WildEncounterManager.h new file mode 100644 index 00000000..7ff1d749 --- /dev/null +++ b/Pokemon/WildEncounterManager.h @@ -0,0 +1,8 @@ +#include +#include "Grass.h" // Assuming the Grass struct is defined here + +class WildEncounterManager { +public: + WildPokemon getRandomPokemonFromGrass(const Grass& grass + ); +}; diff --git a/Pokemon/utility.cpp b/Pokemon/utility.cpp index 3ad2a280..eab18a0c 100644 --- a/Pokemon/utility.cpp +++ b/Pokemon/utility.cpp @@ -3,7 +3,7 @@ #include using namespace std; -void utility::clearConsole() { +void Utility::clearConsole() { #ifdef _WIN32 system("cls"); #else @@ -11,9 +11,10 @@ void utility::clearConsole() { #endif } -void utility::waitForEnter() { +void Utility::waitForEnter() { cin.get(); } -void utility::clearInputBuffer(){ +void Utility::clearInputBuffer(){ + cin.ignore(numeric_limits::max(), '\n'); } \ No newline at end of file diff --git a/Pokemon/utility.h b/Pokemon/utility.h index ca322012..b8849d92 100644 --- a/Pokemon/utility.h +++ b/Pokemon/utility.h @@ -1,6 +1,5 @@ -#pragma once -class utility -{ +#include +class Utility{ public : static void clearConsole(); static void waitForEnter(); From 5cdff4a446440662ef739c83a0a3ae986ee149fc Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Sat, 2 Aug 2025 01:53:56 +0530 Subject: [PATCH 18/25] identifier "WildPokemon" is undefined --- Pokemon/PokemonType.h | 5 +- Pokemon/ProfessorOak.cpp | 109 +++++++++++++++++++++++++++++++++++++++ Pokemon/ProfessorOak.h | 18 +++++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 Pokemon/ProfessorOak.cpp create mode 100644 Pokemon/ProfessorOak.h diff --git a/Pokemon/PokemonType.h b/Pokemon/PokemonType.h index 3806a62b..7ee5187a 100644 --- a/Pokemon/PokemonType.h +++ b/Pokemon/PokemonType.h @@ -4,5 +4,8 @@ enum class PokemonType { GRASS, WATER, ELECTRIC, - NORMAL // Added for the default constructor + NORMAL, + BUG, + POISON, + ROCK // Added for the default constructor }; \ No newline at end of file diff --git a/Pokemon/ProfessorOak.cpp b/Pokemon/ProfessorOak.cpp new file mode 100644 index 00000000..e710cc68 --- /dev/null +++ b/Pokemon/ProfessorOak.cpp @@ -0,0 +1,109 @@ +#include "ProfessorOak.h" +#include"utility.h" +#include "player.h" +#include + +// Parameterized constructor +ProfessorOak::ProfessorOak(string p_name) { name = p_name; } + +void ProfessorOak::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 ProfessorOak::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 ProfessorOak::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(); +} diff --git a/Pokemon/ProfessorOak.h b/Pokemon/ProfessorOak.h new file mode 100644 index 00000000..0b911a4e --- /dev/null +++ b/Pokemon/ProfessorOak.h @@ -0,0 +1,18 @@ +#include +using namespace std; + +// ProfessorOak class definition +class ProfessorOak { +public: + string name; + + // Parameterized constructor + ProfessorOak(string p_name); + + void greetPlayer(Player& player); + + void offerPokemonChoices(Player& player); + + // New method for the main quest conversation + void explainMainQuest(Player& player); +}; \ No newline at end of file From c045e167b0c1ceb5e4e79883d4533bfc83426303 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Sat, 2 Aug 2025 21:20:30 +0530 Subject: [PATCH 19/25] Ready for battle! --- Pokemon/BattleManager.cpp | 24 ++++++++++++++++++++++++ Pokemon/BattleManager.h | 5 +++++ Pokemon/Pokemon.cpp | 16 +++++++++++++++- Pokemon/Pokemon.h | 7 ++++++- Pokemon/WildEncounterManager.cpp | 3 ++- Pokemon/WildEncounterManager.h | 2 +- 6 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 Pokemon/BattleManager.cpp create mode 100644 Pokemon/BattleManager.h diff --git a/Pokemon/BattleManager.cpp b/Pokemon/BattleManager.cpp new file mode 100644 index 00000000..6e1e00a0 --- /dev/null +++ b/Pokemon/BattleManager.cpp @@ -0,0 +1,24 @@ +#include "BattleManager.h" +#include +#include "Pokemon.h" +#include "PokemonType.h" +using namespace std; + +void Battle(Pokemon& playerPokemon, Pokemon& wildPokemon) { + cout << "A wild " << wildPokemon.name << " appeared!\\n"; + + while (!playerPokemon.isFainted() && !wildPokemon.isFainted()) { + playerPokemon.attack(wildPokemon); // Player attacks first + + if (!wildPokemon.isFainted()) { + wildPokemon.attack(playerPokemon); // Wild Pokémon attacks back + } + } + + if (playerPokemon.isFainted()) { + cout << playerPokemon.name << " has fainted! You lose the battle.\\n"; + } + else { + cout << "You defeated the wild " << wildPokemon.name << "!\\n"; + } +} \ No newline at end of file diff --git a/Pokemon/BattleManager.h b/Pokemon/BattleManager.h new file mode 100644 index 00000000..1b6070df --- /dev/null +++ b/Pokemon/BattleManager.h @@ -0,0 +1,5 @@ +#include "Pokemon.h" +#include "PokemonType.h" + + +void Battle(Pokemon& playerPokemon, Pokemon& wildPokemon); \ No newline at end of file diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp index ba7e8b34..0e9f151d 100644 --- a/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon.cpp @@ -17,4 +17,18 @@ Pokemon::~Pokemon() { // Destructor message removed } -void Pokemon::attack() { cout << name << " attacks with a powerful move!\n"; } \ No newline at end of file +void Pokemon::attack(Pokemon& target) { + int damage = 10; // Example damage value, could be based on type or other factors + target.TakeDamage(damage); // Example damage value + cout << name << " attacks " << target.name << " for " << damage << " damage!\\n"; +} +void Pokemon::TakeDamage(int Damage) { + health -= Damage;// Reduce health by the damage taken + + if (health < 0) { + health = 0; // Ensure health doesn't go below 0 + } +} +bool Pokemon::isFainted() const { + return health <= 0; // Check if health is 0 or less +} \ No newline at end of file diff --git a/Pokemon/Pokemon.h b/Pokemon/Pokemon.h index f7f8a549..786a7181 100644 --- a/Pokemon/Pokemon.h +++ b/Pokemon/Pokemon.h @@ -8,6 +8,7 @@ class Pokemon { string name; PokemonType type; int health; + int maxHealth; // Default constructor Pokemon(); @@ -21,5 +22,9 @@ class Pokemon { // Destructor ~Pokemon(); - void attack(); + void attack(Pokemon & target); + + void TakeDamage(int damage); + + bool isFainted() const; }; \ No newline at end of file diff --git a/Pokemon/WildEncounterManager.cpp b/Pokemon/WildEncounterManager.cpp index 63bd053e..a9f116c8 100644 --- a/Pokemon/WildEncounterManager.cpp +++ b/Pokemon/WildEncounterManager.cpp @@ -2,11 +2,12 @@ #include // For rand() #include // For time() + WildEncounterManager::WildEncounterManager() { srand(time(0)); // Seed the random number generator } -WildPokemon WildEncounterManager::getRandomPokemonFromGrass(const Grass& grass) { +Pokemon WildEncounterManager::getRandomPokemonFromGrass(const Grass& grass) { int randomIndex = rand() % grass.wildPokemonList.size(); return grass.wildPokemonList[randomIndex]; } \ No newline at end of file diff --git a/Pokemon/WildEncounterManager.h b/Pokemon/WildEncounterManager.h index 7ff1d749..534cc6aa 100644 --- a/Pokemon/WildEncounterManager.h +++ b/Pokemon/WildEncounterManager.h @@ -3,6 +3,6 @@ class WildEncounterManager { public: - WildPokemon getRandomPokemonFromGrass(const Grass& grass + Pokemon getRandomPokemonFromGrass(const Grass& grass ); }; From 89ea3d4e9a081c60dd1413c50ad6f127ba5fa43a Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Sat, 2 Aug 2025 22:17:12 +0530 Subject: [PATCH 20/25] Healing battle --- Pokemon/Game.cpp | 5 +++-- Pokemon/Pokemon.cpp | 7 ++++++- Pokemon/Pokemon.h | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Pokemon/Game.cpp b/Pokemon/Game.cpp index 48391b53..f71f1ff2 100644 --- a/Pokemon/Game.cpp +++ b/Pokemon/Game.cpp @@ -46,8 +46,9 @@ void Game::gameLoop(Player& player) { 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"; + cout << "You head to the PokeCenter.\\n"; + player.chosenPokemon.heal(); + cout << player.chosenPokemon.name << " has been healed to full health!\n"; break; } case 3: { diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp index 0e9f151d..f5f4b5d8 100644 --- a/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon.cpp @@ -18,7 +18,7 @@ Pokemon::~Pokemon() { } void Pokemon::attack(Pokemon& target) { - int damage = 10; // Example damage value, could be based on type or other factors + int damage = attackPower; // Example damage value, could be based on type or other factors target.TakeDamage(damage); // Example damage value cout << name << " attacks " << target.name << " for " << damage << " damage!\\n"; } @@ -31,4 +31,9 @@ void Pokemon::TakeDamage(int Damage) { } bool Pokemon::isFainted() const { return health <= 0; // Check if health is 0 or less +} + +int Pokemon::heal() { + int healAmount = maxHealth; // Example heal amount + return health; // Return the new health value } \ No newline at end of file diff --git a/Pokemon/Pokemon.h b/Pokemon/Pokemon.h index 786a7181..7271f11c 100644 --- a/Pokemon/Pokemon.h +++ b/Pokemon/Pokemon.h @@ -9,6 +9,7 @@ class Pokemon { PokemonType type; int health; int maxHealth; + int attackPower; // Default constructor Pokemon(); @@ -27,4 +28,6 @@ class Pokemon { void TakeDamage(int damage); bool isFainted() const; + + int heal(); }; \ No newline at end of file From bea99f112c26d15e5ac059b20596216cd8bc436c Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Sun, 3 Aug 2025 00:32:52 +0530 Subject: [PATCH 21/25] Ready for Battle! --- Pokemon/BattleManager.cpp | 24 +++++++++++++++++++++--- Pokemon/BattleManager.h | 12 +++++++++--- Pokemon/Game.cpp | 6 ++++-- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Pokemon/BattleManager.cpp b/Pokemon/BattleManager.cpp index 6e1e00a0..ea406946 100644 --- a/Pokemon/BattleManager.cpp +++ b/Pokemon/BattleManager.cpp @@ -2,23 +2,41 @@ #include #include "Pokemon.h" #include "PokemonType.h" +#include "utility.h" using namespace std; -void Battle(Pokemon& playerPokemon, Pokemon& wildPokemon) { - cout << "A wild " << wildPokemon.name << " appeared!\\n"; +void BattleManager::startBattle(Player& player, Pokemon& wildPokemon) { + cout<<"A wild "<< wildPokemon.name << " appeared!\n"; + // Start the battle with the player's chosen Pokémon + Battle(player.chosenPokemon, wildPokemon); +} +void BattleManager::Battle(Pokemon& playerPokemon, Pokemon& wildPokemon) { while (!playerPokemon.isFainted() && !wildPokemon.isFainted()) { playerPokemon.attack(wildPokemon); // Player attacks first if (!wildPokemon.isFainted()) { wildPokemon.attack(playerPokemon); // Wild Pokémon attacks back } + //Pause to show battle progress + Utility::waitForEnter(); } - if (playerPokemon.isFainted()) { + /*if (playerPokemon.isFainted()) { cout << playerPokemon.name << " has fainted! You lose the battle.\\n"; } else { cout << "You defeated the wild " << wildPokemon.name << "!\\n"; + }*/ +} + +void BattleManager::handleBattleOutcome(Player& player, bool playerWon) { + if (playerWon) { + std::cout << player.chosenPokemon.name << " is victorious! Keep an eye on your Pokémon's health.\n"; + } + else { + std::cout << "Oh no! " << player.chosenPokemon.name << " fainted! You need to visit the PokeCenter.\n"; + Utility::waitForEnter(); + std::cout << "Game Over.\n"; } } \ No newline at end of file diff --git a/Pokemon/BattleManager.h b/Pokemon/BattleManager.h index 1b6070df..48c472cc 100644 --- a/Pokemon/BattleManager.h +++ b/Pokemon/BattleManager.h @@ -1,5 +1,11 @@ #include "Pokemon.h" -#include "PokemonType.h" +#include "Player.h" - -void Battle(Pokemon& playerPokemon, Pokemon& wildPokemon); \ No newline at end of file +class BattleManager { +public: + // Function to handle the battle between player's Pokémon and wild Pokémon + void startBattle(Player& player, Pokemon& wildPokemon); +private: + void Battle(Pokemon& playerPokemon, Pokemon& wildPokemon); + void handleBattleOutcome(Player& player, bool playerWon); +}; \ No newline at end of file diff --git a/Pokemon/Game.cpp b/Pokemon/Game.cpp index f71f1ff2..859fa8c0 100644 --- a/Pokemon/Game.cpp +++ b/Pokemon/Game.cpp @@ -4,6 +4,7 @@ #include "utility.h" #include "WildEncounterManager.h" #include +#include"BattleManager.h" using namespace std; Game::Game() { @@ -17,6 +18,7 @@ Game::Game() { void Game::gameLoop(Player& player) { + BattleManager BattleManager; int choice; bool keepPlaying = true; @@ -41,8 +43,8 @@ void Game::gameLoop(Player& player) { case 1: { // Create a scope within case 1 WildEncounterManager encounterManager; - Pokemon encounteredPokemon = encounterManager.getRandomPokemonFromGrass(forestGrass); - cout << "A wild " << encounteredPokemon.name << " appeared!\n"; + Pokemon wildPokemon = encounterManager.getRandomPokemonFromGrass(forestGrass); + BattleManager.startBattle(player,wildPokemon);; break; } case 2: { From a44ff8d0d8b557db311e180f2eeceebf57df8789 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Sun, 3 Aug 2025 01:47:14 +0530 Subject: [PATCH 22/25] * --- Pokemon/BattleManager.cpp | 56 +++++++++++++++++++++++++-------------- Pokemon/BattleManager.h | 11 +++++--- Pokemon/BattleState.cpp | 1 + Pokemon/BattleState.h | 8 ++++++ 4 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 Pokemon/BattleState.cpp create mode 100644 Pokemon/BattleState.h diff --git a/Pokemon/BattleManager.cpp b/Pokemon/BattleManager.cpp index ea406946..f63a71e6 100644 --- a/Pokemon/BattleManager.cpp +++ b/Pokemon/BattleManager.cpp @@ -3,40 +3,56 @@ #include "Pokemon.h" #include "PokemonType.h" #include "utility.h" +#include "BattleState.h" using namespace std; void BattleManager::startBattle(Player& player, Pokemon& wildPokemon) { - cout<<"A wild "<< wildPokemon.name << " appeared!\n"; - // Start the battle with the player's chosen Pokémon - Battle(player.chosenPokemon, wildPokemon); + battleState.playerPokemon = &player.chosenPokemon; + battleState.wildPokemon = &wildPokemon; + battleState.playerTurn = true; // Player starts first + battleState.battleOngoing = true; + std::cout << "A wild " << wildPokemon.name << " appeared!\\n"; + battle(); } -void BattleManager::Battle(Pokemon& playerPokemon, Pokemon& wildPokemon) { - while (!playerPokemon.isFainted() && !wildPokemon.isFainted()) { - playerPokemon.attack(wildPokemon); // Player attacks first - if (!wildPokemon.isFainted()) { - wildPokemon.attack(playerPokemon); // Wild Pokémon attacks back +void BattleManager::battle() { + while (battleState.battleOngoing) { + if (battleState.playerTurn) { + // Player's turn to attack + battleState.playerPokemon->attack(*battleState.wildPokemon); } - //Pause to show battle progress + else { + // Wild Pokémon's turn to attack + battleState.wildPokemon->attack(*battleState.playerPokemon); + } + + // Update the battle state after the turn + updateBattleState(); + + // Switch turns + battleState.playerTurn = !battleState.playerTurn; + Utility::waitForEnter(); } - /*if (playerPokemon.isFainted()) { - cout << playerPokemon.name << " has fainted! You lose the battle.\\n"; + handleBattleOutcome(); +} + +void BattleManager::updateBattleState() { + if (battleState.playerPokemon->isFainted()) { + battleState.battleOngoing = false; + } + else if (battleState.wildPokemon->isFainted()) { + battleState.battleOngoing = false; } - else { - cout << "You defeated the wild " << wildPokemon.name << "!\\n"; - }*/ } -void BattleManager::handleBattleOutcome(Player& player, bool playerWon) { - if (playerWon) { - std::cout << player.chosenPokemon.name << " is victorious! Keep an eye on your Pokémon's health.\n"; +void BattleManager::handleBattleOutcome() { + if (battleState.playerPokemon->isFainted()) { + std::cout << battleState.playerPokemon->name << " has fainted! You lose the battle.\\n"; } else { - std::cout << "Oh no! " << player.chosenPokemon.name << " fainted! You need to visit the PokeCenter.\n"; - Utility::waitForEnter(); - std::cout << "Game Over.\n"; + std::cout << "You defeated the wild " << battleState.wildPokemon->name << "!\\n"; } } \ No newline at end of file diff --git a/Pokemon/BattleManager.h b/Pokemon/BattleManager.h index 48c472cc..19f99270 100644 --- a/Pokemon/BattleManager.h +++ b/Pokemon/BattleManager.h @@ -1,11 +1,14 @@ #include "Pokemon.h" #include "Player.h" +#include"BattleState.h" class BattleManager { public: - // Function to handle the battle between player's Pokémon and wild Pokémon - void startBattle(Player& player, Pokemon& wildPokemon); + void startBattle(Player& player, Pokemon& wildPokemon); private: - void Battle(Pokemon& playerPokemon, Pokemon& wildPokemon); - void handleBattleOutcome(Player& player, bool playerWon); + BattleState battleState; // New BattleState object to track the battle + + void battle(); + void handleBattleOutcome(); + void updateBattleState(); // Method to update the battle state after each turn }; \ No newline at end of file diff --git a/Pokemon/BattleState.cpp b/Pokemon/BattleState.cpp new file mode 100644 index 00000000..d4dde2be --- /dev/null +++ b/Pokemon/BattleState.cpp @@ -0,0 +1 @@ +#include "BattleState.h" diff --git a/Pokemon/BattleState.h b/Pokemon/BattleState.h new file mode 100644 index 00000000..63766235 --- /dev/null +++ b/Pokemon/BattleState.h @@ -0,0 +1,8 @@ +#include "Pokemon.h" + +struct BattleState { + Pokemon* playerPokemon; // Pointer to the player's Pokémon + Pokemon* wildPokemon; // Pointer to the wild Pokémon + bool playerTurn; // True if it's the player's turn, false if it's the wild Pokémon's turn + bool battleOngoing; // True if the battle is ongoing, false if the battle has ended +}; \ No newline at end of file From d94efbab7045ee9b3a5fb64a39cfd7a61131a023 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Sun, 3 Aug 2025 04:02:28 +0530 Subject: [PATCH 23/25] Don't want to do --- Pokemon/BattleManager.cpp | 1 + Pokemon/BattleManager.h | 2 +- Pokemon/ProfessorOak.cpp | 44 +++++++++++++++++++-------------------- Pokemon/ProfessorOak.h | 2 ++ Pokemon/player.cpp | 2 +- Pokemon/player.h | 1 + 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Pokemon/BattleManager.cpp b/Pokemon/BattleManager.cpp index f63a71e6..406ec9ac 100644 --- a/Pokemon/BattleManager.cpp +++ b/Pokemon/BattleManager.cpp @@ -2,6 +2,7 @@ #include #include "Pokemon.h" #include "PokemonType.h" +#include "player.h" #include "utility.h" #include "BattleState.h" using namespace std; diff --git a/Pokemon/BattleManager.h b/Pokemon/BattleManager.h index 19f99270..d9c8ce6c 100644 --- a/Pokemon/BattleManager.h +++ b/Pokemon/BattleManager.h @@ -1,5 +1,5 @@ #include "Pokemon.h" -#include "Player.h" +#include "player.h" #include"BattleState.h" class BattleManager { diff --git a/Pokemon/ProfessorOak.cpp b/Pokemon/ProfessorOak.cpp index e710cc68..66ea0e0b 100644 --- a/Pokemon/ProfessorOak.cpp +++ b/Pokemon/ProfessorOak.cpp @@ -1,6 +1,5 @@ #include "ProfessorOak.h" #include"utility.h" -#include "player.h" #include // Parameterized constructor @@ -8,12 +7,12 @@ ProfessorOak::ProfessorOak(string p_name) { name = p_name; } void ProfessorOak::greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; - utility::waitForEnter(); + Utility::waitForEnter(); cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; - utility::waitForEnter(); + Utility::waitForEnter(); cout << name << ": But enough about me. Let's talk about you!\n"; - utility::waitForEnter(); + Utility::waitForEnter(); } void ProfessorOak::offerPokemonChoices(Player& player) { @@ -23,17 +22,17 @@ void ProfessorOak::offerPokemonChoices(Player& player) { getline(cin, player.name); cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; - utility::waitForEnter(); + 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(); + Utility::waitForEnter(); // Presenting Pokemon choices cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; - utility::waitForEnter(); + 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"; @@ -46,64 +45,65 @@ void ProfessorOak::offerPokemonChoices(Player& player) { cin >> choice; player.choosePokemon(choice); - utility::waitForEnter(); + Utility::waitForEnter(); } // New method for the main quest conversation void ProfessorOak::explainMainQuest(Player& player) { // Clear the console - utility::clearConsole(); + Utility::clearConsole(); cout << "Professor Oak: " << player.name << "!, I am about to explain you about your upcoming grand " "adventure.\n"; - utility::waitForEnter(); + 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(); + 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(); + Utility::waitForEnter(); cout << "\n" << player.name << ": Wait... that sounds a lot like every other Pokémon game " "out there...\n"; - utility::waitForEnter(); + Utility::waitForEnter(); cout << "Professor Oak: Shhh! Don't break the fourth wall, " << player.name << "! This is serious business!\n"; - utility::waitForEnter(); + 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(); + 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(); + Utility::waitForEnter(); cout << "\n" << player.name << ": Sounds like a walk in the park... right?\n"; - utility::waitForEnter(); + 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(); + Utility::waitForEnter(); cout << "\nProfessor Oak: So, what do you say? Are you ready to " "become the next Pokémon Champion?\n"; - utility::waitForEnter(); + Utility::waitForEnter(); cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; - utility::waitForEnter(); + Utility::waitForEnter(); cout << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; - utility::waitForEnter(); + 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(); + Utility::waitForEnter(); } + diff --git a/Pokemon/ProfessorOak.h b/Pokemon/ProfessorOak.h index 0b911a4e..8463d19f 100644 --- a/Pokemon/ProfessorOak.h +++ b/Pokemon/ProfessorOak.h @@ -1,6 +1,8 @@ #include +#include "player.h" using namespace std; + // ProfessorOak class definition class ProfessorOak { public: diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp index 4b7c8cdb..02494481 100644 --- a/Pokemon/player.cpp +++ b/Pokemon/player.cpp @@ -34,5 +34,5 @@ void Player::choosePokemon(int choice) { break; } cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; - utility::waitForEnter(); // Wait for user to press Enter before proceeding + Utility::waitForEnter(); // Wait for user to press Enter before proceeding } \ No newline at end of file diff --git a/Pokemon/player.h b/Pokemon/player.h index eb38a581..25fa68f2 100644 --- a/Pokemon/player.h +++ b/Pokemon/player.h @@ -2,6 +2,7 @@ #include #include "Pokemon.h" using namespace std; + class Player { public: string name; From 3684eb2c602ec94897eea2114530131e961cbda6 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Thu, 7 Aug 2025 01:46:07 +0530 Subject: [PATCH 24/25] Inherited! But don't want to use namespace --- Pokemon/Caterpie.cpp | 0 Pokemon/Caterpie.h | 0 Pokemon/Pidgey.cpp | 0 Pokemon/Pidgey.h | 0 Pokemon/Pikachu.cpp | 11 ++++ Pokemon/Pikachu.h | 11 ++++ Pokemon/Pokemon.cpp | 5 +- Pokemon/Pokemon.h | 2 +- Pokemon/Pokemon.vcxproj | 22 +++++++ Pokemon/Pokemon.vcxproj.filters | 100 ++++++++++++++++++++++++++------ Pokemon/Temp.txt | 1 + Pokemon/Zubat.cpp | 0 Pokemon/Zubat.h | 8 +++ 13 files changed, 140 insertions(+), 20 deletions(-) create mode 100644 Pokemon/Caterpie.cpp create mode 100644 Pokemon/Caterpie.h create mode 100644 Pokemon/Pidgey.cpp create mode 100644 Pokemon/Pidgey.h create mode 100644 Pokemon/Pikachu.cpp create mode 100644 Pokemon/Pikachu.h create mode 100644 Pokemon/Temp.txt create mode 100644 Pokemon/Zubat.cpp create mode 100644 Pokemon/Zubat.h diff --git a/Pokemon/Caterpie.cpp b/Pokemon/Caterpie.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Pokemon/Caterpie.h b/Pokemon/Caterpie.h new file mode 100644 index 00000000..e69de29b diff --git a/Pokemon/Pidgey.cpp b/Pokemon/Pidgey.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Pokemon/Pidgey.h b/Pokemon/Pidgey.h new file mode 100644 index 00000000..e69de29b diff --git a/Pokemon/Pikachu.cpp b/Pokemon/Pikachu.cpp new file mode 100644 index 00000000..ff66e029 --- /dev/null +++ b/Pokemon/Pikachu.cpp @@ -0,0 +1,11 @@ +#include "Pikachu.h" +#include +#include"PokemonType.h" +using namespace std; + +Pikachu::Pikachu() : Pokemon("Pikachu", PokemonType::ELECTRIC, 100, 20) {} + +void Pikachu::thunderShock(Pokemon& target) { + cout << name << "uses Tunder shock on " << target.name << "\n"; + target.TakeDamage(20); +} \ No newline at end of file diff --git a/Pokemon/Pikachu.h b/Pokemon/Pikachu.h new file mode 100644 index 00000000..d9e42dc9 --- /dev/null +++ b/Pokemon/Pikachu.h @@ -0,0 +1,11 @@ +#include"Pokemon.h" +#pragma once + +class Pikachu : public Pokemon +{ +public: + Pikachu(); + + void thunderShock(Pokemon& target); +}; + diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp index f5f4b5d8..b4b7f295 100644 --- a/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon.cpp @@ -4,9 +4,10 @@ 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), +Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health,int p_attackPower): name(p_name), type(p_type), -health(p_health) { +health(p_health), +attackPower(p_attackPower){ } // Copy constructor diff --git a/Pokemon/Pokemon.h b/Pokemon/Pokemon.h index 7271f11c..3a026acd 100644 --- a/Pokemon/Pokemon.h +++ b/Pokemon/Pokemon.h @@ -15,7 +15,7 @@ class Pokemon { Pokemon(); // Parameterized constructor - Pokemon(string p_name, PokemonType p_type, int p_health); + Pokemon(string p_name, PokemonType p_type, int p_health,int attackPower); // Copy constructor Pokemon(const Pokemon& other); diff --git a/Pokemon/Pokemon.vcxproj b/Pokemon/Pokemon.vcxproj index 2f89b0e7..b33695c1 100644 --- a/Pokemon/Pokemon.vcxproj +++ b/Pokemon/Pokemon.vcxproj @@ -154,11 +154,22 @@ + + + + + + + + + + + @@ -167,10 +178,21 @@ + + + + + + + + + + + diff --git a/Pokemon/Pokemon.vcxproj.filters b/Pokemon/Pokemon.vcxproj.filters index 3ffc753b..c7c1e6cc 100644 --- a/Pokemon/Pokemon.vcxproj.filters +++ b/Pokemon/Pokemon.vcxproj.filters @@ -1,48 +1,114 @@ - + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - + {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - + + src + + + src + + + src + + + src + - Source Files + src - - Source Files + + src + + + src - Source Files + src + + + src + + + src - Source Files + src - - Source Files + + src + + + src + + + src + + + src + + + src - Header Files + include - Header Files + include - Header Files + include - Header Files + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include \ No newline at end of file diff --git a/Pokemon/Temp.txt b/Pokemon/Temp.txt new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/Pokemon/Temp.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Pokemon/Zubat.cpp b/Pokemon/Zubat.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Pokemon/Zubat.h b/Pokemon/Zubat.h new file mode 100644 index 00000000..f9fd0faf --- /dev/null +++ b/Pokemon/Zubat.h @@ -0,0 +1,8 @@ +#pragma once +#include"Pokemon.h" +class Zubat :public Pokemon +{ +public: + Zubat(); + void superSonic(Pokemon& target); +}; \ No newline at end of file From 1f1d6d83203b7c2d7c25cd0bf49837bc6c7dcfe2 Mon Sep 17 00:00:00 2001 From: Pranav Bardiwale Date: Fri, 8 Aug 2025 04:23:53 +0530 Subject: [PATCH 25/25] Poor player!,showing the error --- Pokemon/Bulbasaur.cpp | 11 +++++++++++ Pokemon/Bulbasaur.h | 11 +++++++++++ Pokemon/Caterpie.cpp | 11 +++++++++++ Pokemon/Caterpie.h | 10 ++++++++++ Pokemon/Charmander.cpp | 11 +++++++++++ Pokemon/Charmander.h | 10 ++++++++++ Pokemon/Pidgey.h | 10 ++++++++++ Pokemon/Pikachu.h | 2 +- Pokemon/Pokemon.cpp | 4 ++-- Pokemon/Pokemon.h | 8 ++++---- Pokemon/Squirtle.cpp | 12 ++++++++++++ Pokemon/Squirtle.h | 10 ++++++++++ Pokemon/main.cpp | 18 +++++++++++------- Pokemon/player.cpp | 10 +++++----- 14 files changed, 119 insertions(+), 19 deletions(-) create mode 100644 Pokemon/Bulbasaur.cpp create mode 100644 Pokemon/Bulbasaur.h create mode 100644 Pokemon/Charmander.cpp create mode 100644 Pokemon/Charmander.h create mode 100644 Pokemon/Squirtle.cpp create mode 100644 Pokemon/Squirtle.h diff --git a/Pokemon/Bulbasaur.cpp b/Pokemon/Bulbasaur.cpp new file mode 100644 index 00000000..a1ddddf7 --- /dev/null +++ b/Pokemon/Bulbasaur.cpp @@ -0,0 +1,11 @@ +#include "Bulbasaur.h" +#include +#include "PokemonType.h" +using namespace std; + +Bulbasaur::Bulbasaur() : Pokemon("Bulbasaur", PokemonType::GRASS, 100, 35) {} + +void Bulbasaur::vineWhip(Pokemon& target) { + cout << name << " uses Vine Whip on " << target.name << "!\n"; + target.TakeDamage(20); +} \ No newline at end of file diff --git a/Pokemon/Bulbasaur.h b/Pokemon/Bulbasaur.h new file mode 100644 index 00000000..ec657ab4 --- /dev/null +++ b/Pokemon/Bulbasaur.h @@ -0,0 +1,11 @@ +#pragma once +#include"Pokemon.h" +class Bulbasaur:public Pokemon +{ +public: + Bulbasaur(); +private: + void vineWhip(Pokemon& target); + +}; + diff --git a/Pokemon/Caterpie.cpp b/Pokemon/Caterpie.cpp index e69de29b..1b179165 100644 --- a/Pokemon/Caterpie.cpp +++ b/Pokemon/Caterpie.cpp @@ -0,0 +1,11 @@ +#include "Caterpie.h" +#include "PokemonType.h" +#include +using namespace std; + +Caterpie::Caterpie() : Pokemon("Caterpie", PokemonType::BUG, 100, 35) {} + +void Caterpie::bugBite(Pokemon& target) { + cout << name << " uses Flame Thrower on " << target.name << "!\n"; + target.TakeDamage(20); +} \ No newline at end of file diff --git a/Pokemon/Caterpie.h b/Pokemon/Caterpie.h index e69de29b..fe20c8ce 100644 --- a/Pokemon/Caterpie.h +++ b/Pokemon/Caterpie.h @@ -0,0 +1,10 @@ +#include"Pokemon.h" +#pragma once + +class Caterpie : public Pokemon +{ +public: + Caterpie(); +private: + void bugBite(Pokemon& target); +}; diff --git a/Pokemon/Charmander.cpp b/Pokemon/Charmander.cpp new file mode 100644 index 00000000..89a12352 --- /dev/null +++ b/Pokemon/Charmander.cpp @@ -0,0 +1,11 @@ +#include "Charmander.h" +#include "PokemonType.h" +#include +using namespace std; + +Charmander::Charmander() : Pokemon("Charmander", PokemonType::FIRE, 100, 35) {} + +void Charmander::flameThrower(Pokemon& target) { + cout << name << " uses Flame Thrower on " << target.name << "!\n"; + target.TakeDamage(20); +} \ No newline at end of file diff --git a/Pokemon/Charmander.h b/Pokemon/Charmander.h new file mode 100644 index 00000000..34d00bbd --- /dev/null +++ b/Pokemon/Charmander.h @@ -0,0 +1,10 @@ +#include"Pokemon.h" +#pragma once + +class Charmander : public Pokemon +{ +public: + Charmander(); +private: + void flameThrower(Pokemon& target); +}; diff --git a/Pokemon/Pidgey.h b/Pokemon/Pidgey.h index e69de29b..5c8278eb 100644 --- a/Pokemon/Pidgey.h +++ b/Pokemon/Pidgey.h @@ -0,0 +1,10 @@ +#include"Pokemon.h" +#pragma once + +class Pidgey : public Pokemon +{ +public: + Pidgey(); +private: + void wingAttack(Pokemon& target); +}; diff --git a/Pokemon/Pikachu.h b/Pokemon/Pikachu.h index d9e42dc9..7f913248 100644 --- a/Pokemon/Pikachu.h +++ b/Pokemon/Pikachu.h @@ -5,7 +5,7 @@ class Pikachu : public Pokemon { public: Pikachu(); - +private: void thunderShock(Pokemon& target); }; diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp index b4b7f295..f75314bd 100644 --- a/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon.cpp @@ -2,7 +2,7 @@ #include #include"PokemonType.h" -Pokemon::Pokemon():name("unknown"),type(PokemonType::NORMAL),health(50){} +Pokemon::Pokemon():name("unknown"),type(PokemonType::NORMAL),health(50),attackPower(10){} // Parameterized constructor Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health,int p_attackPower): name(p_name), type(p_type), @@ -11,7 +11,7 @@ attackPower(p_attackPower){ } // Copy constructor -Pokemon::Pokemon(const Pokemon& other):name(other.name),type(other.type),health(other.health) {} +Pokemon::Pokemon(const Pokemon& other):name(other.name),type(other.type),health(other.health),attackPower(other.attackPower) {} // Destructor Pokemon::~Pokemon() { diff --git a/Pokemon/Pokemon.h b/Pokemon/Pokemon.h index 3a026acd..513d6736 100644 --- a/Pokemon/Pokemon.h +++ b/Pokemon/Pokemon.h @@ -4,13 +4,13 @@ using namespace std; enum class PokemonType; class Pokemon { -public: +protected: string name; PokemonType type; int health; - int maxHealth; - int attackPower; - + int maxHealth; + int attackPower; +public: // Default constructor Pokemon(); diff --git a/Pokemon/Squirtle.cpp b/Pokemon/Squirtle.cpp new file mode 100644 index 00000000..4cfd8033 --- /dev/null +++ b/Pokemon/Squirtle.cpp @@ -0,0 +1,12 @@ +#include "Squirtle.h" +#include +#include "PokemonType.h" + +using namespace std; + +Squirtle::Squirtle() : Pokemon("Squirtle", PokemonType::WATER, 100, 35) {} + +void Squirtle::waterSplash(Pokemon& target) { + cout << name << " uses Water Splash on " << target.name << "!\n"; + target.TakeDamage(20); +} \ No newline at end of file diff --git a/Pokemon/Squirtle.h b/Pokemon/Squirtle.h new file mode 100644 index 00000000..0b5faa3f --- /dev/null +++ b/Pokemon/Squirtle.h @@ -0,0 +1,10 @@ +#pragma once +#include"Pokemon.h" +class Squirtle: public Pokemon +{ +public: + Squirtle(); +private: + void waterSplash(Pokemon& target); +}; + diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 88776d2a..742e7db1 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -9,19 +9,23 @@ using namespace std; int main() { // Continue with the main flow of the game - ProfessorOak professor("Professor Oak"); - Player player; + ProfessorOak *professor=new ProfessorOak("Professor Oak"); + Player *player=new Player(); // Greet the player and offer Pokemon choices - professor.greetPlayer(player); - professor.offerPokemonChoices(player); + professor->greetPlayer(player); + professor->offerPokemonChoices(player); // Explain the main quest - professor.explainMainQuest(player); + professor->explainMainQuest(player); // Start the main game loop - Game game; - game.gameLoop(player); + Game *game=new Game(); + game->gameLoop(player); + + delete(professor); + delete(player); + delete(game); return 0; } \ No newline at end of file diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp index 02494481..133c9c11 100644 --- a/Pokemon/player.cpp +++ b/Pokemon/player.cpp @@ -3,6 +3,7 @@ #include "PokemonChoice.h" #include "PokemonType.h" #include "Pokemon.h" +#include "Pikachu.h" #include "utility.h" #include "iostream" using namespace std; @@ -20,17 +21,16 @@ Player::Player(string p_name, Pokemon p_chosenPokemon) { void Player::choosePokemon(int choice) { switch ((PokemonChoice)choice) { case PokemonChoice::CHARMANDER: - chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100); + chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100,10); break; case PokemonChoice::BULBASAUR: - chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100); + chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100,8); break; case PokemonChoice::SQUIRTLE: - chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); + chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100,9); break; default: - chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); - chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); + chosenPokemon = Pikachu(); break; } cout << "Player " << name << " chose " << chosenPokemon.name << "!\n";