Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 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
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->Attack(*battle_state.wild_pokemon);
else
battle_state.wild_pokemon->Attack(*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;
};
14 changes: 14 additions & 0 deletions Pokemon/Pokemon/Bulbasaur.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "Bulbasaur.hpp"
#include "PokemonType.hpp"
#include<iostream>

Bulbasaur::Bulbasaur()
{
Pokemons("Bulbasaur", Pokemon_Types::Grass_Type, 100, 100, 35);
}

void Bulbasaur::VineWhip(Pokemons& target_pokemon)
{
cout << name << " uses Vinewhip on " << target_pokemon.name << "!!!\n";
target_pokemon.TakeDamage(35);
}
11 changes: 11 additions & 0 deletions Pokemon/Pokemon/Bulbasaur.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include "Pokemons.hpp"

class Bulbasaur :public Pokemons
{
public:
Bulbasaur();
private:
void VineWhip(Pokemons& target_pokemon);
};
Empty file added Pokemon/Pokemon/Caterpie.cpp
Empty file.
Empty file added Pokemon/Pokemon/Caterpie.hpp
Empty file.
14 changes: 14 additions & 0 deletions Pokemon/Pokemon/Charmander.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "Charmander.hpp"
#include "PokemonType.hpp"
#include<iostream>

Charmander::Charmander()
{
Pokemons("Charmander", Pokemon_Types::Fire_Type, 100, 100, 35);
}

void Charmander::FlameBurst(Pokemons& target_pokemon)
{
cout << name << " uses Supersonic on " << target_pokemon.name << "!!!\n";
target_pokemon.TakeDamage(35);
}
9 changes: 9 additions & 0 deletions Pokemon/Pokemon/Charmander.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "Pokemons.hpp"

class Charmander :public Pokemons
{
public:
Charmander();
private:
void FlameBurst(Pokemons& target_pokemon);
};
80 changes: 80 additions & 0 deletions Pokemon/Pokemon/Game.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include "Game.hpp"
#include "Player.hpp"
#include "PokemonType.hpp"
#include "Utility.hpp"
#include "WildPokemonEncounterHandler.hpp"
#include "BattleManager.hpp"
#include<iostream>


using namespace std;

using namespace N_Utility;

Game::Game()
{
forest_grass = {
"Forest",
{{"Pidgey",Pokemon_Types::Normal_Type,40, 40, 2},
{"Zubat",Pokemon_Types::Poison_Type,30, 30, 10},
{"Caterpie",Pokemon_Types::Bug_Type,35, 35, 5}},
70 };
}
void Game::GameLoop(Player &player)
{
BattleManager battle_manager;
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:
{
WildPokemonEncounterHandler encounters;
Pokemons encountered_pokemon = encounters.GetRandomWildPokemonFromGrass(forest_grass);
battle_manager.StartBattle(player,encountered_pokemon);
player.captured_pokemon.ShowHealth(player.captured_pokemon);
break;
}
case 2:
{
player.captured_pokemon.Heal();
cout << player.captured_pokemon.name << "'s health is fully restored.\n";
player.captured_pokemon.ShowHealth(player.captured_pokemon);
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";
}
12 changes: 12 additions & 0 deletions Pokemon/Pokemon/Game.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "Grass.hpp"

class Player;

class Game
{
private:
Grass forest_grass;
public:
Game();
void GameLoop(Player &player);
};
20 changes: 20 additions & 0 deletions Pokemon/Pokemon/Grass.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#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;
};

//Grass forestGrass = {
// "Cave",
// {{"Zubat",Pokemon_Types::Poison_Type,30},{"Geodude",Pokemon_Types::Rock_Type,50},{"Caterpie",Pokemon_Types::Bug_Type,10}},
// 80
//};
Empty file added Pokemon/Pokemon/Pidgey.cpp
Empty file.
Empty file added Pokemon/Pokemon/Pidgey.hpp
Empty file.
Empty file added Pokemon/Pokemon/Pikachu.cpp
Empty file.
8 changes: 8 additions & 0 deletions Pokemon/Pokemon/Pikachu.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "Pokemons.hpp"

class Pikachu : public Pokemons
{
public:
Pikachu();
void ThunderShock(Pokemons& target_pokemon);
};
38 changes: 38 additions & 0 deletions Pokemon/Pokemon/Player.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "Player.hpp"
#include "Pokemons.hpp"
#include<iostream>

using namespace std;

using namespace N_Utility;

Player::Player()
{
Player::captured_pokemon = Pokemons();
}

Player::Player(string playerName, Pokemons playerCapturedPokemon)
{
Player::name = playerName;
Player::captured_pokemon = playerCapturedPokemon;
}
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);
break;
case Pokemon_Choice::Bulbasaur:
Player::captured_pokemon = Pokemons("Bulbasaur", Pokemon_Types::Grass_Type, 100, 100, 10);
break;
case Pokemon_Choice::Squirtle:
Player::captured_pokemon = Pokemons("Squirtle", Pokemon_Types::Water_Type, 100, 100, 15);
break;
default:
Player::captured_pokemon = Pokemons("Pikachu", Pokemon_Types::Electric_Type, 100, 100, 20);
break;
}
cout << name << " chose " << captured_pokemon.name << "\n";
Utility::WaitForEnter();
}
21 changes: 21 additions & 0 deletions Pokemon/Pokemon/Player.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include<string>

#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);
void ChosenPokemon(int choice);
};
Loading