diff --git a/Pokemon/BattleManager.cpp b/Pokemon/BattleManager.cpp new file mode 100644 index 00000000..7fc35a1a --- /dev/null +++ b/Pokemon/BattleManager.cpp @@ -0,0 +1,26 @@ +#include +#include "Pokemon.hpp" + + +using namespace std; +class BattleManager +{ + 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/Game.cpp b/Pokemon/Game.cpp new file mode 100644 index 00000000..18a0ec07 --- /dev/null +++ b/Pokemon/Game.cpp @@ -0,0 +1,92 @@ +#include "Game.hpp" +#include "Player.hpp" +#include "PokemonType.hpp" +#include "Utility.hpp" +#include "WildEncounterManager.hpp" +#include +using namespace std; + +Game::Game() { + forestGrass = {"Forest", {Pokemon {"Pidgey", PokemonType::NORMAL, 40}, Pokemon {"Caterpie", PokemonType::BUG, 35}}, 70}; + + /*caveGrass = { + "Cave", + {{"Zubat", PokemonType::POISON, 30, 10}, {"Geodude", PokemonType::ROCK, 50, 10}}, + 80 + }; + + shallowWater = { + "Cave", + {{"Staryu", PokemonType::WATER, 40, 10}, {"Tentacool", PokemonType::POISON, 40, 10}}, + 80 + };*/ +} + +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: { + // 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.\\n"; + player.chosenPokemon.heal(); // Heal the player's Pokémon + cout << player.chosenPokemon.name << "'s health is fully restored!\\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; + } + } + + Utility::waitForEnter(); + } + + cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; +} \ No newline at end of file diff --git a/Pokemon/Game.hpp b/Pokemon/Game.hpp new file mode 100644 index 00000000..7b8af6cb --- /dev/null +++ b/Pokemon/Game.hpp @@ -0,0 +1,16 @@ +#pragma once +#include "Grass.hpp" + +class Player; + +class Game { + +public: + Game(); + void gameLoop(Player& player); + +private: + Grass forestGrass; + Grass caveGrass; + Grass shallowWater; +}; \ No newline at end of file diff --git a/Pokemon/Grass.hpp b/Pokemon/Grass.hpp new file mode 100644 index 00000000..a6c89f98 --- /dev/null +++ b/Pokemon/Grass.hpp @@ -0,0 +1,12 @@ +#pragma once +#include +#include +#include"Pokemon.hpp" +#include"WildEncounterManager.hpp" +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 +}; \ No newline at end of file diff --git a/Pokemon/Player.cpp b/Pokemon/Player.cpp index fc82cefe..8a810f40 100644 --- a/Pokemon/Player.cpp +++ b/Pokemon/Player.cpp @@ -17,16 +17,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, 10); break; case PokemonChoice::SQUIRTLE: - chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100); + chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100, 10); break; default: - chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100); + chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100, 10); break; } cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp index 371886cb..60ff4eda 100644 --- a/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon.cpp @@ -11,23 +11,39 @@ using namespace std; health = 50; } - // Parameterized constructor - Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health) { + Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health, int p_attackPower) { 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 + Pokemon::~Pokemon() { } + + void Pokemon::attack(Pokemon& target) { + int damage = attackPower; // Use attack power for damage calculation + std::cout << name << " attacks " << target.name << " for " << damage << " damage!\n"; + target.takeDamage(damage); + } + + void Pokemon::takeDamage(int damage) + { + health -= damage; + if (health <= 0) + health = 0; + } + + bool Pokemon::isFainted() const + { + return (health <= 0); } - void Pokemon::attack() { std::cout << name << " attacks with a powerful move!\n"; } \ No newline at end of file + void Pokemon::heal() + { + health = maxHealth; + } \ No newline at end of file diff --git a/Pokemon/Pokemon.hpp b/Pokemon/Pokemon.hpp index 116d4522..397c4ce4 100644 --- a/Pokemon/Pokemon.hpp +++ b/Pokemon/Pokemon.hpp @@ -11,17 +11,25 @@ class Pokemon { string name; PokemonType type; int health; + int maxHealth; + int attackPower; // Default constructor Pokemon(); // Parameterized constructor - Pokemon(std::string p_name, PokemonType p_type, int p_health); + Pokemon(std::string p_name, PokemonType p_type, int p_health, int p_attackPower); // Copy constructor Pokemon(const Pokemon& other); ~Pokemon(); - void attack(); + void attack(Pokemon& target); + + void heal(); + + void takeDamage(int damage); + + bool isFainted() const; }; \ No newline at end of file diff --git a/Pokemon/Pokemon.vcxproj b/Pokemon/Pokemon.vcxproj index ab142809..179166f2 100644 --- a/Pokemon/Pokemon.vcxproj +++ b/Pokemon/Pokemon.vcxproj @@ -154,10 +154,14 @@ + + + + @@ -166,12 +170,15 @@ - + + + + diff --git a/Pokemon/Pokemon.vcxproj.filters b/Pokemon/Pokemon.vcxproj.filters index a65475d3..dfa65b46 100644 --- a/Pokemon/Pokemon.vcxproj.filters +++ b/Pokemon/Pokemon.vcxproj.filters @@ -27,11 +27,20 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + - - Header Files - Header Files @@ -47,5 +56,17 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.ilk b/Pokemon/Pokemon/x64/Debug/Pokemon.ilk index df4921c9..9cefa76e 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.ilk and b/Pokemon/Pokemon/x64/Debug/Pokemon.ilk differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.log b/Pokemon/Pokemon/x64/Debug/Pokemon.log index 72912f4a..bb7827ce 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.log +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.log @@ -1,2 +1,3 @@ - main.cpp - Pokemon.vcxproj -> C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\x64\Debug\Pokemon.exe + Game.cpp +C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Game.cpp(10,39): error C2440: '': cannot convert from 'initializer list' to 'Pokemon' +C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Game.cpp(10,84): error C2440: '': cannot convert from 'initializer list' to 'Pokemon' diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.command.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.command.1.tlog index ba9ef440..9f99b432 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.command.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.command.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.read.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.read.1.tlog index 0321cbc6..7c0dbf36 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.read.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.read.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.write.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.write.1.tlog index 19d28472..05356184 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.write.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.write.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog index 41ad9d1f..0092d4e6 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog @@ -1,4 +1,8 @@ +C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\BattleManager.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\BattleManager.obj +C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Game.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Game.obj C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\main.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\main.obj C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Player.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Player.obj C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Pokemon.obj +C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\ProfessorOak.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\ProfessorOak.obj C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Utility.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Utility.obj +C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\WildEncounterManager.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\WildEncounterManager.obj diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.command.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.command.1.tlog index 966f28f3..51a11d88 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.command.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.command.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.read.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.read.1.tlog index 1613e2e1..3a0e0f3c 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.read.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.read.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.secondary.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.secondary.1.tlog index ec39e7c3..400cef15 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.secondary.1.tlog +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.secondary.1.tlog @@ -1,2 +1,2 @@ -^C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\MAIN.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\PLAYER.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\POKEMON.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\UTILITY.OBJ +^C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\BATTLEMANAGER.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\GAME.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\MAIN.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\PLAYER.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\POKEMON.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\PROFESSOROAK.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\UTILITY.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\WILDENCOUNTERMANAGER.OBJ C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Pokemon.ilk diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.write.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.write.1.tlog index 7ff96532..2906cd7e 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.write.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.write.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/unsuccessfulbuild b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/unsuccessfulbuild new file mode 100644 index 00000000..e69de29b diff --git a/Pokemon/Pokemon/x64/Debug/vc143.idb b/Pokemon/Pokemon/x64/Debug/vc143.idb index a24d216f..18aa72d1 100644 Binary files a/Pokemon/Pokemon/x64/Debug/vc143.idb and b/Pokemon/Pokemon/x64/Debug/vc143.idb differ diff --git a/Pokemon/Pokemon/x64/Debug/vc143.pdb b/Pokemon/Pokemon/x64/Debug/vc143.pdb index 5a607333..19c69f22 100644 Binary files a/Pokemon/Pokemon/x64/Debug/vc143.pdb and b/Pokemon/Pokemon/x64/Debug/vc143.pdb differ diff --git a/Pokemon/PokemonType.hpp b/Pokemon/PokemonType.hpp index f56102f3..f83d5fb6 100644 --- a/Pokemon/PokemonType.hpp +++ b/Pokemon/PokemonType.hpp @@ -4,5 +4,8 @@ enum class PokemonType { GRASS, WATER, ELECTRIC, + POISON, + BUG, + ROCK, NORMAL // 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..988ca3c0 --- /dev/null +++ b/Pokemon/ProfessorOak.cpp @@ -0,0 +1,113 @@ +#pragma once +#include +#include // Include this header to use numeric_limits +#include +#include"Utility.hpp" +#include"Player.hpp" +#include"ProfessorOak.hpp" +using namespace std; + + // 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(std::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(); + } \ No newline at end of file diff --git a/Pokemon/ProfessorOak.hpp b/Pokemon/ProfessorOak.hpp new file mode 100644 index 00000000..a4db7eef --- /dev/null +++ b/Pokemon/ProfessorOak.hpp @@ -0,0 +1,22 @@ +#pragma once +#include +#include // Include this header to use numeric_limits +#include +#include"Utility.hpp" +#include"Player.hpp" +using namespace std; + +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 diff --git a/Pokemon/WildEncounterManager.cpp b/Pokemon/WildEncounterManager.cpp new file mode 100644 index 00000000..6f9fe9dc --- /dev/null +++ b/Pokemon/WildEncounterManager.cpp @@ -0,0 +1,15 @@ +#include "WildEncounterManager.hpp" +#include"Grass.hpp" +#include"Pokemon.hpp" +#include +#include + +WildEncounterManager::WildEncounterManager() { + srand(time(0)); +} + +Pokemon WildEncounterManager::getRandomPokemonFromGrass(const Grass& grass) { + int randomIndex = rand() % grass.wildPokemonList.size(); + Pokemon WildPokemon = grass.wildPokemonList[randomIndex]; + return WildPokemon; +} \ No newline at end of file diff --git a/Pokemon/WildEncounterManager.hpp b/Pokemon/WildEncounterManager.hpp new file mode 100644 index 00000000..e5e5110d --- /dev/null +++ b/Pokemon/WildEncounterManager.hpp @@ -0,0 +1,11 @@ +#pragma once +#include + +struct Grass; +class Pokemon; + +class WildEncounterManager { +public: + WildEncounterManager(); + Pokemon getRandomPokemonFromGrass(const Grass& grass); +}; \ No newline at end of file diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index 5162a332..22f3693b 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,208 +1,22 @@ #include -#include // Include this header to use numeric_limits +#include #include -#include"PokemonType.hpp" -#include"PokemonChoice.hpp" -#include"Utility.hpp" -#include"Player.hpp" -using namespace std; - -// 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(std::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; - - // 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: - 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"; -} +#include "Game.hpp" +#include "Player.hpp" +#include "ProfessorOak.hpp" 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); - // Greet the player and offer Pokemon choices - professor.greetPlayer(player); - professor.offerPokemonChoices(player); + ProfessorOak professor("Professor Oak"); + Player player; - // Explain the main quest - professor.explainMainQuest(player); + professor.greetPlayer(player); + professor.offerPokemonChoices(player); - // Start the main game loop - gameLoop(player); + professor.explainMainQuest(player); - return 0; -} + Game game; + game.gameLoop(player); -//test \ No newline at end of file + return 0; +} \ No newline at end of file diff --git a/Pokemon/x64/Debug/Pokemon.pdb b/Pokemon/x64/Debug/Pokemon.pdb index d3c8925f..427c9602 100644 Binary files a/Pokemon/x64/Debug/Pokemon.pdb and b/Pokemon/x64/Debug/Pokemon.pdb differ