Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dd4f9ad
Enter Name
rangamach Oct 29, 2024
c05b631
Choose First Pokemon
rangamach Oct 29, 2024
6c2b609
Professor Oak Dialogue
rangamach Oct 30, 2024
427f70c
Optimized Choosing of Pokemon
rangamach Oct 30, 2024
1fdc2c4
Changed enum to enum classes
rangamach Oct 30, 2024
967a46e
Created Player, ProfessorOak, Pokemon classes
rangamach Oct 31, 2024
74abf20
Added Constructors and Destructor.
rangamach Oct 31, 2024
1d0d5e1
Added Main Quest Explanation
rangamach Oct 31, 2024
19b0fc9
Added the Game Loop.
rangamach Oct 31, 2024
e8c785b
Added a header file
rangamach Nov 1, 2024
05c270a
Added Pokemon Type and Choice Headers.
rangamach Nov 1, 2024
66ab9c2
Added Utility Class.
rangamach Nov 1, 2024
1e29a3d
Added Player seperate header and cpp file
rangamach Nov 1, 2024
2013102
Added Pokemons seperate cpp and header files.
rangamach Nov 1, 2024
6b6efff
Refactored Code.
rangamach Nov 1, 2024
423a130
Added struct Grass.
rangamach Nov 2, 2024
21c46a2
Added Wild Pokemon Encounters Implementation.
rangamach Nov 2, 2024
665c83a
Implemented a battle loop.
rangamach Nov 2, 2024
99b0859
Added attack power and heal mechanism.
rangamach Nov 2, 2024
95471e2
Almost perfected battle loop.
rangamach Nov 2, 2024
95c93e1
Added Battle State.
rangamach Nov 4, 2024
a5c746a
Added Utility namespace.
rangamach Nov 4, 2024
b5ea981
Added Pikachu,Caterpie,Zubat,Pidgey classes.
rangamach Nov 4, 2024
64aa518
Added abstraction and getter and setter for health.
rangamach Nov 4, 2024
59a1054
Added other pokemons.
rangamach Nov 4, 2024
5878c37
Added Pointers, new and delete operations.
rangamach Nov 5, 2024
37b6b4d
Changed Attack function to abstract function.
rangamach Nov 5, 2024
39063b1
Fixed All Errors after changing Pokemons to abstract.
rangamach Nov 5, 2024
8dc6048
Added unique battle dialogue.
rangamach Nov 6, 2024
e4afc01
Added Special Moves to Pokemon.
rangamach Nov 7, 2024
6e212e0
Added IStatusEffect interface.
rangamach Nov 7, 2024
f1a76ab
Implemented Paralyzed Effect.
rangamach Nov 7, 2024
a0ab1ab
Added Thundershock paralysis code.
rangamach Nov 7, 2024
0b24d9d
Version 1
rangamach Nov 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Pokemon/Pokemon/BattleManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "BattleManager.hpp"
#include "Pokemons.hpp"
#include "Player.hpp"
#include<iostream>

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";
}
15 changes: 15 additions & 0 deletions Pokemon/Pokemon/BattleManager.hpp
Original file line number Diff line number Diff line change
@@ -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();
};
9 changes: 9 additions & 0 deletions Pokemon/Pokemon/BattleState.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Pokemons;

struct BattleState
{
Pokemons *player_pokemon;
Pokemons *wild_pokemon;
bool player_turn;
bool battle_unfinished;
};
34 changes: 34 additions & 0 deletions Pokemon/Pokemon/Bulbasaur.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "Bulbasaur.hpp"
#include "PokemonType.hpp"
#include "Utility.hpp"
#include<iostream>

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);
}
15 changes: 15 additions & 0 deletions Pokemon/Pokemon/Bulbasaur.hpp
Original file line number Diff line number Diff line change
@@ -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;
};
30 changes: 30 additions & 0 deletions Pokemon/Pokemon/Caterpie.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "Caterpie.hpp"
#include "PokemonType.hpp"
#include "Utility.hpp"
#include "PokemonMove.hpp"
#include<iostream>

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);
}
15 changes: 15 additions & 0 deletions Pokemon/Pokemon/Caterpie.hpp
Original file line number Diff line number Diff line change
@@ -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;
};
29 changes: 29 additions & 0 deletions Pokemon/Pokemon/Charmander.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "Charmander.hpp"
#include "PokemonType.hpp"
#include "Utility.hpp"
#include<iostream>

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);
}
15 changes: 15 additions & 0 deletions Pokemon/Pokemon/Charmander.hpp
Original file line number Diff line number Diff line change
@@ -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;
};
87 changes: 87 additions & 0 deletions Pokemon/Pokemon/Game.cpp
Original file line number Diff line number Diff line change
@@ -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<iostream>

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()
{

}
14 changes: 14 additions & 0 deletions Pokemon/Pokemon/Game.hpp
Original file line number Diff line number Diff line change
@@ -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);
};
14 changes: 14 additions & 0 deletions Pokemon/Pokemon/Grass.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include<vector>
#include<string>
#include "Pokemons.hpp"

using namespace std;

struct Grass
{
string environment;
vector<Pokemons*> wild_pokemons_list;
int pokemon_encounter_rate;
};
22 changes: 22 additions & 0 deletions Pokemon/Pokemon/IStatusEffect.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include<iostream>
#include<string>

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;
};
Loading