diff --git a/Pokemon/BattleManager.cpp b/Pokemon/BattleManager.cpp deleted file mode 100644 index 7fc35a1a..00000000 --- a/Pokemon/BattleManager.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#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 deleted file mode 100644 index 18a0ec07..00000000 --- a/Pokemon/Game.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#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 deleted file mode 100644 index 7b8af6cb..00000000 --- a/Pokemon/Game.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#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 deleted file mode 100644 index a6c89f98..00000000 --- a/Pokemon/Grass.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#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/Header/Battle/BattleManager.hpp b/Pokemon/Header/Battle/BattleManager.hpp new file mode 100644 index 00000000..c9e5e9ca --- /dev/null +++ b/Pokemon/Header/Battle/BattleManager.hpp @@ -0,0 +1,24 @@ +#pragma once +#include"../../Header/Battle/BattleState.hpp" +#include"../../Header/Pokemon/Pokemon.hpp" +#include"../../Header/Character/Player/Player.hpp" + +using namespace N_Character; +using namespace N_Player; + +namespace N_Battle +{ + + + class BattleManager { + public: + void startBattle(Player& player, N_Pokemon::Pokemon& wildPokemon); + private: + BattleState battleState; + + void battle(); + void handleBattleOutcome(); + void updateBattleState(); + }; +} + diff --git a/Pokemon/Header/Battle/BattleState.hpp b/Pokemon/Header/Battle/BattleState.hpp new file mode 100644 index 00000000..2895f38d --- /dev/null +++ b/Pokemon/Header/Battle/BattleState.hpp @@ -0,0 +1,13 @@ +#pragma once +#include"../../Header/Pokemon/Pokemon.hpp" + + +namespace N_Battle +{ + struct BattleState { + N_Pokemon::Pokemon* playerPokemon; + N_Pokemon::Pokemon* wildPokemon; + bool playerTurn; + bool battleOngoing; + }; +} diff --git a/Pokemon/Header/Battle/WildEncounterManager.hpp b/Pokemon/Header/Battle/WildEncounterManager.hpp new file mode 100644 index 00000000..ccc1dae6 --- /dev/null +++ b/Pokemon/Header/Battle/WildEncounterManager.hpp @@ -0,0 +1,18 @@ +#pragma once +#include +#include"../Pokemon/Pokemon.hpp" +#include"../Pokemon/Grass.hpp" + +//class Pokemon; +//struct Grass; + +using namespace N_Pokemon; + +namespace N_Battle +{ + class WildEncounterManager { + public: + WildEncounterManager(); + Pokemon getRandomPokemonFromGrass(const Grass& grass); + }; +} \ No newline at end of file diff --git a/Pokemon/Header/Character/Player/Player.hpp b/Pokemon/Header/Character/Player/Player.hpp new file mode 100644 index 00000000..1be15730 --- /dev/null +++ b/Pokemon/Header/Character/Player/Player.hpp @@ -0,0 +1,29 @@ +#pragma once +#include +#include +#include"../../../Header/Pokemon/PokemonType.hpp" +#include"../../../Header/Pokemon/PokemonChoice.hpp" +#include"../../../Header/Pokemon/Pokemon.hpp" +#include"../../../Header/Utility/Utility.hpp" +using namespace std; + +namespace N_Character +{ + namespace N_Player + { + class Player { + public: + string name; + N_Pokemon::Pokemon chosenPokemon; + + // Default constructor + Player(); + + // Parameterized constructor + Player(string p_name, N_Pokemon::Pokemon p_chosenPokemon); + + + void choosePokemon(int choice); + }; + } +} \ No newline at end of file diff --git a/Pokemon/Header/Character/ProfessorOak.hpp b/Pokemon/Header/Character/ProfessorOak.hpp new file mode 100644 index 00000000..0ae53d30 --- /dev/null +++ b/Pokemon/Header/Character/ProfessorOak.hpp @@ -0,0 +1,27 @@ +#pragma once +#include +#include // Include this header to use numeric_limits +#include +#include"../../Header/Utility/Utility.hpp" +#include"../../Header/Character/Player/Player.hpp" +using namespace std; + +namespace N_Character +{ + using namespace N_Player; + + 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/Header/Main/Game.hpp b/Pokemon/Header/Main/Game.hpp new file mode 100644 index 00000000..b6bb005e --- /dev/null +++ b/Pokemon/Header/Main/Game.hpp @@ -0,0 +1,22 @@ +#pragma once +#include "../Pokemon/Grass.hpp" +#include"../Character/Player/Player.hpp" + +using namespace N_Character; +using namespace N_Player; +using namespace N_Pokemon; + +namespace N_Game +{ + 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/Header/Pokemon/Grass.hpp b/Pokemon/Header/Pokemon/Grass.hpp new file mode 100644 index 00000000..a8f45181 --- /dev/null +++ b/Pokemon/Header/Pokemon/Grass.hpp @@ -0,0 +1,14 @@ +#pragma once +#include +#include +#include"../../Header/Pokemon/Pokemon.hpp" +using namespace std; + +namespace N_Pokemon +{ + struct Grass { + string environmentType; + vector wildPokemonList; + int encounterRate; + }; +} \ No newline at end of file diff --git a/Pokemon/Header/Pokemon/Pokemon.hpp b/Pokemon/Header/Pokemon/Pokemon.hpp new file mode 100644 index 00000000..603909ee --- /dev/null +++ b/Pokemon/Header/Pokemon/Pokemon.hpp @@ -0,0 +1,38 @@ +#pragma once +#include +#include +#include +#include"../../Header/Pokemon/PokemonType.hpp" +#include"../../Header/Pokemon/PokemonChoice.hpp" +using namespace std; + +namespace N_Pokemon +{ + class Pokemon { + public: + 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, int p_attackPower); + + // Copy constructor + Pokemon(const Pokemon& other); + + ~Pokemon(); + + void attack(Pokemon& target); + + void heal(); + + void takeDamage(int damage); + + bool isFainted() const; + }; +} \ No newline at end of file diff --git a/Pokemon/Header/Pokemon/PokemonChoice.hpp b/Pokemon/Header/Pokemon/PokemonChoice.hpp new file mode 100644 index 00000000..374d3765 --- /dev/null +++ b/Pokemon/Header/Pokemon/PokemonChoice.hpp @@ -0,0 +1,10 @@ +#pragma once +namespace N_Pokemon +{ + enum class PokemonChoice { + CHARMANDER = 1, + BULBASAUR, + SQUIRTLE, + PIKACHU // Default choice + }; +} \ No newline at end of file diff --git a/Pokemon/Header/Pokemon/PokemonType.hpp b/Pokemon/Header/Pokemon/PokemonType.hpp new file mode 100644 index 00000000..aa84dda3 --- /dev/null +++ b/Pokemon/Header/Pokemon/PokemonType.hpp @@ -0,0 +1,14 @@ +#pragma once +namespace N_Pokemon +{ + enum class PokemonType { + FIRE, + GRASS, + WATER, + ELECTRIC, + POISON, + BUG, + ROCK, + NORMAL // Added for the default constructor + }; +} \ No newline at end of file diff --git a/Pokemon/Header/Utility/Utility.hpp b/Pokemon/Header/Utility/Utility.hpp new file mode 100644 index 00000000..d9fd3543 --- /dev/null +++ b/Pokemon/Header/Utility/Utility.hpp @@ -0,0 +1,10 @@ +#pragma once +namespace N_Utility +{ + class Utility { + public: + static void clearConsole(); + static void waitForEnter(); + static void clearInputBuffer(); // New helper function + }; +} \ No newline at end of file diff --git a/Pokemon/Player.cpp b/Pokemon/Player.cpp deleted file mode 100644 index 8a810f40..00000000 --- a/Pokemon/Player.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "Player.hpp" -#include -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, 10); - break; - case PokemonChoice::BULBASAUR: - chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100, 10); - break; - case PokemonChoice::SQUIRTLE: - chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100, 10); - break; - default: - chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100, 10); - 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.hpp b/Pokemon/Player.hpp deleted file mode 100644 index 6089fdb6..00000000 --- a/Pokemon/Player.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include -#include -#include "PokemonType.hpp" -#include "PokemonChoice.hpp" -#include "Utility.hpp" -#include "Pokemon.hpp" -using namespace std; - -class Pokemon; - -class Player { -public: - string name; - Pokemon chosenPokemon; - - // Default constructor - Player(); - - // Parameterized constructor - Player(string p_name, Pokemon p_chosenPokemon); - - - void choosePokemon(int choice); -}; \ No newline at end of file diff --git a/Pokemon/Pokemon.hpp b/Pokemon/Pokemon.hpp deleted file mode 100644 index 397c4ce4..00000000 --- a/Pokemon/Pokemon.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include -#include -#include -#include "PokemonType.hpp" -#include "PokemonChoice.hpp" -using namespace std; - -class Pokemon { -public: - 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, int p_attackPower); - - // Copy constructor - Pokemon(const Pokemon& other); - - ~Pokemon(); - - 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 179166f2..bb4bc852 100644 --- a/Pokemon/Pokemon.vcxproj +++ b/Pokemon/Pokemon.vcxproj @@ -154,14 +154,14 @@ - - + + - - - - - + + + + + @@ -170,15 +170,17 @@ - - - - - - - - - + + + + + + + + + + + diff --git a/Pokemon/Pokemon.vcxproj.filters b/Pokemon/Pokemon.vcxproj.filters index dfa65b46..ae1c52fd 100644 --- a/Pokemon/Pokemon.vcxproj.filters +++ b/Pokemon/Pokemon.vcxproj.filters @@ -18,54 +18,60 @@ Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + + Header Files + + + Header Files + + Header Files diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.ilk b/Pokemon/Pokemon/x64/Debug/Pokemon.ilk index 9cefa76e..23796fb6 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 bb7827ce..f7764f8e 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.log +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.log @@ -1,3 +1,5 @@ - 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' + BattleManager.cpp + Game.cpp + Pokemon.cpp + Generating Code... + Pokemon.vcxproj -> C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\x64\Debug\Pokemon.exe 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 9f99b432..f02149a2 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 7c0dbf36..37f2db34 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 05356184..c0af07c7 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 0092d4e6..3e5c2ae6 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog @@ -1,8 +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\Src\Battle\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\Src\Main\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 +C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Src\Character\Player\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\Src\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\Src\Character\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\Src\Utility\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\Src\Battle\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 51a11d88..90fc3303 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 3a0e0f3c..c30c5cab 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/unsuccessfulbuild b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/unsuccessfulbuild deleted file mode 100644 index e69de29b..00000000 diff --git a/Pokemon/Pokemon/x64/Debug/vc143.idb b/Pokemon/Pokemon/x64/Debug/vc143.idb index 18aa72d1..9b516fe9 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 19c69f22..4ea25218 100644 Binary files a/Pokemon/Pokemon/x64/Debug/vc143.pdb and b/Pokemon/Pokemon/x64/Debug/vc143.pdb differ diff --git a/Pokemon/PokemonChoice.hpp b/Pokemon/PokemonChoice.hpp deleted file mode 100644 index d69dc90e..00000000 --- a/Pokemon/PokemonChoice.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -enum class PokemonChoice { - CHARMANDER = 1, - BULBASAUR, - SQUIRTLE, - PIKACHU // Default choice -}; \ No newline at end of file diff --git a/Pokemon/PokemonType.hpp b/Pokemon/PokemonType.hpp deleted file mode 100644 index f83d5fb6..00000000 --- a/Pokemon/PokemonType.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -enum class PokemonType { - FIRE, - GRASS, - WATER, - ELECTRIC, - POISON, - BUG, - ROCK, - NORMAL // Added for the default constructor -}; \ No newline at end of file diff --git a/Pokemon/ProfessorOak.hpp b/Pokemon/ProfessorOak.hpp deleted file mode 100644 index a4db7eef..00000000 --- a/Pokemon/ProfessorOak.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#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/Src/Battle/BattleManager.cpp b/Pokemon/Src/Battle/BattleManager.cpp new file mode 100644 index 00000000..519ba846 --- /dev/null +++ b/Pokemon/Src/Battle/BattleManager.cpp @@ -0,0 +1,63 @@ +#include +#include"../../Header/Pokemon/Pokemon.hpp" +#include"../../Header/Battle/BattleManager.hpp" +#include"../../Header/Utility/Utility.hpp" + +using namespace std; +using namespace N_Utility; + +namespace N_Battle +{ + void BattleManager::startBattle(Player& player, N_Pokemon::Pokemon& 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() { + while (battleState.battleOngoing) { + if (battleState.playerTurn) { + // Player's turn to attack + battleState.playerPokemon->attack(*battleState.wildPokemon); + } + 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(); + } + + handleBattleOutcome(); + } + + void BattleManager::handleBattleOutcome() { + if (battleState.playerPokemon->isFainted()) { + std::cout << battleState.playerPokemon->name << " has fainted! You lose the battle.\n"; + } + else { + std::cout << "You defeated the wild " << battleState.wildPokemon->name << "!\n"; + } + } + + + + void BattleManager::updateBattleState() { + if (battleState.playerPokemon->isFainted()) { + battleState.battleOngoing = false; + } + else if (battleState.wildPokemon->isFainted()) { + battleState.battleOngoing = false; + } + } +} + diff --git a/Pokemon/Src/Battle/WildEncounterManager.cpp b/Pokemon/Src/Battle/WildEncounterManager.cpp new file mode 100644 index 00000000..4309aefe --- /dev/null +++ b/Pokemon/Src/Battle/WildEncounterManager.cpp @@ -0,0 +1,19 @@ +#include "../../Header/Battle/WildEncounterManager.hpp" +#include"../../Header/Pokemon/Grass.hpp" +#include"../../Header/Pokemon/Pokemon.hpp" +#include +#include + +namespace N_Battle +{ + 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/Src/Character/Player/Player.cpp b/Pokemon/Src/Character/Player/Player.cpp new file mode 100644 index 00000000..9e5e7183 --- /dev/null +++ b/Pokemon/Src/Character/Player/Player.cpp @@ -0,0 +1,43 @@ +#pragma once +#include "../../../Header/Character/Player/Player.hpp" +#include"../../../Header/Pokemon/Pokemon.hpp" +#include"../../../Header/Utility/Utility.hpp" +#include +using namespace std; + +using namespace N_Utility; + +namespace N_Character +{ + namespace N_Player + { + Player::Player() { + name = "Trainer"; + chosenPokemon = N_Pokemon::Pokemon(); // Using the default Pokemon constructor + } + + Player::Player(string p_name, N_Pokemon::Pokemon p_chosenPokemon) { + name = p_name; + chosenPokemon = p_chosenPokemon; + } + + void Player::choosePokemon(int choice) { + switch ((N_Pokemon::PokemonChoice)choice) { + case N_Pokemon::PokemonChoice::CHARMANDER: + chosenPokemon = N_Pokemon::Pokemon("Charmander", N_Pokemon::PokemonType::FIRE, 100, 10); + break; + case N_Pokemon::PokemonChoice::BULBASAUR: + chosenPokemon = N_Pokemon::Pokemon("Bulbasaur", N_Pokemon::PokemonType::GRASS, 100, 10); + break; + case N_Pokemon::PokemonChoice::SQUIRTLE: + chosenPokemon = N_Pokemon::Pokemon("Squirtle", N_Pokemon::PokemonType::WATER, 100, 10); + break; + default: + chosenPokemon = N_Pokemon::Pokemon("Pikachu", N_Pokemon::PokemonType::ELECTRIC, 100, 10); + break; + } + cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; + Utility::waitForEnter(); + } + } +} \ No newline at end of file diff --git a/Pokemon/ProfessorOak.cpp b/Pokemon/Src/Character/ProfessorOak.cpp similarity index 95% rename from Pokemon/ProfessorOak.cpp rename to Pokemon/Src/Character/ProfessorOak.cpp index 988ca3c0..36bf7596 100644 --- a/Pokemon/ProfessorOak.cpp +++ b/Pokemon/Src/Character/ProfessorOak.cpp @@ -2,12 +2,14 @@ #include #include // Include this header to use numeric_limits #include -#include"Utility.hpp" -#include"Player.hpp" -#include"ProfessorOak.hpp" +#include"../../Header/Utility/Utility.hpp" +#include"../../Header/Character/ProfessorOak.hpp" using namespace std; - // Parameterized constructor +using namespace N_Utility; + +namespace N_Character +{ ProfessorOak::ProfessorOak(string p_name) { name = p_name; } void ProfessorOak::greetPlayer(Player& player) { @@ -33,7 +35,6 @@ using namespace std; "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"; @@ -53,9 +54,7 @@ using namespace std; Utility::waitForEnter(); } - // New method for the main quest conversation void ProfessorOak::explainMainQuest(Player& player) { - // Clear the console Utility::clearConsole(); cout << "Professor Oak: " << player.name @@ -110,4 +109,5 @@ using namespace std; 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 + } +} \ No newline at end of file diff --git a/Pokemon/Src/Main/Game.cpp b/Pokemon/Src/Main/Game.cpp new file mode 100644 index 00000000..b8de7cbf --- /dev/null +++ b/Pokemon/Src/Main/Game.cpp @@ -0,0 +1,73 @@ +#include "../../Header/Main/Game.hpp" +#include "../../Header/Character/Player/Player.hpp" +#include"../../Header/Pokemon/PokemonType.hpp" +#include"../../Header/Utility/Utility.hpp" +#include "../../Header/Battle/WildEncounterManager.hpp" +#include "../../Header/Battle/BattleManager.hpp" +#include +using namespace std; + +using namespace N_Battle; +using namespace N_Utility; +using namespace N_Character; +using namespace N_Player; +using namespace N_Pokemon; + +namespace N_Game +{ + Game::Game() { + forestGrass = {"Forest", {Pokemon {"Pidgey", PokemonType::NORMAL, 40, 10}, Pokemon {"Caterpie", PokemonType::BUG, 35, 10}}, 70 }; + + caveGrass = {"Cave", {Pokemon {"Zubat", PokemonType::POISON, 30, 10}, Pokemon {"Geodude", PokemonType::ROCK, 50, 10}}, 80}; + + shallowWater = {"Cave", {Pokemon {"Staryu", PokemonType::WATER, 40, 10}, Pokemon {"Tentacool", PokemonType::POISON, 40, 10}}, 80}; + } + + void Game::gameLoop(Player& player) { + BattleManager battleManager; + bool keepPlaying = true; + + while (keepPlaying) { + Utility::clearConsole(); + std::cout << "\nWhat would you like to do next, " << player.name << "?\n"; + std::cout << "1. Battle Wild Pokémon\n"; + std::cout << "2. Visit PokeCenter\n"; + std::cout << "3. Challenge Gyms\n"; + std::cout << "4. Enter Pokémon League\n"; + std::cout << "5. Quit\n"; + std::cout << "Enter your choice: "; + int choice; + std::cin >> choice; + + Utility::clearInputBuffer(); + + switch (choice) { + case 1: { + WildEncounterManager encounterManager; + Pokemon wildPokemon = encounterManager.getRandomPokemonFromGrass(forestGrass); + battleManager.startBattle(player, wildPokemon); + break; + } + case 2: { + std::cout << "You head to the PokeCenter.\n"; + player.chosenPokemon.heal(); + std::cout << player.chosenPokemon.name << "'s health is fully restored!\n"; + break; + } + case 5: { + keepPlaying = false; + break; + } + default: { + std::cout << "That's not a valid choice. Try again!\n"; + break; + } + } + + Utility::waitForEnter(); + } + + std::cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; + } +} + diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Src/Pokemon/Pokemon.cpp similarity index 73% rename from Pokemon/Pokemon.cpp rename to Pokemon/Src/Pokemon/Pokemon.cpp index 60ff4eda..151059ff 100644 --- a/Pokemon/Pokemon.cpp +++ b/Pokemon/Src/Pokemon/Pokemon.cpp @@ -2,32 +2,40 @@ #include #include #include -#include "Pokemon.hpp" +#include "../../Header/Pokemon/Pokemon.hpp" using namespace std; +namespace N_Pokemon +{ Pokemon::Pokemon() { name = "Unknown"; type = PokemonType::NORMAL; health = 50; + attackPower = 10; + maxHealth = 100; } Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health, int p_attackPower) { name = p_name; type = p_type; health = p_health; + attackPower = p_attackPower; + maxHealth = 100; } Pokemon::Pokemon(const Pokemon& other) { name = other.name; type = other.type; health = other.health; + attackPower = other.attackPower; + maxHealth = 100; } 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"; + cout << name << " attacks " << target.name << " for " << damage << " damage!\n"; target.takeDamage(damage); } @@ -46,4 +54,6 @@ using namespace std; void Pokemon::heal() { health = maxHealth; - } \ No newline at end of file + } +} + \ No newline at end of file diff --git a/Pokemon/Src/Utility/Utility.cpp b/Pokemon/Src/Utility/Utility.cpp new file mode 100644 index 00000000..d677d8fe --- /dev/null +++ b/Pokemon/Src/Utility/Utility.cpp @@ -0,0 +1,27 @@ +#pragma once +#include"../../Header/Utility/Utility.hpp" +#include +#include +using namespace std; + +namespace N_Utility +{ + 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.cpp b/Pokemon/Utility.cpp deleted file mode 100644 index 37ef8c2f..00000000 --- a/Pokemon/Utility.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include"Utility.hpp" -#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.hpp b/Pokemon/Utility.hpp deleted file mode 100644 index 0b41e490..00000000 --- a/Pokemon/Utility.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -class Utility { -public: - static void clearConsole(); - static void waitForEnter(); - static void clearInputBuffer(); // New helper function -}; \ No newline at end of file diff --git a/Pokemon/WildEncounterManager.cpp b/Pokemon/WildEncounterManager.cpp deleted file mode 100644 index 6f9fe9dc..00000000 --- a/Pokemon/WildEncounterManager.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#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 deleted file mode 100644 index e5e5110d..00000000 --- a/Pokemon/WildEncounterManager.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#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 22f3693b..8a4c9886 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,9 +1,13 @@ #include #include #include -#include "Game.hpp" -#include "Player.hpp" -#include "ProfessorOak.hpp" +#include "Header/Main/Game.hpp" +#include "Header/Character/Player/Player.hpp" +#include "Header/Character/ProfessorOak.hpp" + +using namespace N_Character; +using namespace N_Game; +using namespace N_Player; int main() { diff --git a/Pokemon/x64/Debug/Pokemon.pdb b/Pokemon/x64/Debug/Pokemon.pdb index 427c9602..ec70645e 100644 Binary files a/Pokemon/x64/Debug/Pokemon.pdb and b/Pokemon/x64/Debug/Pokemon.pdb differ