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
6 changes: 2 additions & 4 deletions Pokemon/Header/Battle/BattleManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ using namespace N_Player;

namespace N_Battle
{


class BattleManager {
public:
void startBattle(Player& player, N_Pokemon::Pokemon& wildPokemon);
void startBattle(Player* player, N_Pokemon::Pokemon* wildPokemon);
private:
BattleState battleState;
BattleState* battleState;

void battle();
void handleBattleOutcome();
Expand Down
2 changes: 1 addition & 1 deletion Pokemon/Header/Battle/WildEncounterManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ namespace N_Battle
class WildEncounterManager {
public:
WildEncounterManager();
Pokemon getRandomPokemonFromGrass(const Grass& grass);
Pokemon getRandomPokemonFromGrass(const Grass* grass);
};
}
4 changes: 2 additions & 2 deletions Pokemon/Header/Character/Player/Player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ namespace N_Character
class Player {
public:
string name;
N_Pokemon::Pokemon chosenPokemon;
N_Pokemon::Pokemon* chosenPokemon;

// Default constructor
Player();

// Parameterized constructor
Player(string p_name, N_Pokemon::Pokemon p_chosenPokemon);
Player(string p_name, N_Pokemon::Pokemon* p_chosenPokemon);


void choosePokemon(int choice);
Expand Down
6 changes: 3 additions & 3 deletions Pokemon/Header/Character/ProfessorOak.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ namespace N_Character
// Parameterized constructor
ProfessorOak(string p_name);

void greetPlayer(Player& player);
void greetPlayer(Player* player);

void offerPokemonChoices(Player& player);
void offerPokemonChoices(Player* player);

// New method for the main quest conversation
void explainMainQuest(Player& player);
void explainMainQuest(Player* player);
};
}
8 changes: 4 additions & 4 deletions Pokemon/Header/Main/Game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace N_Game

public:
Game();
void gameLoop(Player& player);
void gameLoop(Player* player);

private:
Grass forestGrass;
Grass caveGrass;
Grass shallowWater;
Grass* forestGrass;
Grass* caveGrass;
Grass* shallowWater;
};
}
2 changes: 1 addition & 1 deletion Pokemon/Header/Pokemon/Grass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace N_Pokemon
{
struct Grass {
string environmentType;
vector<Pokemon> wildPokemonList;
vector<Pokemon*> wildPokemonList;
int encounterRate;
};
}
4 changes: 2 additions & 2 deletions Pokemon/Header/Pokemon/Pokemon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ namespace N_Pokemon
Pokemon(std::string p_name, PokemonType p_type, int p_health, int p_attackPower);

// Copy constructor
Pokemon(const Pokemon& other);
Pokemon(const Pokemon* other);

~Pokemon();

void attack(Pokemon& target);
void attack(Pokemon* target);

void heal();

Expand Down
2 changes: 1 addition & 1 deletion Pokemon/Header/Pokemon/Pokemons/Bulbasaur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace N_Pokemon {

private:
int leafBlade_dmg;
void leafBlade(Pokemon& target);
void leafBlade(Pokemon* target);
};

}
Expand Down
2 changes: 1 addition & 1 deletion Pokemon/Header/Pokemon/Pokemons/Caterpie.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace N_Pokemon {

private:
int bugBite_dmg;
void bugBite(Pokemon& target);
void bugBite(Pokemon* target);
};

}
Expand Down
2 changes: 1 addition & 1 deletion Pokemon/Header/Pokemon/Pokemons/Charmander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace N_Pokemon {

private:
int flameThrower_dmg;
void flameThrower(Pokemon& target);
void flameThrower(Pokemon* target);
};

}
Expand Down
2 changes: 1 addition & 1 deletion Pokemon/Header/Pokemon/Pokemons/Pidgey.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace N_Pokemon {

private:
int wingAttack_dmg;
void WingAttack(Pokemon& target);
void WingAttack(Pokemon* target);
};
}
}
2 changes: 1 addition & 1 deletion Pokemon/Header/Pokemon/Pokemons/Pikachu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace N_Pokemon {

private:
int thunderShock_dmg;
void thunderShock(Pokemon& target);
void thunderShock(Pokemon* target);
};

}
Expand Down
2 changes: 1 addition & 1 deletion Pokemon/Header/Pokemon/Pokemons/Squitle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace N_Pokemon {

private:
int waterGun_dmg;
void waterGun(Pokemon& target);
void waterGun(Pokemon* target);
};

}
Expand Down
36 changes: 18 additions & 18 deletions Pokemon/Src/Battle/BattleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,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;
std::cout << "A wild " << wildPokemon.getName() << " appeared!\n";
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;
std::cout << "A wild " << wildPokemon->getName() << " appeared!\n";
battle();
}

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->attack(battleState->wildPokemon);
}
else {
// Wild Pok�mon's turn to attack
battleState.wildPokemon->attack(*battleState.playerPokemon);
battleState->wildPokemon->attack(battleState->playerPokemon);
}

// Update the battle state after the turn
updateBattleState();

// Switch turns
battleState.playerTurn = !battleState.playerTurn;
battleState->playerTurn = !battleState->playerTurn;

Utility::waitForEnter();
}
Expand All @@ -41,22 +41,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;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Pokemon/Src/Battle/WildEncounterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ namespace N_Battle
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;
}
}
15 changes: 8 additions & 7 deletions Pokemon/Src/Character/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,38 @@
using namespace std;

