diff --git a/Pokemon/Header/Battle/BattleManager.hpp b/Pokemon/Header/Battle/BattleManager.hpp index a7e32b30..1a6ddec6 100644 --- a/Pokemon/Header/Battle/BattleManager.hpp +++ b/Pokemon/Header/Battle/BattleManager.hpp @@ -12,7 +12,7 @@ namespace N_Battle public: void startBattle(Player* player, N_Pokemon::Pokemon* wildPokemon); private: - BattleState* battleState; + BattleState battleState; void battle(); void handleBattleOutcome(); diff --git a/Pokemon/Header/Battle/WildEncounterManager.hpp b/Pokemon/Header/Battle/WildEncounterManager.hpp index 66c04a17..e8c540be 100644 --- a/Pokemon/Header/Battle/WildEncounterManager.hpp +++ b/Pokemon/Header/Battle/WildEncounterManager.hpp @@ -1,6 +1,5 @@ #pragma once #include -#include"../Pokemon/Pokemon.hpp" #include"../Pokemon/Grass.hpp" //class Pokemon; @@ -13,6 +12,6 @@ namespace N_Battle class WildEncounterManager { public: WildEncounterManager(); - Pokemon getRandomPokemonFromGrass(const Grass* grass); + 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 index 53472610..591ced8f 100644 --- a/Pokemon/Header/Character/Player/Player.hpp +++ b/Pokemon/Header/Character/Player/Player.hpp @@ -1,9 +1,11 @@ #pragma once #include #include -#include"../../../Header/Pokemon/PokemonType.hpp" -#include"../../../Header/Pokemon/PokemonChoice.hpp" #include"../../../Header/Pokemon/Pokemon.hpp" +#include"../../../Header/Pokemon/Pokemons/Charmander.hpp" +#include"../../../Header/Pokemon/Pokemons/Squirtle.hpp" +#include"../../../Header/Pokemon/Pokemons/Pikachu.hpp" +#include"../../../Header/Pokemon/Pokemons/Bulbasaur.hpp" #include"../../../Header/Utility/Utility.hpp" using namespace std; @@ -20,7 +22,7 @@ namespace N_Character Player(); // Parameterized constructor - Player(string p_name, N_Pokemon::Pokemon* p_chosenPokemon); + Player(string p_name); void choosePokemon(int choice); diff --git a/Pokemon/Header/Main/Game.hpp b/Pokemon/Header/Main/Game.hpp index b9502dfc..95450f4a 100644 --- a/Pokemon/Header/Main/Game.hpp +++ b/Pokemon/Header/Main/Game.hpp @@ -1,6 +1,12 @@ #pragma once #include "../Pokemon/Grass.hpp" -#include"../Character/Player/Player.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"../../Header/Pokemon/Pokemons/Pidgey.hpp" +#include"../../Header/Pokemon/Pokemons/Caterpie.hpp" using namespace N_Character; using namespace N_Player; @@ -12,11 +18,14 @@ namespace N_Game public: Game(); + ~Game(); void gameLoop(Player* player); private: - Grass* forestGrass; - Grass* caveGrass; - Grass* shallowWater; + Grass forestGrass; + Pokemon* wildPokemon; + + //Grass* caveGrass; + //Grass* shallowWater; }; } \ No newline at end of file diff --git a/Pokemon/Header/Pokemon/Move.hpp b/Pokemon/Header/Pokemon/Move.hpp new file mode 100644 index 00000000..392f5fe1 --- /dev/null +++ b/Pokemon/Header/Pokemon/Move.hpp @@ -0,0 +1,15 @@ +#pragma once +#include +using namespace std; + +namespace N_Pokemon { + struct Move { + string name; + int power; + + Move(const string& moveName, int movePower) { + name = moveName; + power = movePower; + } + }; +} \ No newline at end of file diff --git a/Pokemon/Header/Pokemon/Pokemon.hpp b/Pokemon/Header/Pokemon/Pokemon.hpp index 406057f9..d0b2c572 100644 --- a/Pokemon/Header/Pokemon/Pokemon.hpp +++ b/Pokemon/Header/Pokemon/Pokemon.hpp @@ -2,10 +2,15 @@ #include #include #include -#include"../../Header/Pokemon/PokemonType.hpp" -#include"../../Header/Pokemon/PokemonChoice.hpp" +#include +#include"../Utility/Utility.hpp" +#include"../Pokemon/Move.hpp" +#include"../Pokemon/PokemonType.hpp" +#include"../Pokemon/PokemonChoice.hpp" using namespace std; +struct Move; + namespace N_Pokemon { class Pokemon { @@ -15,14 +20,14 @@ namespace N_Pokemon Pokemon(); // Parameterized constructor - Pokemon(std::string p_name, PokemonType p_type, int p_health, int p_attackPower); + Pokemon(std::string p_name, PokemonType p_type, int p_health, vector p_moves); // Copy constructor Pokemon(const Pokemon* other); ~Pokemon(); - void attack(Pokemon* target); + virtual void attack(Move selectedMove, Pokemon* target) = 0; void heal(); @@ -35,11 +40,20 @@ namespace N_Pokemon void setName(string _name); + void selectAndUseMove(Pokemon* target); + + void reduceAttackPower(int reducedDamage); + protected: string name; PokemonType type; int health; int maxHealth; - int attackPower; + vector moves; + int attackBonus = 0; + + void printAvailableMoves(); + int selectMove(); + void useMove(Move selectedMove, Pokemon* target); }; } \ No newline at end of file diff --git a/Pokemon/Header/Pokemon/Pokemons/Bulbasaur.hpp b/Pokemon/Header/Pokemon/Pokemons/Bulbasaur.hpp index 0bfeb20e..6e63cae6 100644 --- a/Pokemon/Header/Pokemon/Pokemons/Bulbasaur.hpp +++ b/Pokemon/Header/Pokemon/Pokemons/Bulbasaur.hpp @@ -7,10 +7,7 @@ namespace N_Pokemon { class Bulbasaur : public Pokemon { public: Bulbasaur(); - - private: - int leafBlade_dmg; - void leafBlade(Pokemon* target); + void attack(Move selectedMove, Pokemon* target) override; }; } diff --git a/Pokemon/Header/Pokemon/Pokemons/Caterpie.hpp b/Pokemon/Header/Pokemon/Pokemons/Caterpie.hpp index 59d4254e..76ea43ee 100644 --- a/Pokemon/Header/Pokemon/Pokemons/Caterpie.hpp +++ b/Pokemon/Header/Pokemon/Pokemons/Caterpie.hpp @@ -7,10 +7,7 @@ namespace N_Pokemon { class Caterpie : public Pokemon { public: Caterpie(); - - private: - int bugBite_dmg; - void bugBite(Pokemon* target); + void attack(Move selectedMove, Pokemon* target) override; }; } diff --git a/Pokemon/Header/Pokemon/Pokemons/Charmander.hpp b/Pokemon/Header/Pokemon/Pokemons/Charmander.hpp index d7f7ea45..3a1d0feb 100644 --- a/Pokemon/Header/Pokemon/Pokemons/Charmander.hpp +++ b/Pokemon/Header/Pokemon/Pokemons/Charmander.hpp @@ -7,10 +7,7 @@ namespace N_Pokemon { class Charmander : public Pokemon { public: Charmander(); - - private: - int flameThrower_dmg; - void flameThrower(Pokemon* target); + void attack(Move selectedMove, Pokemon* target) override; }; } diff --git a/Pokemon/Header/Pokemon/Pokemons/Pidgey.hpp b/Pokemon/Header/Pokemon/Pokemons/Pidgey.hpp index b19647ac..232b5a4f 100644 --- a/Pokemon/Header/Pokemon/Pokemons/Pidgey.hpp +++ b/Pokemon/Header/Pokemon/Pokemons/Pidgey.hpp @@ -7,10 +7,7 @@ namespace N_Pokemon { class Pidgey : public Pokemon { public: Pidgey(); - - private: - int wingAttack_dmg; - void WingAttack(Pokemon* target); + void attack(Move selectedMove, Pokemon* target) override; }; } } \ No newline at end of file diff --git a/Pokemon/Header/Pokemon/Pokemons/Pikachu.hpp b/Pokemon/Header/Pokemon/Pokemons/Pikachu.hpp index 98d73ccf..6742f078 100644 --- a/Pokemon/Header/Pokemon/Pokemons/Pikachu.hpp +++ b/Pokemon/Header/Pokemon/Pokemons/Pikachu.hpp @@ -7,10 +7,7 @@ namespace N_Pokemon { class Pikachu : public Pokemon { public: Pikachu(); - - private: - int thunderShock_dmg; - void thunderShock(Pokemon* target); + void attack(Move selectedMove, Pokemon* target) override; }; } diff --git a/Pokemon/Header/Pokemon/Pokemons/Squirtle.hpp b/Pokemon/Header/Pokemon/Pokemons/Squirtle.hpp new file mode 100644 index 00000000..e3396672 --- /dev/null +++ b/Pokemon/Header/Pokemon/Pokemons/Squirtle.hpp @@ -0,0 +1,14 @@ +#pragma once +#include "../Pokemon.hpp" + +namespace N_Pokemon { + namespace N_Pokemons { + + class Squirtle : public Pokemon { + public: + Squirtle(); + void attack(Move selectedMove, Pokemon* target) override; + }; + + } +} \ No newline at end of file diff --git a/Pokemon/Header/Pokemon/Pokemons/Squitle.hpp b/Pokemon/Header/Pokemon/Pokemons/Squitle.hpp deleted file mode 100644 index d00fe6eb..00000000 --- a/Pokemon/Header/Pokemon/Pokemons/Squitle.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "../Pokemon.hpp" - -namespace N_Pokemon { - namespace N_Pokemons { - - class Squitle : public Pokemon { - public: - Squitle(); - - private: - int waterGun_dmg; - void waterGun(Pokemon* target); - }; - - } -} \ No newline at end of file diff --git a/Pokemon/Pokemon.vcxproj b/Pokemon/Pokemon.vcxproj index 32c20e06..2025189d 100644 --- a/Pokemon/Pokemon.vcxproj +++ b/Pokemon/Pokemon.vcxproj @@ -1,4 +1,4 @@ - + @@ -181,6 +181,7 @@ + @@ -188,7 +189,7 @@ - + diff --git a/Pokemon/Pokemon.vcxproj.filters b/Pokemon/Pokemon.vcxproj.filters index cf5d2230..c78e9074 100644 --- a/Pokemon/Pokemon.vcxproj.filters +++ b/Pokemon/Pokemon.vcxproj.filters @@ -107,7 +107,10 @@ Header Files - + + Header Files + + Header Files diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.ilk b/Pokemon/Pokemon/x64/Debug/Pokemon.ilk index 766b24a8..5e0ccccf 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 ed0dade3..d08c1e76 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.log +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.log @@ -1,8 +1,17 @@ - Bulbasaur.cpp + BattleManager.cpp + Game.cpp +C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\Src\Battle\BattleManager.cpp(25,44): error C2660: 'N_Pokemon::Pokemon::attack': function does not take 1 arguments +C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\Src\Battle\BattleManager.cpp(29,42): error C2660: 'N_Pokemon::Pokemon::attack': function does not take 1 arguments + main.cpp + Player.cpp + Pokemon.cpp + ProfessorOak.cpp + Bulbasaur.cpp Charmander.cpp Pidgey.cpp Caterpie.cpp Pikachu.cpp Squirtle.cpp + WildEncounterManager.cpp +C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\Src\Battle\WildEncounterManager.cpp(12,19): warning C4244: 'argument': conversion from 'time_t' to 'unsigned int', possible loss of data 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 5a5862ff..a80912cd 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 59c027d7..3bc408ee 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 0c8a0b40..2741ce59 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/Pokemon.lastbuildstate b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Pokemon.lastbuildstate index beed68b5..8b6bc897 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Pokemon.lastbuildstate +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Pokemon.lastbuildstate @@ -1,2 +1,2 @@ PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.40.33807:TargetPlatformVersion=10.0.22621.0: -Debug|x64|C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\| +Debug|x64|C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\| 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 75d42c75..5a658e15 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 new file mode 100644 index 00000000..e69de29b diff --git a/Pokemon/Pokemon/x64/Debug/vc143.idb b/Pokemon/Pokemon/x64/Debug/vc143.idb index 03a2dbe1..37a6639c 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 c614a301..6ac01f19 100644 Binary files a/Pokemon/Pokemon/x64/Debug/vc143.pdb and b/Pokemon/Pokemon/x64/Debug/vc143.pdb differ diff --git a/Pokemon/Src/Battle/BattleManager.cpp b/Pokemon/Src/Battle/BattleManager.cpp index 58810502..870243e9 100644 --- a/Pokemon/Src/Battle/BattleManager.cpp +++ b/Pokemon/Src/Battle/BattleManager.cpp @@ -9,30 +9,31 @@ 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; + battleState.playerPokemon = player->chosenPokemon; + battleState.wildPokemon = wildPokemon; + battleState.playerTurn = true; // Player starts first + battleState.battleOngoing = true; std::cout << "A wild " << wildPokemon->getName() << " appeared!\n"; battle(); } - + //className* ptrname; declaration + //ptrname->name; void BattleManager::battle() { - while (battleState->battleOngoing) { - if (battleState->playerTurn) { + while (battleState.battleOngoing) { + if (battleState.playerTurn) { // Player's turn to attack - battleState->playerPokemon->attack(battleState->wildPokemon); + battleState.playerPokemon->selectAndUseMove(battleState.wildPokemon); } else { // Wild Pokémon's turn to attack - battleState->wildPokemon->attack(battleState->playerPokemon); + battleState.wildPokemon->selectAndUseMove(battleState.playerPokemon); } // Update the battle state after the turn updateBattleState(); // Switch turns - battleState->playerTurn = !battleState->playerTurn; + battleState.playerTurn = !battleState.playerTurn; Utility::waitForEnter(); } @@ -41,22 +42,22 @@ namespace N_Battle } void BattleManager::handleBattleOutcome() { - if (battleState->playerPokemon->isFainted()) { - std::cout << battleState->playerPokemon->getName() << " has fainted! You lose the battle.\n"; + if (battleState.playerPokemon->isFainted()) { + std::cout << battleState.playerPokemon->getName() << " has fainted! You lose the battle.\n"; } else { - std::cout << "You defeated the wild " << battleState->wildPokemon->getName() << "!\n"; + std::cout << "You defeated the wild " << battleState.wildPokemon->getName() << "!\n"; } } void BattleManager::updateBattleState() { - if (battleState->playerPokemon->isFainted()) { - battleState->battleOngoing = false; + if (battleState.playerPokemon->isFainted()) { + battleState.battleOngoing = false; } - else if (battleState->wildPokemon->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 index 5e8f7bda..008a5205 100644 --- a/Pokemon/Src/Battle/WildEncounterManager.cpp +++ b/Pokemon/Src/Battle/WildEncounterManager.cpp @@ -4,16 +4,18 @@ #include #include +//using namespace N_Pokemon; + namespace N_Battle { WildEncounterManager::WildEncounterManager() { srand(time(0)); } - Pokemon WildEncounterManager::getRandomPokemonFromGrass(const Grass* grass) + Pokemon* WildEncounterManager::getRandomPokemonFromGrass(const Grass &grass) { - int randomIndex = rand() % grass->wildPokemonList.size(); - Pokemon WildPokemon = grass->wildPokemonList[randomIndex]; + 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 index e9d0df3d..c8685e2d 100644 --- a/Pokemon/Src/Character/Player/Player.cpp +++ b/Pokemon/Src/Character/Player/Player.cpp @@ -1,12 +1,15 @@ #pragma once #include "../../../Header/Character/Player/Player.hpp" -#include"../../../Header/Pokemon/Pokemon.hpp" -#include"../../../Header/Utility/Utility.hpp" #include +#include"../../../Header/Pokemon/Pokemons/Charmander.hpp" +#include"../../../Header/Pokemon/Pokemons/Squirtle.hpp" +#include"../../../Header/Pokemon/Pokemons/Pikachu.hpp" +#include"../../../Header/Pokemon/Pokemons/Bulbasaur.hpp" using namespace std; using namespace N_Utility; using namespace N_Pokemon; +using namespace N_Pokemons; namespace N_Character { @@ -14,27 +17,26 @@ namespace N_Character { Player::Player() { name = "Trainer"; - Pokemon* chosenPokemon = new Pokemon(); // Using the default Pokemon constructor + chosenPokemon = nullptr; } - Player::Player(string p_name, Pokemon* p_chosenPokemon) { + Player::Player(string p_name) { name = p_name; - chosenPokemon = p_chosenPokemon; } void Player::choosePokemon(int choice) { switch ((N_Pokemon::PokemonChoice)choice) { case N_Pokemon::PokemonChoice::CHARMANDER: - Pokemon* chosenPokemon = new Pokemon("Charmander", N_Pokemon::PokemonType::FIRE, 100, 10); + chosenPokemon = new Charmander(); break; case N_Pokemon::PokemonChoice::BULBASAUR: - Pokemon* chosenPokemon = new Pokemon("Bulbasaur", N_Pokemon::PokemonType::GRASS, 100, 10); + chosenPokemon = new Bulbasaur(); break; case N_Pokemon::PokemonChoice::SQUIRTLE: - Pokemon* chosenPokemon = new Pokemon("Squirtle", N_Pokemon::PokemonType::WATER, 100, 10); + chosenPokemon = new Squirtle(); break; default: - Pokemon* chosenPokemon = new Pokemon("Pikachu", N_Pokemon::PokemonType::ELECTRIC, 100, 10); + chosenPokemon = new Pikachu(); break; } cout << "Player " << name << " chose " << chosenPokemon->getName() << "!\n"; diff --git a/Pokemon/Src/Main/Game.cpp b/Pokemon/Src/Main/Game.cpp index 1a8a03fd..943504bb 100644 --- a/Pokemon/Src/Main/Game.cpp +++ b/Pokemon/Src/Main/Game.cpp @@ -1,9 +1,4 @@ #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; @@ -11,25 +6,26 @@ using namespace N_Battle; using namespace N_Utility; using namespace N_Character; using namespace N_Player; -using namespace N_Pokemon; +using namespace N_Pokemons; namespace N_Game { Game::Game() { - Grass* forestGrass = new Grass({"Forest", {Pokemon {"Pidgey", PokemonType::NORMAL, 40, 10}, Pokemon {"Caterpie", PokemonType::BUG, 35, 10}}, 70 }); + forestGrass = {"Forest", {new Pidgey() , new Caterpie()}, 70}; - Grass* caveGrass = new Grass({"Cave", {Pokemon {"Zubat", PokemonType::POISON, 30, 10}, Pokemon {"Geodude", PokemonType::ROCK, 50, 10}}, 80}); + //Grass* caveGrass = new Grass({"Cave", {Pokemon {"Zubat", PokemonType::POISON, 30, 10}, Pokemon {"Geodude", PokemonType::ROCK, 50, 10}}, 80}); - Grass* shallowWater = new Grass({"water", {Pokemon {"Staryu", PokemonType::WATER, 40, 10}, Pokemon {"Tentacool", PokemonType::POISON, 40, 10}}, 80}); + //Grass* shallowWater = new Grass({"water", {Pokemon {"Staryu", PokemonType::WATER, 40, 10}, Pokemon {"Tentacool", PokemonType::POISON, 40, 10}}, 80}); } void Game::gameLoop(Player* player) { BattleManager battleManager; bool keepPlaying = true; + WildEncounterManager encounterManager; while (keepPlaying) { Utility::clearConsole(); - std::cout << "\nWhat would you like to do next, " << player.name << "?\n"; + 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"; @@ -43,8 +39,8 @@ namespace N_Game switch (choice) { case 1: { - WildEncounterManager encounterManager; - Pokemon* wildPokemon = new Pokemon(encounterManager.getRandomPokemonFromGrass(forestGrass)); + wildPokemon = encounterManager.getRandomPokemonFromGrass(forestGrass); + battleManager.startBattle(player, wildPokemon); break; } @@ -69,5 +65,10 @@ namespace N_Game std::cout << "Goodbye, " << player->name << "! Thanks for playing!\n"; } + + Game::~Game() { + delete(wildPokemon); + } + } diff --git a/Pokemon/Src/Pokemon/Pokemon.cpp b/Pokemon/Src/Pokemon/Pokemon.cpp index b090871e..51c5e912 100644 --- a/Pokemon/Src/Pokemon/Pokemon.cpp +++ b/Pokemon/Src/Pokemon/Pokemon.cpp @@ -5,21 +5,22 @@ #include "../../Header/Pokemon/Pokemon.hpp" using namespace std; +using namespace N_Utility; + 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) { + Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health, vector p_moves) { name = p_name; type = p_type; health = p_health; - attackPower = p_attackPower; + moves = p_moves; maxHealth = 100; } @@ -27,16 +28,62 @@ namespace N_Pokemon name = other->name; type = other->type; health = other->health; - attackPower = other->attackPower; maxHealth = 100; } + void Pokemon::selectAndUseMove(Pokemon* target) { + printAvailableMoves(); + + int choice = selectMove(); + Move selectedMove = moves[choice - 1]; + + useMove(selectedMove, target); + } + + 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::waitForEnter(); + + cout << "...\n"; + Utility::waitForEnter(); + + if (target->isFainted()) + cout << target->name << " fainted!\n"; + else + cout << target->name << " has " << target->health << " HP left.\n"; + } + + Pokemon::~Pokemon() { } - void Pokemon::attack(Pokemon* target) { - int damage = attackPower; // Use attack power for damage calculation - cout << name << " attacks " << target->name << " for " << damage << " damage!\n"; - target->takeDamage(damage); + void Pokemon::attack(Move selectedMove, Pokemon* target) { + target->takeDamage((selectedMove.power + attackBonus)); } void Pokemon::takeDamage(int damage) @@ -65,5 +112,10 @@ namespace N_Pokemon { Pokemon::name = _name; } + + void Pokemon::reduceAttackPower(int reducedDamage) + { + attackBonus -= reducedDamage; + } } \ No newline at end of file diff --git a/Pokemon/Src/Pokemon/Pokemons/Bulbasaur.cpp b/Pokemon/Src/Pokemon/Pokemons/Bulbasaur.cpp index 6b02986e..9fcbe12b 100644 --- a/Pokemon/Src/Pokemon/Pokemons/Bulbasaur.cpp +++ b/Pokemon/Src/Pokemon/Pokemons/Bulbasaur.cpp @@ -7,14 +7,25 @@ namespace N_Pokemon { using namespace std; - Bulbasaur::Bulbasaur() : Pokemon("Bulbasaur", PokemonType::ELECTRIC, 100, 20) + Bulbasaur::Bulbasaur() : Pokemon("Bulbasaur", PokemonType::GRASS, 100, {Move("Leaf Blade", 25), Move("Vine Whip", 20) }) { - leafBlade_dmg = 15; + } - void Bulbasaur::leafBlade(Pokemon* target) { - cout << name << " uses Thunder Shock on " << target->getName() << "!\n"; - target->takeDamage(leafBlade_dmg); + 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->getName() << " dodged the second hit!\n"; + } } } } \ No newline at end of file diff --git a/Pokemon/Src/Pokemon/Pokemons/Caterpie.cpp b/Pokemon/Src/Pokemon/Pokemons/Caterpie.cpp index 717c5539..6e6b0499 100644 --- a/Pokemon/Src/Pokemon/Pokemons/Caterpie.cpp +++ b/Pokemon/Src/Pokemon/Pokemons/Caterpie.cpp @@ -7,14 +7,20 @@ namespace N_Pokemon { using namespace std; - Caterpie::Caterpie() : Pokemon("Pikachu", PokemonType::ELECTRIC, 100, 20) + Caterpie::Caterpie() : Pokemon("Caterpie", PokemonType::BUG, 100, {Move("Bug Bite", 20), Move("STICKY WEB", 10)}) { - bugBite_dmg = 15; } - void Caterpie::bugBite(Pokemon* target) { - cout << name << " uses Wing Attack on " << target->getName() << "!\n"; - target->takeDamage(bugBite_dmg); + 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->getName() << "'s next attack will be reduced by " << reducedDamage << " damage!\n"; + } } } } \ No newline at end of file diff --git a/Pokemon/Src/Pokemon/Pokemons/Charmander.cpp b/Pokemon/Src/Pokemon/Pokemons/Charmander.cpp index 340a1b48..be5dc5ff 100644 --- a/Pokemon/Src/Pokemon/Pokemons/Charmander.cpp +++ b/Pokemon/Src/Pokemon/Pokemons/Charmander.cpp @@ -7,14 +7,20 @@ namespace N_Pokemon { using namespace std; - Charmander::Charmander() : Pokemon("Charmander", PokemonType::ELECTRIC, 100, 20) + Charmander::Charmander() : Pokemon("Charmander", PokemonType::FIRE, 100, {Move("Flame Thrower", 25), Move("Ember", 20)}) { - flameThrower_dmg = 15; } - void Charmander::flameThrower(Pokemon* target) { - cout << name << " uses Thunder Shock on " << target->getName() << "!\n"; - target->takeDamage(flameThrower_dmg); + 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"; + N_Utility::Utility::waitForEnter(); + } } } } \ No newline at end of file diff --git a/Pokemon/Src/Pokemon/Pokemons/Pidgey.cpp b/Pokemon/Src/Pokemon/Pokemons/Pidgey.cpp index 05e78691..2f932d7b 100644 --- a/Pokemon/Src/Pokemon/Pokemons/Pidgey.cpp +++ b/Pokemon/Src/Pokemon/Pokemons/Pidgey.cpp @@ -7,14 +7,23 @@ namespace N_Pokemon { using namespace std; - Pidgey::Pidgey() : Pokemon("Pidgey", PokemonType::NORMAL, 100, 20) + Pidgey::Pidgey() : Pokemon("Pidgey", PokemonType::NORMAL, 100, {Move("Wing Attack",15), Move("Peck", 10)}) { - wingAttack_dmg = 15; } - void Pidgey::WingAttack(Pokemon* target) { - cout << name << " uses Wing Attack on " << target->getName() << "!\n"; - target->takeDamage(wingAttack_dmg); + 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"; + N_Battle::BattleManager::stopBattle(); + N_Utility::Utility::waitForEnter(); + } + } } } } \ No newline at end of file diff --git a/Pokemon/Src/Pokemon/Pokemons/Pikachu.cpp b/Pokemon/Src/Pokemon/Pokemons/Pikachu.cpp index e4158b0a..809ca549 100644 --- a/Pokemon/Src/Pokemon/Pokemons/Pikachu.cpp +++ b/Pokemon/Src/Pokemon/Pokemons/Pikachu.cpp @@ -7,14 +7,25 @@ namespace N_Pokemon { using namespace std; - Pikachu::Pikachu() : Pokemon("Pikachu", PokemonType::ELECTRIC, 100, 20) + Pikachu::Pikachu() : Pokemon("Pikachu", PokemonType::ELECTRIC, 100, {Move("Thunder Blot", 25), Move("Iron tail", 20), Move("Quick Attack", 15)}) { - thunderShock_dmg = 15; } - void Pikachu::thunderShock(Pokemon* target) { - cout << name << " uses Thunder Shock on " << target->getName() << "!\n"; - target->takeDamage(thunderShock_dmg); + 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/Src/Pokemon/Pokemons/Squirtle.cpp b/Pokemon/Src/Pokemon/Pokemons/Squirtle.cpp index e4ac9dff..fdee6deb 100644 --- a/Pokemon/Src/Pokemon/Pokemons/Squirtle.cpp +++ b/Pokemon/Src/Pokemon/Pokemons/Squirtle.cpp @@ -1,4 +1,4 @@ -#include "../../../Header/Pokemon/Pokemons/Squitle.hpp" +#include "../../../Header/Pokemon/Pokemons/Squirtle.hpp" #include "../../../Header/Pokemon/PokemonType.hpp" #include @@ -7,14 +7,26 @@ namespace N_Pokemon { using namespace std; - Squitle::Squitle() : Pokemon("Squitle", PokemonType::ELECTRIC, 100, 20) + Squirtle::Squirtle() : Pokemon("Squirtle", PokemonType::WATER, 100, {Move("Water gun", 20), Move("Tackle", 15)}) { - waterGun_dmg = 15; + } - void Squitle::waterGun(Pokemon* target) { - cout << name << " uses Thunder Shock on " << target->getName() << "!\n"; - target->takeDamage(waterGun_dmg); + 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/main.cpp b/Pokemon/main.cpp index a59d719f..751f4035 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -22,5 +22,8 @@ int main() { Game* game = new Game(); game->gameLoop(player); + delete(professor); + delete(player); + return 0; } \ No newline at end of file diff --git a/Pokemon/x64/Debug/Pokemon.pdb b/Pokemon/x64/Debug/Pokemon.pdb index a7bc4521..0136e9f8 100644 Binary files a/Pokemon/x64/Debug/Pokemon.pdb and b/Pokemon/x64/Debug/Pokemon.pdb differ