diff --git a/Pokemon/BattleManager.cpp b/Pokemon/BattleManager.cpp new file mode 100644 index 00000000..0ebe0fe0 --- /dev/null +++ b/Pokemon/BattleManager.cpp @@ -0,0 +1,59 @@ +#include "BattleManager.h" +#include +#include "Pokemon.h" +#include "PokemonType.h" +#include "player.h" +#include "utility.h" +#include "BattleState.h" +using namespace std; + +BattleState BattleManager::battleState; + +void BattleManager::startBattle(Player* player, Pokemon* wildPokemon) { + battleState.playerPokemon = player->chosenPokemon; + battleState.wildPokemon = wildPokemon; + battleState.playerTurn = true; + battleState.battleOngoing = true; + + cout << "A wild " << wildPokemon->name << " appeared!\n"; + Utility::waitForEnter(); + + battle(); +} + +void BattleManager::stopBattle() { battleState.battleOngoing = false; } + +void BattleManager::battle() { + while (battleState.battleOngoing) + { + if (battleState.playerTurn) + battleState.playerPokemon->selectAndUseMove(battleState.wildPokemon); + else + battleState.wildPokemon->selectAndUseMove(battleState.playerPokemon); + + updateBattleState(); + battleState.playerTurn = !battleState.playerTurn; + Utility::waitForEnter(); + } + + handleBattleOutcome(); +} + +void BattleManager::updateBattleState() { + if (battleState.playerPokemon->isFainted()) { + battleState.battleOngoing = false; + } + else if (battleState.wildPokemon->isFainted()) { + battleState.battleOngoing = false; + } +} + +void BattleManager::handleBattleOutcome() { + if (battleState.playerPokemon->isFainted()) { + cout << battleState.playerPokemon->name + << " has fainted! You lose the battle.\n"; + } + else { + 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 new file mode 100644 index 00000000..b477e553 --- /dev/null +++ b/Pokemon/BattleManager.h @@ -0,0 +1,18 @@ +#pragma once +#include "BattleState.h" +#include "Player.h" + + +class Pokemon; + +class BattleManager { +public: + void startBattle(Player* player, Pokemon* wildPokemon); + static void stopBattle(); +private: + static BattleState battleState; + + void battle(); + void handleBattleOutcome(); + void updateBattleState(); +}; 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..ecef7ae2 --- /dev/null +++ b/Pokemon/BattleState.h @@ -0,0 +1,9 @@ +#pragma once +#include "Pokemon.h" + +struct BattleState { + Pokemon* playerPokemon; + Pokemon* wildPokemon; + bool playerTurn; + bool battleOngoing; +}; diff --git a/Pokemon/Bulbasaur.cpp b/Pokemon/Bulbasaur.cpp new file mode 100644 index 00000000..cb070222 --- /dev/null +++ b/Pokemon/Bulbasaur.cpp @@ -0,0 +1,30 @@ +#include "Bulbasaur.h" +#include +#include "PokemonType.h" +using namespace std; + +Bulbasaur::Bulbasaur() + : Pokemon("Bulbasaur", PokemonType::GRASS, 110, { + Move("VINE WHIP", 25), + Move("TACKLE", 10) + }) { +} + +void Bulbasaur::attack(Move selectedMove, Pokemon* target) +{ + Pokemon::attack(selectedMove, target); + + if (selectedMove.name == "VINE WHIP") + { + // Chance for a second hit (50% chance) + int secondHitChance = rand() % 2; + + if (secondHitChance == 1) + { + Pokemon::attack(selectedMove, target); + std::cout << name << " hits again with a second " << selectedMove.name << "!\n"; + } + else + std::cout << target->name << " dodged the second hit!\n"; + } +} \ No newline at end of file diff --git a/Pokemon/Bulbasaur.h b/Pokemon/Bulbasaur.h new file mode 100644 index 00000000..5d5192c3 --- /dev/null +++ b/Pokemon/Bulbasaur.h @@ -0,0 +1,9 @@ +#pragma once +#include "Pokemon.h" + +class Bulbasaur : public Pokemon { +public: + Bulbasaur(); + void attack(Move selectedMove, Pokemon* target) override; +}; + diff --git a/Pokemon/Caterpie.cpp b/Pokemon/Caterpie.cpp new file mode 100644 index 00000000..316d1119 --- /dev/null +++ b/Pokemon/Caterpie.cpp @@ -0,0 +1,25 @@ +#include "Caterpie.h" +#include "PokemonType.h" +#include +using namespace std; + +Caterpie::Caterpie() + : Pokemon("Caterpie", PokemonType::BUG, 75, { + Move("TACKLE", 10), + Move("STRING SHOT", 5), + Move("STICKY WEB", 10) + }) { +} + +void Caterpie::attack(Move selectedMove, Pokemon* target) +{ + Pokemon::attack(selectedMove, target); + + if (selectedMove.name == "STICKY WEB") + { + // Reduce the target's next attack damage (for simplicity, reducing by a fixed value) + int reducedDamage = 5; + target->reduceAttackPower(reducedDamage); + std::cout << target->name << "'s next attack will be reduced by " << reducedDamage << " damage!\n"; + } +} \ No newline at end of file diff --git a/Pokemon/Caterpie.h b/Pokemon/Caterpie.h new file mode 100644 index 00000000..433e8ca2 --- /dev/null +++ b/Pokemon/Caterpie.h @@ -0,0 +1,8 @@ +#include"Pokemon.h" +#pragma once + +class Caterpie : public Pokemon { +public: + Caterpie(); + void attack(Move selectedMove, Pokemon* target) override; +}; diff --git a/Pokemon/Charmander.cpp b/Pokemon/Charmander.cpp new file mode 100644 index 00000000..59ee8e40 --- /dev/null +++ b/Pokemon/Charmander.cpp @@ -0,0 +1,27 @@ +#include "Charmander.h" +#include "PokemonType.h" +#include "Move.h" +#include "Utility.h" +#include +using namespace std; + +Charmander::Charmander() + : Pokemon("Charmander", PokemonType::FIRE, 95, { + Move("EMBER", 20), + Move("SCRATCH", 15), + Move("BLAZING CHARGE", 70) + }) { +} + +void Charmander::attack(Move selectedMove, Pokemon* target) +{ + Pokemon::attack(selectedMove, target); + + if (selectedMove.name == "BLAZING CHARGE") + { + // Recoil effect: Charmander takes recoil damage + this->takeDamage(10); // Fixed recoil damage + std::cout << name << " takes 10 recoil damage from the Blazing Charge!\n"; + Utility::Utility::waitForEnter(); + } +} \ No newline at end of file diff --git a/Pokemon/Charmander.h b/Pokemon/Charmander.h new file mode 100644 index 00000000..6ad3bbba --- /dev/null +++ b/Pokemon/Charmander.h @@ -0,0 +1,8 @@ +#include"Pokemon.h" +#pragma once + +class Charmander : public Pokemon { +public: + Charmander(); + void attack(Move selectedMove, Pokemon* target) override; +}; diff --git a/Pokemon/Game.cpp b/Pokemon/Game.cpp new file mode 100644 index 00000000..366293f4 --- /dev/null +++ b/Pokemon/Game.cpp @@ -0,0 +1,109 @@ +#include "Game.h" +#include "Player.h" +#include "PokemonType.h" +#include "utility.h" +#include "WildEncounterManager.h" +#include +#include"BattleManager.h" +#include "Caterpie.h" +#include "Pidgey.h" +#include "Zubat.h" +#include "Utility.h" +#include +using namespace std; + +Game::Game() { + // Create a sample grass environment with actual Pokemon objects + forestGrass = { "Forest", {new Pidgey(), new Caterpie(), new Zubat()}, 70 }; +} + +void Game::gameLoop(Player* player) { + + int choice; + bool keepPlaying = true; + BattleManager* battleManager = new BattleManager(); + WildEncounterManager* encounterManager = new WildEncounterManager(); + + 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: { + wildPokemon = encounterManager->getRandomPokemonFromGrass(forestGrass); + battleManager->startBattle(player, wildPokemon); + break; + } + case 2: { + visitPokeCenter(player); + 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"; + + delete(encounterManager); + delete(battleManager); +} + +void Game::visitPokeCenter(Player* player) { + if (player->chosenPokemon->health == player->chosenPokemon->maxHealth) { + std::cout << "Your Pokémon is already at full health!\n"; + } + else { + std::cout << "You head to the PokeCenter.\n"; + std::cout << "Healing your Pokémon...\n"; + Utility::waitForEnter(); // Simulate a short pause for the + // healing process + player->chosenPokemon->heal(); // Heal the player's Pokémon + std::cout << player->chosenPokemon->name << "'s health is fully restored!\n"; + } +} + +Game::~Game() +{ + delete(wildPokemon); +} \ No newline at end of file diff --git a/Pokemon/Game.h b/Pokemon/Game.h new file mode 100644 index 00000000..1284dd9f --- /dev/null +++ b/Pokemon/Game.h @@ -0,0 +1,17 @@ +#pragma once +#include "Player.h" +#include "Grass.h" + +// class Player; + +class Game { +private: + Grass forestGrass; + Pokemon* wildPokemon; + +public: + Game(); + ~Game(); + void gameLoop(Player* player); + void visitPokeCenter(Player* player); +}; diff --git a/Pokemon/Grass.cpp b/Pokemon/Grass.cpp new file mode 100644 index 00000000..0de5d572 --- /dev/null +++ b/Pokemon/Grass.cpp @@ -0,0 +1,21 @@ +#include "Grass.h" +#include "PokemonType.h" +#include "Move.h" + +Grass forestGrass = { + "Forest", + { + new Pokemon("Pidgey", PokemonType::NORMAL, 40, {Move("GUST", 15), Move("TACKLE", 10)}), + new Pokemon("Caterpie", PokemonType::BUG, 35, {Move("TACKLE", 10), Move("STRING SHOT", 5)}) + }, + 70 +}; + +Grass caveGrass = { + "Cave", + { + new Pokemon("Zubat", PokemonType::POISON, 30, {Move("BITE", 12), Move("WING ATTACK", 10)}), + new Pokemon("Geodude", PokemonType::ROCK, 50, {Move("TACKLE", 10), Move("DEFENSE CURL", 5)}) + }, + 80 +}; \ No newline at end of file diff --git a/Pokemon/Grass.h b/Pokemon/Grass.h new file mode 100644 index 00000000..41a9423e --- /dev/null +++ b/Pokemon/Grass.h @@ -0,0 +1,13 @@ +#include +#include +#include"Pokemon.h" +#include +using namespace std; +class Pokemon; + +struct Grass { + std::string environmentType; // Example: "Forest", "Cave", "Riverbank" + std::vector wildPokemonList; // List of wild Pokémon in this grass + int encounterRate; // Likelihood of encountering a wild Pokémon, out of 100 +}; + diff --git a/Pokemon/Move.cpp b/Pokemon/Move.cpp new file mode 100644 index 00000000..40185c88 --- /dev/null +++ b/Pokemon/Move.cpp @@ -0,0 +1 @@ +#include "Move.h" diff --git a/Pokemon/Move.h b/Pokemon/Move.h new file mode 100644 index 00000000..6c2a023e --- /dev/null +++ b/Pokemon/Move.h @@ -0,0 +1,16 @@ +#pragma once +#include +using namespace std; + + +struct Move +{ + string name; + int power; + + Move(const string& moveName, int movePower) + { + name = moveName; + power = movePower; + } +}; diff --git a/Pokemon/MoveName.cpp b/Pokemon/MoveName.cpp new file mode 100644 index 00000000..441d1119 --- /dev/null +++ b/Pokemon/MoveName.cpp @@ -0,0 +1 @@ +#include "MoveName.h" diff --git a/Pokemon/MoveName.h b/Pokemon/MoveName.h new file mode 100644 index 00000000..46f3201e --- /dev/null +++ b/Pokemon/MoveName.h @@ -0,0 +1,17 @@ +#pragma once + +enum class MoveName +{ + BUG_BITE, + TACKLE, + EMBER, + THUNDERSHOCK, + QUICK_ATTACK, + GUST, + WATER_GUN, + VINE_WHIP, + STRING_SHOT, + SCRATCH, + BITE, + LEECH_LIFE +}; \ No newline at end of file diff --git a/Pokemon/Pidgey.cpp b/Pokemon/Pidgey.cpp new file mode 100644 index 00000000..92521ca4 --- /dev/null +++ b/Pokemon/Pidgey.cpp @@ -0,0 +1,30 @@ +#include "Pidgey.h" +#include +#include "PokemonType.h" +#include "Move.h" +#include "BattleManager.h" +#include "Utility.h" +using namespace std; + +Pidgey::Pidgey() + : Pokemon("Pidgey", PokemonType::FLYING, 80, { + Move("GUST", 15), + Move("TACKLE", 10) + }) { +} + +void Pidgey::attack(Move selectedMove, Pokemon* target) +{ + Pokemon::attack(selectedMove, target); + + if (selectedMove.name == "GUST") + { + // 20% chance to blow the opponent away + if (rand() % 100 < 20) + { + std::cout << "... and blew the opponent away!\n"; + BattleManager::stopBattle(); + Utility::Utility::waitForEnter(); + } + } +} \ No newline at end of file diff --git a/Pokemon/Pidgey.h b/Pokemon/Pidgey.h new file mode 100644 index 00000000..e7e3efe1 --- /dev/null +++ b/Pokemon/Pidgey.h @@ -0,0 +1,8 @@ +#include"Pokemon.h" +#pragma once + +class Pidgey : public Pokemon { +public: + Pidgey(); + void attack(Move selectedMove, Pokemon* target) override; +}; \ No newline at end of file diff --git a/Pokemon/Pikachu.cpp b/Pokemon/Pikachu.cpp new file mode 100644 index 00000000..3387aef8 --- /dev/null +++ b/Pokemon/Pikachu.cpp @@ -0,0 +1,31 @@ +#include "Pikachu.h" +#include +#include"PokemonType.h" +#include "Move.h" +using namespace std; + +Pikachu::Pikachu() + : Pokemon("Pikachu", PokemonType::ELECTRIC, 100, { + Move("THUNDER SHOCK", 20), + Move("QUICK ATTACK", 10), + Move("THUNDER BOLT", 80) + }) { +} + +void Pikachu::attack(Move selectedMove, Pokemon* target) +{ + if (selectedMove.name == "THUNDER BOLT") + { + // 80% chance to hit + if (rand() % 100 < 80) + { + Pokemon::attack(selectedMove, target); + std::cout << "... and it hit successfully!\n"; + } + else + std::cout << "... but it missed!\n"; + } + else + Pokemon::attack(selectedMove, target); + +} \ No newline at end of file diff --git a/Pokemon/Pikachu.h b/Pokemon/Pikachu.h new file mode 100644 index 00000000..b3bbff6c --- /dev/null +++ b/Pokemon/Pikachu.h @@ -0,0 +1,8 @@ +#include"Pokemon.h" +#pragma once + +class Pikachu : public Pokemon { +public: + Pikachu(); + void attack(Move selectedMove, Pokemon* target) override; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp new file mode 100644 index 00000000..8a1cae51 --- /dev/null +++ b/Pokemon/Pokemon.cpp @@ -0,0 +1,110 @@ +#include "Pokemon.h" +#include +#include"PokemonType.h" +#include "Move.h" +#include "Utility.h" + +// Default constructor +Pokemon::Pokemon() { + name = "Unknown"; + type = PokemonType::NORMAL; + health = 50; + maxHealth = 50; +} + +// Parameterized constructor +Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health, vector p_moves) { + name = p_name; + type = p_type; + maxHealth = p_health; + health = p_health; + moves = p_moves; +} + +// Copy constructor +Pokemon::Pokemon(Pokemon* other) { + name = other->name; + type = other->type; + health = other->health; + maxHealth = other->maxHealth; + moves = other->moves; +} + +// Reduce HP by the damage amount +void Pokemon::takeDamage(int damage) { + health -= damage; + if (health < 0) { + health = 0; + } +} + +void Pokemon::selectAndUseMove(Pokemon* target) +{ + printAvailableMoves(); + + int choice = selectMove(); + Move selectedMove = moves[choice - 1]; + + useMove(selectedMove, target); +} + +void Pokemon::reduceAttackPower(int reduced_damage) +{ + for (int i = 0; i < moves.size(); i++) + { + moves[i].power -= reduced_damage; + if (moves[i].power < 0) + moves[i].power = 0; + } +} + +void Pokemon::printAvailableMoves() +{ + cout << name << "'s available moves:\n"; + + // List out all moves for the player to choose from + for (size_t i = 0; i < moves.size(); ++i) { + cout << i + 1 << ": " << moves[i].name << " (Power: " << moves[i].power << ")\n"; + } +} + +int Pokemon::selectMove() +{ + // Ask the player to select a move + int choice; + cout << "Choose a move: "; + cin >> choice; + + // Validate the choice + while (choice < 1 || choice > static_cast(moves.size())) { + cout << "Invalid choice. Try again: "; + cin >> choice; + } + + return choice; +} + +void Pokemon::useMove(Move selectedMove, Pokemon* target) +{ + cout << name << " used " << selectedMove.name << "!\n"; + attack(selectedMove, target); + + Utility::Utility::waitForEnter(); + + cout << "...\n"; + Utility::Utility::waitForEnter(); + + if (target->isFainted()) + cout << target->name << " fainted!\n"; + else + cout << target->name << " has " << target->health << " HP left.\n"; +} + +void Pokemon::attack(Move selectedMove, Pokemon* target) { target->takeDamage(selectedMove.power); } + +// Check if the Pokemon has fainted +bool Pokemon::isFainted() const { return health <= 0; } + +// Restore health to full +void Pokemon::heal() { health = maxHealth; +} \ No newline at end of file diff --git a/Pokemon/Pokemon.h b/Pokemon/Pokemon.h new file mode 100644 index 00000000..25c728dd --- /dev/null +++ b/Pokemon/Pokemon.h @@ -0,0 +1,35 @@ +#include +#include +#include "Move.h" +using namespace std; + +enum class PokemonType; + +struct Move; +enum class PokemonType; + +class Pokemon { +public: + std::string name; + PokemonType type; + int health; + int maxHealth; + vector moves; // Store the list of moves + + Pokemon(); + Pokemon(std::string p_name, PokemonType p_type, int p_health, vector); + Pokemon(Pokemon* other); + + bool isFainted() const; + void heal(); + virtual void attack(Move selectedMove, Pokemon* target); + void takeDamage(int damage); + void selectAndUseMove(Pokemon* target); + void reduceAttackPower(int reduced_damage); + +protected: + // Base implementation for selecting and using a move + void printAvailableMoves(); + int selectMove(); + void useMove(Move selectedMove, Pokemon* target); +}; \ 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..b33695c1 100644 --- a/Pokemon/Pokemon.vcxproj +++ b/Pokemon/Pokemon.vcxproj @@ -154,7 +154,22 @@ + + + + + + + + + + + + + + + @@ -162,6 +177,23 @@ + + + + + + + + + + + + + + + + + diff --git a/Pokemon/Pokemon.vcxproj.filters b/Pokemon/Pokemon.vcxproj.filters index 644f8bee..c7c1e6cc 100644 --- a/Pokemon/Pokemon.vcxproj.filters +++ b/Pokemon/Pokemon.vcxproj.filters @@ -1,22 +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 + + + src + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + + + include + \ 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..5b99db86 --- /dev/null +++ b/Pokemon/PokemonType.h @@ -0,0 +1,12 @@ +// Define an enum for Pokemon types +enum class PokemonType { + FIRE, + GRASS, + WATER, + ELECTRIC, + NORMAL, + BUG, + POISON, + ROCK, + FLYING// 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..f33942bd --- /dev/null +++ b/Pokemon/ProfessorOak.cpp @@ -0,0 +1,99 @@ +#include "ProfessorOak.h" +#include"utility.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) { + + std::cout << name << ": First, tell me, what’s your name? \t [Please Enter Your Name]\n"; + std::getline(std::cin, player->name); + std::cout << name << ": Ah, " << player->name << "! What a fantastic name!\n"; + Utility::waitForEnter(); + std::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(); +} + +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..14e7bf46 --- /dev/null +++ b/Pokemon/ProfessorOak.h @@ -0,0 +1,17 @@ +#include +#include "Player.h" + +class Player; + +using namespace std; + + +class ProfessorOak { +public: + string name; + + ProfessorOak(string p_name); + void greetPlayer(Player* player); + void offerPokemonChoices(Player* player); + void explainMainQuest(Player* player); +}; \ No newline at end of file diff --git a/Pokemon/Squirtle.cpp b/Pokemon/Squirtle.cpp new file mode 100644 index 00000000..4c845422 --- /dev/null +++ b/Pokemon/Squirtle.cpp @@ -0,0 +1,32 @@ +#include "Squirtle.h" +#include +#include "PokemonType.h" +#include "Move.h" + +using namespace std; + +Squirtle::Squirtle() + : Pokemon("Squirtle", PokemonType::WATER, 105, { + Move("WATER GUN", 20), + Move("TACKLE", 10), + Move("RAPID SPIN", 5) + }) { +} + +void Squirtle::attack(Move selectedMove, Pokemon* target) +{ + Pokemon::attack(selectedMove, target); + + if (selectedMove.name == "RAPID SPIN") + { + // Random number of hits between 2 and 5 + int hits = (rand() % 4) + 2; + + // Split damage across hits + for (int i = 0; i < hits; ++i) { + Pokemon::attack(selectedMove, target); + } + + std::cout << "... and hit " << hits << " times!\\n"; + } +} \ No newline at end of file diff --git a/Pokemon/Squirtle.h b/Pokemon/Squirtle.h new file mode 100644 index 00000000..1ff3b3b1 --- /dev/null +++ b/Pokemon/Squirtle.h @@ -0,0 +1,9 @@ +#pragma once +#include"Pokemon.h" +class Squirtle : public Pokemon { +public: + Squirtle(); + void attack(Move selectedMove, Pokemon* target) override; +}; + + 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/WildEncounterManager.cpp b/Pokemon/WildEncounterManager.cpp new file mode 100644 index 00000000..86645895 --- /dev/null +++ b/Pokemon/WildEncounterManager.cpp @@ -0,0 +1,19 @@ +#include "WildEncounterManager.h" +#include "Grass.h" // Assuming the Grass struct is defined here +#include "Pokemon.h" // Assuming the Pokemon class is defined here +#include // For rand() +#include // For time() + + + +WildEncounterManager::WildEncounterManager() { + srand(time(0)); // Seed the random number generator +} + +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.h b/Pokemon/WildEncounterManager.h new file mode 100644 index 00000000..d9d8cc02 --- /dev/null +++ b/Pokemon/WildEncounterManager.h @@ -0,0 +1,12 @@ +#include "Pokemon.h" + +struct Grass; +class Pokemon; + + + +class WildEncounterManager { +public: + WildEncounterManager(); + Pokemon* getRandomPokemonFromGrass(const Grass& grass); +}; \ No newline at end of file diff --git a/Pokemon/Zubat.cpp b/Pokemon/Zubat.cpp new file mode 100644 index 00000000..208ac68e --- /dev/null +++ b/Pokemon/Zubat.cpp @@ -0,0 +1,31 @@ +#include "Zubat.h" +#include "PokemonType.h" +#include +#include "Move.h" + +using namespace std; + +Zubat::Zubat() + : Pokemon("Zubat", PokemonType::POISON, 85, { + Move("BITE", 18), + Move("LEECH LIFE", 10) + }) { +} + +void Zubat::attack(Move selectedMove, Pokemon* target) +{ + // Call the base class method from child class. + Pokemon::attack(selectedMove, target); + + if (selectedMove.name == "LEECH LIFE") + { + // Restore 50% of the damage dealt + this->health += selectedMove.power * 0.5; + + // Ensure health does not exceed maxHealth + if (this->health > this->maxHealth) + this->health = this->maxHealth; + + std::cout << "... and regained health!\n"; + } +} \ No newline at end of file diff --git a/Pokemon/Zubat.h b/Pokemon/Zubat.h new file mode 100644 index 00000000..337dcbb6 --- /dev/null +++ b/Pokemon/Zubat.h @@ -0,0 +1,7 @@ +#pragma once +#include"Pokemon.h" +class Zubat : public Pokemon { +public: + Zubat(); + void attack(Move selectedMove, Pokemon* target) override; +}; \ No newline at end of file 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..742e7db1 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,6 +1,31 @@ +#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=new ProfessorOak("Professor Oak"); + Player *player=new 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=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 new file mode 100644 index 00000000..5cc18bd5 --- /dev/null +++ b/Pokemon/player.cpp @@ -0,0 +1,52 @@ +#include "Game.h" +#include "BattleManager.h" +#include "WildEncounterManager.h" +#include "Player.h" +#include "Caterpie.h" +#include "Pidgey.h" +#include "Zubat.h" +#include "Utility.h" +#include +#include"PokemonChoice.h" +#include "PokemonType.h" +#include "Charmander.h" +#include "Bulbasaur.h" +#include "Squirtle.h" +#include "Pikachu.h" +#include +using namespace std; + + + +Game::Game() { + // Create a sample grass environment with actual Pokemon objects + forestGrass = { "Forest", {new Pidgey(), new Caterpie(), new Zubat()}, 70 }; +} + +Player::Player() { + name = "Trainer"; +} + +Player::Player(std::string p_name) { + name = p_name; +} + +void Player::choosePokemon(int choice) { + switch ((PokemonChoice)choice) { + case PokemonChoice::CHARMANDER: + chosenPokemon = new Charmander(); + break; + case PokemonChoice::BULBASAUR: + chosenPokemon = new Bulbasaur(); + break; + case PokemonChoice::SQUIRTLE: + chosenPokemon = new Squirtle(); + break; + default: + chosenPokemon = new Pikachu(); + break; + } + std::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..0dbed8b9 --- /dev/null +++ b/Pokemon/player.h @@ -0,0 +1,17 @@ +#pragma once +#include +#include "Pokemon.h" + +using namespace std; + + +class Player { +public: + string name; + Pokemon* chosenPokemon; + + Player(); // Default constructor + Player(string p_name); // Parameterized constructor + + void choosePokemon(int choice); // Method to choose a Pokemon +}; 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(); +}; +