diff --git a/Pokemon/Pokemon/BattleManager.cpp b/Pokemon/Pokemon/BattleManager.cpp new file mode 100644 index 0000000..becb099 --- /dev/null +++ b/Pokemon/Pokemon/BattleManager.cpp @@ -0,0 +1,49 @@ +#include "BattleManager.hpp" +#include "Pokemons.hpp" +#include "Player.hpp" +#include + +using namespace std; + +using namespace N_Utility; + +void BattleManager::StartBattle(Player& player, Pokemons* wild_pokemon) +{ + battle_state.player_pokemon = player.captured_pokemon; + battle_state.wild_pokemon = wild_pokemon; + battle_state.player_turn = true; + battle_state.battle_unfinished = true; + cout << "A wild " << wild_pokemon->name << " appeared!\n"; + Battle(*player.captured_pokemon, wild_pokemon); +} + +void BattleManager::Battle(Pokemons& player_pokemon, Pokemons* wild_pokemon) +{ + while (battle_state.battle_unfinished) + { + if (battle_state.player_turn && battle_state.player_pokemon->CanAttack()) + battle_state.player_pokemon->SelectAndExecuteMove(wild_pokemon); + else if (battle_state.wild_pokemon->CanAttack()); + battle_state.wild_pokemon->SelectAndExecuteMove(battle_state.player_pokemon); + UpdateBattleState(); + battle_state.player_turn = !battle_state.player_turn; + Utility::WaitForEnter(); + } + BattleOutcome(); +} + +void BattleManager::UpdateBattleState() +{ + if (battle_state.player_pokemon->IsFainted()) + battle_state.battle_unfinished = false; + else if (battle_state.wild_pokemon->IsFainted()) + battle_state.battle_unfinished = false; +} + +void BattleManager::BattleOutcome() +{ + if(battle_state.player_pokemon->IsFainted()) + cout << "Oh no! " << battle_state.player_pokemon->name << " fainted! You need to visit the PokeCenter.\n"; + else if(battle_state.wild_pokemon->IsFainted()) + cout << "Congratulations!!! " << battle_state.player_pokemon->name << " is victorious! Keep an eye on the health of your Pokemon.\n"; +} \ No newline at end of file diff --git a/Pokemon/Pokemon/BattleManager.hpp b/Pokemon/Pokemon/BattleManager.hpp new file mode 100644 index 0000000..6867e30 --- /dev/null +++ b/Pokemon/Pokemon/BattleManager.hpp @@ -0,0 +1,15 @@ +#include "BattleState.hpp" + +class Player; +class Pokemons; + +class BattleManager +{ + public: + void StartBattle(Player& player, Pokemons *wild_pokemon); + private: + BattleState battle_state; + void Battle(Pokemons &player_pokemon, Pokemons* wild_pokemon); + void BattleOutcome(); + void UpdateBattleState(); +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/BattleState.hpp b/Pokemon/Pokemon/BattleState.hpp new file mode 100644 index 0000000..53e5aec --- /dev/null +++ b/Pokemon/Pokemon/BattleState.hpp @@ -0,0 +1,9 @@ +class Pokemons; + +struct BattleState +{ + Pokemons *player_pokemon; + Pokemons *wild_pokemon; + bool player_turn; + bool battle_unfinished; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Bulbasaur.cpp b/Pokemon/Pokemon/Bulbasaur.cpp new file mode 100644 index 0000000..9523b13 --- /dev/null +++ b/Pokemon/Pokemon/Bulbasaur.cpp @@ -0,0 +1,34 @@ +#include "Bulbasaur.hpp" +#include "PokemonType.hpp" +#include "Utility.hpp" +#include + +using namespace N_Utility; + +//void Bulbasaur::VineWhip(Pokemons* target_pokemon) +//{ +// cout << name << " uses Vinewhip on " << target_pokemon->name << "!!!\n"; +// target_pokemon->TakeDamage(attack_power); +// N_Utility::Utility::WaitForEnter(); +// if (target_pokemon->IsFainted()) +// cout << target_pokemon->name << " fainted!!!\n"; +// else +// cout << target_pokemon->name << " has " << target_pokemon->health << "HP left."; +//} + +void Bulbasaur::Attack(PokemonMove selected_move, Pokemons* target_pokemon) +{ + Pokemons::Attack(selected_move, target_pokemon); + if (selected_move.move_name == "Vine Whip") + { + int second_hit_chance = rand() % 2; + if (second_hit_chance == 1) + { + Pokemons::Attack(selected_move, target_pokemon); + cout << name << " hits again with a second " << selected_move.move_name << "!!!\n"; + } + else + cout << target_pokemon->name << " dodged the second hit!!!\n"; + } + //VineWhip(target_pokemon); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Bulbasaur.hpp b/Pokemon/Pokemon/Bulbasaur.hpp new file mode 100644 index 0000000..94a9e4c --- /dev/null +++ b/Pokemon/Pokemon/Bulbasaur.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "Pokemons.hpp" +#include "PokemonMove.hpp" +#include "PokemonType.hpp" + +class Bulbasaur :public Pokemons +{ +public: + Bulbasaur() : Pokemons("Bulbasaur", Pokemon_Types::Grass_Type, 100, 100, {{"Vine Whip", 25},{"Tackle", 10}}) {}; +private: + //void VineWhip(Pokemons* target_pokemon); + + void Attack(PokemonMove selected_move, Pokemons* target_pokemon) override; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Caterpie.cpp b/Pokemon/Pokemon/Caterpie.cpp new file mode 100644 index 0000000..a58504d --- /dev/null +++ b/Pokemon/Pokemon/Caterpie.cpp @@ -0,0 +1,30 @@ +#include "Caterpie.hpp" +#include "PokemonType.hpp" +#include "Utility.hpp" +#include "PokemonMove.hpp" +#include + +using namespace N_Utility; + +//void Caterpie::BugBite(Pokemons* target_pokemon) +//{ +// cout << name << " uses Bugbite on " << target_pokemon->name << "!!!\n"; +// target_pokemon->TakeDamage(attack_power); +// N_Utility::Utility::WaitForEnter(); +// if (target_pokemon->IsFainted()) +// cout << target_pokemon->name << " fainted!!!\n"; +// else +// cout << target_pokemon->name << " has " << target_pokemon->health << "HP left."; +//} + +void Caterpie::Attack(PokemonMove selected_move, Pokemons* target_pokemon) +{ + Pokemons::Attack(selected_move, target_pokemon); + if (selected_move.move_name == "Sticky Web") + { + target_pokemon->ReduceAttackPower(5); + cout << target_pokemon->name << "'s next attack will be reduced by 5 damage!\n"; + N_Utility::Utility::WaitForEnter(); + } + //BugBite(target_pokemon); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Caterpie.hpp b/Pokemon/Pokemon/Caterpie.hpp new file mode 100644 index 0000000..f5e27c7 --- /dev/null +++ b/Pokemon/Pokemon/Caterpie.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "Pokemons.hpp" +#include "PokemonMove.hpp" +#include "PokemonType.hpp" + +class Caterpie :public Pokemons +{ + public: + Caterpie() : Pokemons("Caterpie", Pokemon_Types::Bug_Type, 100, 100, {{"Sticky Web",10},{"Bug Bite",25}}) {}; + private: + //void BugBite(Pokemons* target_pokemon); + + void Attack(PokemonMove selected_move, Pokemons* target_pokemon) override; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Charmander.cpp b/Pokemon/Pokemon/Charmander.cpp new file mode 100644 index 0000000..b30035f --- /dev/null +++ b/Pokemon/Pokemon/Charmander.cpp @@ -0,0 +1,29 @@ +#include "Charmander.hpp" +#include "PokemonType.hpp" +#include "Utility.hpp" +#include + +using namespace N_Utility; + +//void Charmander::FlameBurst(Pokemons* target_pokemon) +//{ +// cout << name << " uses Flameburst on " << target_pokemon->name << "!!!\n"; +// target_pokemon->TakeDamage(attack_power); +// N_Utility::Utility::WaitForEnter(); +// if (target_pokemon->IsFainted()) +// cout << target_pokemon->name << " fainted!!!\n"; +// else +// cout << target_pokemon->name << " has " << target_pokemon->health << "HP left."; +//} + +void Charmander::Attack(PokemonMove selected_move, Pokemons* target_pokemon) +{ + Pokemons::Attack(selected_move, target_pokemon); + if (selected_move.move_name == "Blazing Charge") + { + this->TakeDamage(10); + cout << name << " takes 10 recoil damage from the Blazing Charge!!!\n"; + N_Utility::Utility::WaitForEnter(); + } + //FlameBurst(target_pokemon); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Charmander.hpp b/Pokemon/Pokemon/Charmander.hpp new file mode 100644 index 0000000..14cc0b9 --- /dev/null +++ b/Pokemon/Pokemon/Charmander.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "Pokemons.hpp" +#include "PokemonMove.hpp" +#include "PokemonType.hpp" + +class Charmander :public Pokemons +{ +public: + Charmander() : Pokemons("Charmander", Pokemon_Types::Fire_Type, 100, 100, {{"Flameburst",35},{"Blazing Charge",70}}) {}; +private: + //void FlameBurst(Pokemons* target_pokemon); + + void Attack(PokemonMove selected_move, Pokemons* target_pokemon) override; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Game.cpp b/Pokemon/Pokemon/Game.cpp new file mode 100644 index 0000000..03a3234 --- /dev/null +++ b/Pokemon/Pokemon/Game.cpp @@ -0,0 +1,87 @@ +#include "Game.hpp" +#include "Player.hpp" +#include "PokemonType.hpp" +#include "Utility.hpp" +#include "WildPokemonEncounterHandler.hpp" +#include "BattleManager.hpp" +#include "Pidgey.hpp" +#include "Zubat.hpp" +#include "Caterpie.hpp" +#include + +using namespace std; + +using namespace N_Utility; + +Game::Game() +{ + forest_grass = { + "Forest", + {new Pidgey(),new Zubat(),new Caterpie()}, + 70 + }; +} + +void Game::GameLoop(Player &player) +{ + BattleManager* battle_manager = new BattleManager(); + int choice; + bool keepPlaying = true; + while (keepPlaying) + { + Utility::ClearConsole(); + cout << "\nWhat would you like to do next, " << player.name << "?\n"; + cout << "1. Battle Wild Pokemon\n"; + cout << "2. Visit PokeCenter\n"; + cout << "3. Challenge Gyms\n"; + cout << "4. Enter Pokemon League\n"; + cout << "5. Quit\n"; + cout << "Enter your choice: "; + cin >> choice; + Utility::ClearInputBuffer(); + switch (choice) + { + case 1: + { + // What pokemon will appear randomly while walking around. + WildPokemonEncounterHandler encounters; + Pokemons* encountered_pokemon = encounters.GetRandomWildPokemonFromGrass(forest_grass); + battle_manager->StartBattle(player,encountered_pokemon); + break; + } + case 2: + { + player.captured_pokemon->Heal(); + cout << player.captured_pokemon->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 Pokemon 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 Pokemon 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"; + delete(battle_manager); +} + +Game::~Game() +{ + +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Game.hpp b/Pokemon/Pokemon/Game.hpp new file mode 100644 index 0000000..367b163 --- /dev/null +++ b/Pokemon/Pokemon/Game.hpp @@ -0,0 +1,14 @@ +#include "Grass.hpp" + +class Player; + +class Game +{ + private: + Grass forest_grass; + Pokemons* wild_pokemon; + public: + Game(); + ~Game(); + void GameLoop(Player &player); +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Grass.hpp b/Pokemon/Pokemon/Grass.hpp new file mode 100644 index 0000000..4056d13 --- /dev/null +++ b/Pokemon/Pokemon/Grass.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include +#include +#include "Pokemons.hpp" + +using namespace std; + +struct Grass +{ + string environment; + vector wild_pokemons_list; + int pokemon_encounter_rate; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/IStatusEffect.hpp b/Pokemon/Pokemon/IStatusEffect.hpp new file mode 100644 index 0000000..d3b1923 --- /dev/null +++ b/Pokemon/Pokemon/IStatusEffect.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +using namespace std; + +class Pokemons; + +class IStatusEffect +{ +public: + virtual void ApplyEffect(Pokemons* target_pokemin) = 0; + + virtual string GetEffectName(Pokemons* target_pokemon) = 0; + + virtual bool TurnEndEffect(Pokemons* target_pokemon) = 0; + + virtual void ClearEffect(Pokemons* target_pokemon) = 0; + + virtual ~IStatusEffect() = default; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/ParalyzedEffect.cpp b/Pokemon/Pokemon/ParalyzedEffect.cpp new file mode 100644 index 0000000..4ed02cc --- /dev/null +++ b/Pokemon/Pokemon/ParalyzedEffect.cpp @@ -0,0 +1,41 @@ +#include "ParalyzedEffect.hpp" +#include "IStatusEffect.hpp" +#include "Pokemons.hpp" +#include + +void ParalyzedEffect::ApplyEffect(Pokemons* target_pokemon) +{ + cout << target_pokemon->name << " is paralyzed!!!\n" << target_pokemon->name << " may not be able to move!!!\n"; + //effect lasts for 1 to 3 turns randomly. + turns_left = rand() % 3 + 1; +} + +string ParalyzedEffect::GetEffectName(Pokemons* target_pokemon) +{ + return "Paralyzed"; +} + +bool ParalyzedEffect::TurnEndEffect(Pokemons* target_pokemon) +{ + if (turns_left <= 0) + { + ClearEffect(target_pokemon); + return true; + } + turns_left--; + //randon number between 0 and 3. + int paralysis_chance = rand() % 4; + if (paralysis_chance == 0) + { + cout << target_pokemon->name << " is paralyzed!!!\n" << target_pokemon->name << " cannot move!!!\n"; + return false; + } + cout << target_pokemon->name << " shakes off the paralysis momentarily and can move!!!\n"; + return true; +} + +void ParalyzedEffect::ClearEffect(Pokemons* target_pokemon) +{ + cout << target_pokemon->name << " is no longer paralyzed!!!\n"; + target_pokemon->ClearEffect(); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/ParalyzedEffect.hpp b/Pokemon/Pokemon/ParalyzedEffect.hpp new file mode 100644 index 0000000..f43aa5f --- /dev/null +++ b/Pokemon/Pokemon/ParalyzedEffect.hpp @@ -0,0 +1,16 @@ +#include "IStatusEffect.hpp" + + +class ParalyzedEffect : public IStatusEffect +{ +private: + int turns_left; +public: + void ApplyEffect(Pokemons* target_pokemin) override; + + string GetEffectName(Pokemons* target_pokemon) override; + + bool TurnEndEffect(Pokemons* target_pokemon) override; + + void ClearEffect(Pokemons* target_pokemon) override; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Pidgey.cpp b/Pokemon/Pokemon/Pidgey.cpp new file mode 100644 index 0000000..22fd594 --- /dev/null +++ b/Pokemon/Pokemon/Pidgey.cpp @@ -0,0 +1,21 @@ +#include "Pidgey.hpp" +#include "PokemonType.hpp" +#include "Utility.hpp" +#include "PokemonMove.hpp" +#include "BattleManager.hpp" +#include + +using namespace N_Utility; + +void Pidgey::Attack(PokemonMove seleccted_move, Pokemons* target_pokemon) +{ + Pokemons::Attack(seleccted_move, target_pokemon); + if (seleccted_move.move_name == "Gust") + { + if (rand() % 100 < 20) + { + cout << this->name << " blew " << target_pokemon->name << " away!!!\n"; + target_pokemon->health = 0; + } + } +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Pidgey.hpp b/Pokemon/Pokemon/Pidgey.hpp new file mode 100644 index 0000000..c988a2b --- /dev/null +++ b/Pokemon/Pokemon/Pidgey.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "Pokemons.hpp" +#include "PokemonMove.hpp" +#include "PokemonType.hpp" + +class Pidgey :public Pokemons +{ + public: + Pidgey() : Pokemons("Pidgey", Pokemon_Types::Normal_Type, 100, 100, {{"Wing Attack",35},{"Gust",15}}) {}; + private: + //void WingAttack(Pokemons* target_pokemon); + + void Attack(PokemonMove selected_move, Pokemons* target_pokemon) override; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Pikachu.cpp b/Pokemon/Pokemon/Pikachu.cpp new file mode 100644 index 0000000..f2d4f1b --- /dev/null +++ b/Pokemon/Pokemon/Pikachu.cpp @@ -0,0 +1,32 @@ +#include "Pikachu.hpp" +#include "PokemonType.hpp" +#include "Utility.hpp" +#include "PokemonMove.hpp" +#include + +using namespace N_Utility; + +using namespace std; + +void Pikachu::Attack(PokemonMove selected_move, Pokemons* target_pokemon) +{ + if (selected_move.move_name == "Thunderbolt") + { + if (rand() % 100 < 80) + { + Pokemons::Attack(selected_move, target_pokemon); + cout << this->name << " hit " << target_pokemon->name << " successfully!!!\n"; + } + else + { + cout << this->name << " missed " << target_pokemon->name << "!!!\n"; + } + } + else + Pokemons::Attack(selected_move, target_pokemon); + if (selected_move.move_name == "Thundershock") + { + if (target_pokemon->CanApplyEffect()) + target_pokemon->ApplyEffect(StatusEffectType::Paralyzed); + } +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Pikachu.hpp b/Pokemon/Pokemon/Pikachu.hpp new file mode 100644 index 0000000..67f5888 --- /dev/null +++ b/Pokemon/Pokemon/Pikachu.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "Pokemons.hpp" +#include "PokemonMove.hpp" +#include "PokemonType.hpp" + +class Pikachu : public Pokemons +{ + public: + Pikachu() : Pokemons("Pikachu", Pokemon_Types::Electric_Type, 100, 100, { {"Thundershock",15},{"Thunderbolt",80}}) {}; + private: + //void ThunderShock(Pokemons* target_pokemon); + + void Attack(PokemonMove selected_move, Pokemons* target_pokemon) override; +}; diff --git a/Pokemon/Pokemon/Player.cpp b/Pokemon/Pokemon/Player.cpp new file mode 100644 index 0000000..4cd28bb --- /dev/null +++ b/Pokemon/Pokemon/Player.cpp @@ -0,0 +1,51 @@ +#include "Player.hpp" +#include "Pokemons.hpp" +#include "Pikachu.hpp" +#include "Charmander.hpp" +#include "Bulbasaur.hpp" +#include "Squirtle.hpp" +#include + +using namespace std; + +using namespace N_Utility; + +Player::Player() +{ + +} + +//Player::Player(string playerName, Pokemons playerCapturedPokemon) +//{ +// Player::name = playerName; +// Player::captured_pokemon = playerCapturedPokemon; +//} + +Player::Player(string playerName) +{ + Player::name = playerName; +} +void Player::ChosenPokemon(int choice) +{ + switch ((Pokemon_Choice)choice) + { + case Pokemon_Choice::Charmander: + //Player::captured_pokemon = Pokemons("Charmander", Pokemon_Types::Fire_Type, 100, 100, 20); + Player::captured_pokemon = new Charmander(); + break; + case Pokemon_Choice::Bulbasaur: + //Player::captured_pokemon = Pokemons("Bulbasaur", Pokemon_Types::Grass_Type, 100, 100, 10); + Player::captured_pokemon = new Bulbasaur(); + break; + case Pokemon_Choice::Squirtle: + //Player::captured_pokemon = Pokemons("Squirtle", Pokemon_Types::Water_Type, 100, 100, 15); + Player::captured_pokemon = new Squirtle(); + break; + default: + //Player::captured_pokemon = Pokemons("Pikachu", Pokemon_Types::Electric_Type, 100, 100, 20); + Player::captured_pokemon = new Pikachu(); + break; + } + cout << name << " chose " << captured_pokemon->name << "\n"; + Utility::WaitForEnter(); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Player.hpp b/Pokemon/Pokemon/Player.hpp new file mode 100644 index 0000000..2fb122b --- /dev/null +++ b/Pokemon/Pokemon/Player.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include "PokemonType.hpp" +#include "PokemonChoice.hpp" +#include "Utility.hpp" +#include "Pokemons.hpp" + +using namespace std; + +class Player +{ + public: + string name; + Pokemons* captured_pokemon; + + Player(); + //Player(string playerName, Pokemons playerCapturedPokemon); + Player(string playerName); + void ChosenPokemon(int choice); +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Pokemon.cpp b/Pokemon/Pokemon/Pokemon.cpp index 70d0cba..636818a 100644 --- a/Pokemon/Pokemon/Pokemon.cpp +++ b/Pokemon/Pokemon/Pokemon.cpp @@ -1,20 +1,30 @@ -// Pokemon.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - #include +#include +#include "PokemonType.hpp" +#include "PokemonChoice.hpp" +#include "Utility.hpp" +#include "Player.hpp" +#include "Game.hpp" +#include "ProfessorOak.hpp" + +using namespace std; + +using namespace N_Utility; int main() { - std::cout << "Hello World!\n"; -} + Game* loop = new Game(); + ProfessorOak* professor = new ProfessorOak("Professor Oak"); + Player* player = new Player(); + + professor->GreetPlayer(*player); + professor->PlayerIntro(*player); + professor->FirstPokemon(*player); + professor->ExplainMainQuest(*player); -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu + loop->GameLoop(*player); -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file + delete(professor); + delete(player); + delete(loop); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Pokemon.vcxproj b/Pokemon/Pokemon/Pokemon.vcxproj index 3cb6302..15141e2 100644 --- a/Pokemon/Pokemon/Pokemon.vcxproj +++ b/Pokemon/Pokemon/Pokemon.vcxproj @@ -127,7 +127,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pokemon/Pokemon/Pokemon.vcxproj.filters b/Pokemon/Pokemon/Pokemon.vcxproj.filters index 8e148e6..33a1f7e 100644 --- a/Pokemon/Pokemon/Pokemon.vcxproj.filters +++ b/Pokemon/Pokemon/Pokemon.vcxproj.filters @@ -18,5 +18,112 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + 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 + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/Pokemon/Pokemon/PokemonChoice.hpp b/Pokemon/Pokemon/PokemonChoice.hpp new file mode 100644 index 0000000..0abd64e --- /dev/null +++ b/Pokemon/Pokemon/PokemonChoice.hpp @@ -0,0 +1,9 @@ +#pragma once + +enum class Pokemon_Choice +{ + Charmander = 1, + Bulbasaur, + Squirtle, + Pikachu +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/PokemonMove.hpp b/Pokemon/Pokemon/PokemonMove.hpp new file mode 100644 index 0000000..70bcae9 --- /dev/null +++ b/Pokemon/Pokemon/PokemonMove.hpp @@ -0,0 +1,17 @@ +#pragma once +#include +#include "Pokemons.hpp" + +using namespace std; + +struct PokemonMove +{ + string move_name; + int move_power; + + PokemonMove(const string& pokemon_move_name, int pokemon_move_power) + { + move_name = pokemon_move_name; + move_power = pokemon_move_power; + } +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/PokemonType.hpp b/Pokemon/Pokemon/PokemonType.hpp new file mode 100644 index 0000000..2e8afd0 --- /dev/null +++ b/Pokemon/Pokemon/PokemonType.hpp @@ -0,0 +1,23 @@ +#pragma once + +enum class Pokemon_Types +{ + Normal_Type, + Fire_Type, + Water_Type, + Electric_Type, + Grass_Type, + Ice_Type, + Fighting_Type, + Poison_Type, + Ground_Type, + Flying_Type, + Psychic_Type, + Bug_Type, + Rock_Type, + Ghost_Type, + Dragon_Type, + Dark_Type, + Steel_Type, + Fairy_Type +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Pokemons.cpp b/Pokemon/Pokemon/Pokemons.cpp new file mode 100644 index 0000000..a9524e6 --- /dev/null +++ b/Pokemon/Pokemon/Pokemons.cpp @@ -0,0 +1,159 @@ +#include +#include "Pokemons.hpp" +#include "PokemonType.hpp" +#include "PokemonMove.hpp" +#include "Utility.hpp" +#include "IStatusEffect.hpp" +#include "StatusEffectType.hpp" +#include "ParalyzedEffect.hpp" + +using namespace std; + +using namespace N_Utility; + +Pokemons::Pokemons() +{ + Pokemons::name = "Unknown"; + Pokemons::type = Pokemon_Types::Normal_Type; + Pokemons::health = 50; + Pokemons::max_health = 100; + Pokemons::attack_power = 10; + Pokemons::pokemon_moves = {}; +} + +Pokemons::Pokemons(string poke_name, Pokemon_Types poke_type, int poke_health, int poke_max_health, vector pokemon_moves_list) +{ + Pokemons::name = poke_name; + Pokemons::type = poke_type; + Pokemons::health = poke_health; + Pokemons::max_health = poke_max_health; + Pokemons::pokemon_moves = pokemon_moves_list; +} + +Pokemons::Pokemons(const Pokemons& other) +{ + Pokemons::name = other.name; + Pokemons::type = other.type; + Pokemons::health = other.health; + Pokemons::max_health = other.max_health; + Pokemons::pokemon_moves = other.pokemon_moves; +} + +Pokemons::~Pokemons() +{ + +} + +void Pokemons::Attack(PokemonMove pokemon_move, Pokemons* target_pokemon) +{ + target_pokemon->TakeDamage(pokemon_move.move_power); +} + +void Pokemons::TakeDamage(int damage) +{ + health -= damage; + if (health < 0) + health = 0; +} + +bool Pokemons::IsFainted() const +{ + return health <= 0; +} + +void Pokemons::Heal() +{ + health = max_health; +} + +int Pokemons::GetHealth() +{ + return health; +} + +void Pokemons::SetHealth(int updated_health) +{ + health = updated_health; +} + +void Pokemons::PrintAllAvailableMoves() +{ + cout << "Availablle Moves:\n"; + for (size_t i = 0; i < pokemon_moves.size(); ++i) + cout << i + 1 << ": " << pokemon_moves[i].move_name << " -> " << "Power: " << pokemon_moves[i].move_power << endl; +} + +int Pokemons::SelectMove() +{ + int choice; + cout << "Choose a move: "; + cin >> choice; + while (choice < 1 || choice > static_cast(pokemon_moves.size())) + { + cout << "Invalid Choice. Try Again"; + cin >> choice; + } + return choice; +} + +void Pokemons::ExecuteMove(PokemonMove selected_move, Pokemons* target_pokemon) +{ + cout << name << " used " << selected_move.move_name << "!!!\n"; + Attack(selected_move, target_pokemon); + N_Utility::Utility::WaitForEnter(); + cout << ". . . \n"; + N_Utility::Utility::WaitForEnter(); + if (target_pokemon->IsFainted()) + cout << target_pokemon->name << " fainted!!!\n"; + else + cout << target_pokemon->name << " has " << target_pokemon->health << "HP left.\n"; +} + +void Pokemons::SelectAndExecuteMove(Pokemons* target_pokemon) +{ + PrintAllAvailableMoves(); + int move = SelectMove(); + ExecuteMove(pokemon_moves[move-1], target_pokemon); +} + +void Pokemons::ReduceAttackPower(int power) +{ + for (int i = 0; i < pokemon_moves.size(); i++) + { + pokemon_moves[i].move_power -= power; + if (pokemon_moves[i].move_power < 0) + pokemon_moves[i].move_power = 0; + } +} + +bool Pokemons::CanAttack() +{ + if (applied_effect == nullptr) + return true; + else + return applied_effect->TurnEndEffect(this); +} + +bool Pokemons::CanApplyEffect() +{ + return applied_effect == nullptr; +} + +void Pokemons::ApplyEffect(StatusEffectType status_to_apply) +{ + switch (status_to_apply) + { + case StatusEffectType::Paralyzed: + applied_effect = new ParalyzedEffect(); + applied_effect->ApplyEffect(this); + break; + default: + applied_effect = nullptr; + } +} + +void Pokemons::ClearEffect() +{ + applied_effect = nullptr; +} + diff --git a/Pokemon/Pokemon/Pokemons.h b/Pokemon/Pokemon/Pokemons.h new file mode 100644 index 0000000..e69de29 diff --git a/Pokemon/Pokemon/Pokemons.hpp b/Pokemon/Pokemon/Pokemons.hpp new file mode 100644 index 0000000..279b12b --- /dev/null +++ b/Pokemon/Pokemon/Pokemons.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include +#include +#include "IStatusEffect.hpp" +#include "StatusEffectType.hpp" + +using namespace std; + +enum class Pokemon_Types; +struct PokemonMove; + +class Pokemons +{ +public: + string name; + Pokemon_Types type; + int health; + int max_health; + int attack_power; + vector pokemon_moves; + IStatusEffect* applied_effect; + + Pokemons(); + Pokemons(string poke_name, Pokemon_Types poke_type, int poke_health, int poke_max_health, vector poke_moves_list); + Pokemons(const Pokemons& other); + ~Pokemons(); + virtual void Attack(PokemonMove pokemon_move, Pokemons* target_pokemon) = 0; + void TakeDamage(int damage); + bool IsFainted() const; + void Heal(); + int GetHealth(); + void SetHealth(int updated_health); + void SelectAndExecuteMove(Pokemons* target_pokemon); + void ReduceAttackPower(int power); + bool CanAttack(); + void ApplyEffect(StatusEffectType effect_to_apply); + void ClearEffect(); + bool CanApplyEffect(); + +protected: + int SelectMove(); + void PrintAllAvailableMoves(); + void ExecuteMove(PokemonMove selected_move, Pokemons* target_pokemon); +}; diff --git a/Pokemon/Pokemon/ProfessorOak.cpp b/Pokemon/Pokemon/ProfessorOak.cpp new file mode 100644 index 0000000..da16a90 --- /dev/null +++ b/Pokemon/Pokemon/ProfessorOak.cpp @@ -0,0 +1,80 @@ +#include "ProfessorOak.hpp" +#include "Player.hpp" +#include + +using namespace std; +using namespace N_Utility; + +ProfessorOak::ProfessorOak(string prof_name) +{ + name = prof_name; +} + +void ProfessorOak::PlayerIntro(Player& player) +{ + cout << name << ": First, tell me what is your name?\n"; + getline(cin, player.name); + cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; + Utility::WaitForEnter(); + cout << name << ": You must be eager to start your adventure. But first, you will need a Pokemon of your own!\n"; + Utility::WaitForEnter(); +} + +void ProfessorOak::GreetPlayer(Player& player) +{ + cout << name << ": Welcome to the world of Pokemon! I am Professor Oak.\n"; + Utility::WaitForEnter(); + cout << name << ": 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::FirstPokemon(Player& player) +{ + int choice; + cout << name << ": I have three Pokemon here with me. They are all quite feisty!\n"; + Utility::WaitForEnter(); + cout << name << ": Choose wisely...\n"; + cout << name << ": 1. Charmander - The fire type. A real hothead!\n"; + cout << name << ": 2. Bulbasaur - The grass type. Calm and collected!\n"; + cout << name << ": 3. Squirtle - The water type. Cool as a cucumber!\n"; + + cout << name << ": So, which one will it be? Enter the number of your choice:"; + cin >> choice; + player.ChosenPokemon(choice); + + cout << "Professor Oak: " << player.captured_pokemon->name << " and you, " << player.name << ", are going to be the best of friends!\n"; + Utility::WaitForEnter(); +} + +void ProfessorOak::ExplainMainQuest(Player player) +{ + Utility::ClearConsole(); + cout << name << ": Ok, " << player.name << ", I am about to explain you about your upcoming grand adventure.\n"; + Utility::WaitForEnter(); + cout << name << ": You see, becoming a Pokemon Master is no easy feat, it takes courage, wisdom, and a bit of luck.\n"; + Utility::WaitForEnter(); + cout << name << ": Your mission, should you choose to accept it (and trust me, you really do not have a choice) is to collect all the Pokemon Badges and conquer the Pokemon League. \n"; + Utility::WaitForEnter(); + cout << player.name << ": Wait... that sounds a lot like every other Pokemon game out there.\n"; + Utility::WaitForEnter(); + cout << name << ": Shhh! Don't break the fourth wall " << player.name << "! This is serious business.\n"; + Utility::WaitForEnter(); + cout << name << ": To achieve this, you will need to battle wild Pokemon, challenge gym leaders, and of course, keep your Pokemon healthy at the PokeCenter.\n"; + Utility::WaitForEnter(); + cout << name << ": Along the way, you'll capture new Pokemon 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 << player.name << ": Sounds like a walk in the park... right?\n"; + Utility::WaitForEnter(); + cout << name << ": Hah! Thats 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 << name << ": So, what do you say? Are you ready to become the next Pokemon Champion?\n"; + Utility::WaitForEnter(); + cout << player.name << ": Ready as I will ever be, Professor!\n"; + Utility::WaitForEnter(); + cout << name << ": That is the spirit! Now, your journey begins.\n"; + Utility::WaitForEnter(); + cout << name << ": But first... let's just pretend I didn't forget to set up the actual game loop... Ahem, onwards!\n"; + Utility::WaitForEnter(); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/ProfessorOak.hpp b/Pokemon/Pokemon/ProfessorOak.hpp new file mode 100644 index 0000000..ce8cb58 --- /dev/null +++ b/Pokemon/Pokemon/ProfessorOak.hpp @@ -0,0 +1,16 @@ +#include + +using namespace std; + +class Player; + +class ProfessorOak +{ +public: + string name; + ProfessorOak(string prof_name); + void GreetPlayer(Player& player); + void PlayerIntro(Player& player); + void FirstPokemon(Player& player); + void ExplainMainQuest(Player player); +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Squirtle.cpp b/Pokemon/Pokemon/Squirtle.cpp new file mode 100644 index 0000000..278f95f --- /dev/null +++ b/Pokemon/Pokemon/Squirtle.cpp @@ -0,0 +1,31 @@ +#include "Squirtle.hpp" +#include "PokemonType.hpp" +#include "PokemonMove.hpp" +#include "Utility.hpp" +#include + +using namespace N_Utility; + +//void Squirtle::WaterSplash(Pokemons* target_pokemon) +//{ +// cout << name << " uses Watersplash on " << target_pokemon->name << "!!!\n"; +// target_pokemon->TakeDamage(attack_power); +// N_Utility::Utility::WaitForEnter(); +// if (target_pokemon->IsFainted()) +// cout << target_pokemon->name << " fainted!!!\n"; +// else +// cout << target_pokemon->name << " has " << target_pokemon->health << "HP left."; +//} + +void Squirtle::Attack(PokemonMove selected_move, Pokemons* target_pokemon) +{ + Pokemons::Attack(selected_move, target_pokemon); + if (selected_move.move_name == "Rapid Spin") + { + int hits = (rand() % 4) + 2; + for (int i = 0; i < hits; ++i) + Pokemons::Attack(selected_move, target_pokemon); + cout << this->name << " hit " << target_pokemon->name << " " << hits << " times!!!\n"; + } + //WaterSplash(target_pokemon); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Squirtle.hpp b/Pokemon/Pokemon/Squirtle.hpp new file mode 100644 index 0000000..4744615 --- /dev/null +++ b/Pokemon/Pokemon/Squirtle.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "Pokemons.hpp" +#include "PokemonMove.hpp" +#include "PokemonType.hpp" + +class Squirtle :public Pokemons +{ +public: + Squirtle() : Pokemons("Squirtle", Pokemon_Types::Water_Type, 100, 100, { {"Watersplash",35},{"Rapid Spin",5}}) {}; +private: + //void WaterSplash(Pokemons* target_pokemon); + + void Attack(PokemonMove selected_move, Pokemons* target_pokemon) override; +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/StatusEffectType.hpp b/Pokemon/Pokemon/StatusEffectType.hpp new file mode 100644 index 0000000..69683b8 --- /dev/null +++ b/Pokemon/Pokemon/StatusEffectType.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "Pokemons.hpp" + +enum class StatusEffectType +{ + Paralyzed, + Sleeping, + Burned, + Poisoned +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Utility.cpp b/Pokemon/Pokemon/Utility.cpp new file mode 100644 index 0000000..9b1c285 --- /dev/null +++ b/Pokemon/Pokemon/Utility.cpp @@ -0,0 +1,21 @@ +#include "Utility.hpp" +#include + +using namespace std; + +using namespace N_Utility; + +void Utility::WaitForEnter() +{ + cin.get(); +} + +void Utility::ClearConsole() +{ + system("cls"); +} + +void Utility::ClearInputBuffer() +{ + cin.ignore(numeric_limits::max(), '\n'); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Utility.hpp b/Pokemon/Pokemon/Utility.hpp new file mode 100644 index 0000000..2d064db --- /dev/null +++ b/Pokemon/Pokemon/Utility.hpp @@ -0,0 +1,12 @@ +#pragma once + +namespace N_Utility +{ + class Utility + { + public: + static void WaitForEnter(); + static void ClearConsole(); + static void ClearInputBuffer(); + }; +} \ No newline at end of file diff --git a/Pokemon/Pokemon/WildPokemonEncounterHandler.cpp b/Pokemon/Pokemon/WildPokemonEncounterHandler.cpp new file mode 100644 index 0000000..364bb68 --- /dev/null +++ b/Pokemon/Pokemon/WildPokemonEncounterHandler.cpp @@ -0,0 +1,18 @@ +#include "WildPokemonEncounterHandler.hpp" +#include +#include + +using namespace std; + +WildPokemonEncounterHandler::WildPokemonEncounterHandler() +{ + srand(time(0)); +} + +Pokemons* WildPokemonEncounterHandler::GetRandomWildPokemonFromGrass(const Grass& grass) +{ + int random_index = rand() % grass.wild_pokemons_list.size(); + if (grass.wild_pokemons_list[random_index]->health == 0) + grass.wild_pokemons_list[random_index]->Heal(); + return grass.wild_pokemons_list[random_index]; +} diff --git a/Pokemon/Pokemon/WildPokemonEncounterHandler.hpp b/Pokemon/Pokemon/WildPokemonEncounterHandler.hpp new file mode 100644 index 0000000..6302acf --- /dev/null +++ b/Pokemon/Pokemon/WildPokemonEncounterHandler.hpp @@ -0,0 +1,9 @@ +#include "Grass.hpp" +#include + +class WildPokemonEncounterHandler +{ +public: + WildPokemonEncounterHandler(); + Pokemons* GetRandomWildPokemonFromGrass(const Grass& grass); +}; \ No newline at end of file diff --git a/Pokemon/Pokemon/Zubat.cpp b/Pokemon/Pokemon/Zubat.cpp new file mode 100644 index 0000000..3d4365a --- /dev/null +++ b/Pokemon/Pokemon/Zubat.cpp @@ -0,0 +1,30 @@ +#include "Zubat.hpp" +#include "Pokemons.hpp" +#include "PokemonMove.hpp" +#include "Utility.hpp" +#include + +using namespace N_Utility; + +//void Zubat::SuperSonic(Pokemons* target_pokemon) +//{ +// cout << name << " uses Supersonic on " << target_pokemon->name << "!!!\n"; +// target_pokemon->TakeDamage(attack_power); +// N_Utility::Utility::WaitForEnter(); +// if (target_pokemon->IsFainted()) +// cout << target_pokemon->name << " fainted!!!\n"; +// else +// cout << target_pokemon->name << " has " << target_pokemon->health << "HP left."; +//} + +void Zubat::Attack(PokemonMove selected_move, Pokemons* target_pokemon) +{ + Pokemons::Attack(selected_move, target_pokemon); + if (selected_move.move_name == "Leech Life") + { + this->health += selected_move.move_power * 0.5; + } + if (this->health > this->max_health) + this->health = this->max_health; + //SuperSonic(target_pokemon); +} \ No newline at end of file diff --git a/Pokemon/Pokemon/Zubat.hpp b/Pokemon/Pokemon/Zubat.hpp new file mode 100644 index 0000000..eb876df --- /dev/null +++ b/Pokemon/Pokemon/Zubat.hpp @@ -0,0 +1,13 @@ +#include "Pokemons.hpp" +#include "PokemonMove.hpp" +#include "PokemonType.hpp" + +class Zubat :public Pokemons +{ + public: + Zubat() : Pokemons("Zubat", Pokemon_Types::Poison_Type, 100, 100, { {"Supersonic",20},{"Leech Life",10}}) {}; + private: + //void SuperSonic(Pokemons* target_pokemon); + + void Attack(PokemonMove selected_move, Pokemons* target_pokemon) override; +}; \ No newline at end of file