Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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;
};
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
//};
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);
};
120 changes: 104 additions & 16 deletions Pokemon/Pokemon/Pokemon.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,108 @@
// Pokemon.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<string>
#include "PokemonType.hpp"
#include "PokemonChoice.hpp"
#include "Utility.hpp"
#include "Player.hpp"
#include "Game.hpp"

using namespace std;

using namespace N_Utility;


class ProfessorOak
{
public:
string name;
void 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();
}

ProfessorOak(string prof_name)
{
name = prof_name;
}

void 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 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 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();
}
};

int main()
{
std::cout << "Hello World!\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// 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
Game loop;

Pokemons charmander("Charmander", Pokemon_Types::Fire_Type, 100, 100, 15);

ProfessorOak Oak("Professor Oak");
Player player("Ash", charmander);

Oak.GreetPlayer(player);
Oak.PlayerIntro(player);
Oak.FirstPokemon(player);

Oak.ExplainMainQuest(player);

loop.GameLoop(player);
}
Loading