using namespace N_Utility;
using namespace N_Pokemon;

namespace N_Character
{
namespace N_Player
{
Player::Player() {
name = "Trainer";
chosenPokemon = N_Pokemon::Pokemon(); // Using the default Pokemon constructor
Pokemon* chosenPokemon = new Pokemon(); // Using the default Pokemon constructor
}

Player::Player(string p_name, N_Pokemon::Pokemon p_chosenPokemon) {
Player::Player(string p_name, Pokemon* p_chosenPokemon) {
name = p_name;
chosenPokemon = p_chosenPokemon;
}

void Player::choosePokemon(int choice) {
switch ((N_Pokemon::PokemonChoice)choice) {
case N_Pokemon::PokemonChoice::CHARMANDER:
chosenPokemon = N_Pokemon::Pokemon("Charmander", N_Pokemon::PokemonType::FIRE, 100, 10);
Pokemon* chosenPokemon = new Pokemon("Charmander", N_Pokemon::PokemonType::FIRE, 100, 10);
break;
case N_Pokemon::PokemonChoice::BULBASAUR:
chosenPokemon = N_Pokemon::Pokemon("Bulbasaur", N_Pokemon::PokemonType::GRASS, 100, 10);
Pokemon* chosenPokemon = new Pokemon("Bulbasaur", N_Pokemon::PokemonType::GRASS, 100, 10);
break;
case N_Pokemon::PokemonChoice::SQUIRTLE:
chosenPokemon = N_Pokemon::Pokemon("Squirtle", N_Pokemon::PokemonType::WATER, 100, 10);
Pokemon* chosenPokemon = new Pokemon("Squirtle", N_Pokemon::PokemonType::WATER, 100, 10);
break;
default:
chosenPokemon = N_Pokemon::Pokemon("Pikachu", N_Pokemon::PokemonType::ELECTRIC, 100, 10);
Pokemon* chosenPokemon = new Pokemon("Pikachu", N_Pokemon::PokemonType::ELECTRIC, 100, 10);
break;
}
cout << "Player " << name << " chose " << chosenPokemon.getName() << "!\n";
cout << "Player " << name << " chose " << chosenPokemon->getName() << "!\n";
Utility::waitForEnter();
}
}
Expand Down
22 changes: 11 additions & 11 deletions Pokemon/Src/Character/ProfessorOak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace N_Character
{
ProfessorOak::ProfessorOak(string p_name) { name = p_name; }

void ProfessorOak::greetPlayer(Player& player) {
void ProfessorOak::greetPlayer(Player* player) {
cout << name << ": Hello there! Welcome to the world of Pokemon!\n";
Utility::waitForEnter();
cout << name
Expand All @@ -22,12 +22,12 @@ namespace N_Character
Utility::waitForEnter();
}

void ProfessorOak::offerPokemonChoices(Player& player) {
void ProfessorOak::offerPokemonChoices(Player* player) {
cout
<< name
<< ": First, tell me, what�s your name? \t [Please Enter Your Name]\n";
getline(std::cin, player.name);
cout << name << ": Ah, " << player.name
getline(std::cin, player->name);
cout << name << ": Ah, " << player->name
<< "! What a fantastic name!\n";
Utility::waitForEnter();
cout << name
Expand All @@ -50,14 +50,14 @@ namespace N_Character
<< ": So, which one will it be? Enter the number of your choice: ";
cin >> choice;

player.choosePokemon(choice);
player->choosePokemon(choice);
Utility::waitForEnter();
}

void ProfessorOak::explainMainQuest(Player& player) {
void ProfessorOak::explainMainQuest(Player* player) {
Utility::clearConsole();

cout << "Professor Oak: " << player.name
cout << "Professor Oak: " << player->name
<< "!, I am about to explain you about your upcoming grand "
"adventure.\n";
Utility::waitForEnter();
Expand All @@ -71,12 +71,12 @@ namespace N_Character
Utility::waitForEnter();

cout << "\n"
<< player.name
<< player->name
<< ": Wait... that sounds a lot like every other Pok�mon game "
"out there...\n";
Utility::waitForEnter();
cout << "Professor Oak: Shhh! Don't break the fourth wall, "
<< player.name << "! This is serious business!\n";
<< player->name << "! This is serious business!\n";
Utility::waitForEnter();

cout << "\nProfessor Oak: To achieve this, you�ll need to battle wild "
Expand All @@ -89,7 +89,7 @@ namespace N_Character
Utility::waitForEnter();

cout << "\n"
<< player.name << ": Sounds like a walk in the park... right?\n";
<< player->name << ": Sounds like a walk in the park... right?\n";
Utility::waitForEnter();
cout << "Professor Oak: Hah! That�s what they all say! But beware, "
"young Trainer, the path to victory is fraught with "
Expand All @@ -100,7 +100,7 @@ namespace N_Character
cout << "\nProfessor Oak: So, what do you say? Are you ready to "
"become the next Pok�mon Champion?\n";
Utility::waitForEnter();
cout << "\n" << player.name << ": Ready as I�ll ever be, Professor!\n";
cout << "\n" << player->name << ": Ready as I�ll ever be, Professor!\n";
Utility::waitForEnter();

cout
Expand Down
Loading