diff --git a/Pokemon/Game.cpp b/Pokemon/Game.cpp new file mode 100644 index 00000000..48391b53 --- /dev/null +++ b/Pokemon/Game.cpp @@ -0,0 +1,86 @@ +#include "Game.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 }; +} + +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, 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"; +} \ No newline at end of file diff --git a/Pokemon/Game.h b/Pokemon/Game.h new file mode 100644 index 00000000..e5d3602a --- /dev/null +++ b/Pokemon/Game.h @@ -0,0 +1,11 @@ +#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 new file mode 100644 index 00000000..7378afdd --- /dev/null +++ b/Pokemon/Grass.cpp @@ -0,0 +1,14 @@ +#include "Grass.h" +#include"PokemonType.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..0c0c9516 --- /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/Pokemon.cpp b/Pokemon/Pokemon.cpp new file mode 100644 index 00000000..ba7e8b34 --- /dev/null +++ b/Pokemon/Pokemon.cpp @@ -0,0 +1,20 @@ +#include "Pokemon.h" +#include +#include"PokemonType.h" + +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..f7f8a549 --- /dev/null +++ b/Pokemon/Pokemon.h @@ -0,0 +1,25 @@ +#include +using namespace std; + +enum class PokemonType; + +class Pokemon { +public: + string name; + PokemonType type; + int health; + + // Default constructor + Pokemon(); + + // Parameterized constructor + Pokemon(string p_name, PokemonType p_type, int p_health); + + // Copy constructor + Pokemon(const Pokemon& other); + + // Destructor + ~Pokemon(); + + void attack(); +}; \ No newline at end of file diff --git a/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 new file mode 100644 index 00000000..e69de29b 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..8b137891 --- /dev/null +++ b/Pokemon/PokemonType.cpp @@ -0,0 +1 @@ + diff --git a/Pokemon/PokemonType.h b/Pokemon/PokemonType.h new file mode 100644 index 00000000..3806a62b --- /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 +}; \ No newline at end of file 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/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 c2bc7bfc..88776d2a 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,6 +1,27 @@ +#include"Game.h" +#include"player.h" +#include"ProfessorOak.h" #include +#include // Include this header to use numeric_limits +#include +using namespace std; int main() { + + // Continue with the main flow of the game + ProfessorOak professor("Professor Oak"); + Player player; + + // Greet the player and offer Pokemon choices + professor.greetPlayer(player); + professor.offerPokemonChoices(player); + + // Explain the main quest + professor.explainMainQuest(player); + + // Start the main game loop + Game game; + game.gameLoop(player); return 0; -} +} \ No newline at end of file diff --git a/Pokemon/player.cpp b/Pokemon/player.cpp new file mode 100644 index 00000000..4b7c8cdb --- /dev/null +++ b/Pokemon/player.cpp @@ -0,0 +1,38 @@ +// Player.cpp +#include "player.h" +#include "PokemonChoice.h" +#include "PokemonType.h" +#include "Pokemon.h" +#include "utility.h" +#include "iostream" +using namespace std; + +Player::Player() { + name = "Trainer"; + chosenPokemon = Pokemon(); // Using the default Pokemon 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); + 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..eb38a581 --- /dev/null +++ b/Pokemon/player.h @@ -0,0 +1,14 @@ +// Player.h +#include +#include "Pokemon.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 a Pokemon +}; \ No newline at end of file diff --git a/Pokemon/utility.cpp b/Pokemon/utility.cpp new file mode 100644 index 00000000..eab18a0c --- /dev/null +++ b/Pokemon/utility.cpp @@ -0,0 +1,20 @@ +#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(){ + cin.ignore(numeric_limits::max(), '\n'); +} \ No newline at end of file diff --git a/Pokemon/utility.h b/Pokemon/utility.h new file mode 100644 index 00000000..b8849d92 --- /dev/null +++ b/Pokemon/utility.h @@ -0,0 +1,8 @@ +#include +class Utility{ +public : + static void clearConsole(); + static void waitForEnter(); + static void clearInputBuffer(); +}; +