Skip to content

Feature 5 wild pokemons #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: Project_Setup
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
38cd0e2
Update main.cpp
ayushgaikwad26 Mar 6, 2025
3ab2a1f
Merge pull request #1 from ayushgaikwad26/Feature_1_Pokemon_Selection
ayushgaikwad26 Mar 6, 2025
051844f
Update main.cpp
ayushgaikwad26 Mar 6, 2025
2d1b3c5
Merge pull request #2 from ayushgaikwad26/Feature_1_Pokemon_Selection
ayushgaikwad26 Mar 6, 2025
be72cf4
Update main.cpp
ayushgaikwad26 Mar 6, 2025
6583fca
Merge pull request #3 from ayushgaikwad26/Feature_1_Pokemon_Selection
ayushgaikwad26 Mar 6, 2025
e50c866
Update main.cpp
ayushgaikwad26 Mar 7, 2025
4d255de
Merge pull request #4 from ayushgaikwad26/Feature_1_Pokemon_Selection
ayushgaikwad26 Mar 7, 2025
2f3969e
Update main.cpp
ayushgaikwad26 Mar 10, 2025
961032a
Merge pull request #5 from ayushgaikwad26/Feature_1_Pokemon_Selection
ayushgaikwad26 Mar 10, 2025
446fc30
Update main.cpp
ayushgaikwad26 Mar 10, 2025
9ce0cfa
Update main.cpp
ayushgaikwad26 Mar 11, 2025
85fab1a
Merge pull request #7 from ayushgaikwad26/Feature_2_OOP
ayushgaikwad26 Mar 11, 2025
fd66f1f
Update main.cpp
ayushgaikwad26 Mar 11, 2025
2b6b4e1
Update main.cpp
ayushgaikwad26 Mar 11, 2025
0bd08ce
Update main.cpp
ayushgaikwad26 Mar 11, 2025
a060d0e
Update main.cpp
ayushgaikwad26 Mar 11, 2025
9f4bd89
,
ayushgaikwad26 Mar 11, 2025
2bea9fe
k
ayushgaikwad26 Mar 11, 2025
e439e90
s
ayushgaikwad26 Mar 11, 2025
d0fa4c3
Update Player.hpp
ayushgaikwad26 Mar 11, 2025
d56c9d1
s
ayushgaikwad26 Mar 11, 2025
81d62ae
a
ayushgaikwad26 Mar 11, 2025
fa74a59
s
ayushgaikwad26 Mar 11, 2025
927de53
s
ayushgaikwad26 Mar 12, 2025
8bc4ede
a
ayushgaikwad26 Mar 13, 2025
ecc6877
s
ayushgaikwad26 Mar 13, 2025
e3bf2cc
Update Game.cpp
ayushgaikwad26 Mar 17, 2025
afc794b
a
ayushgaikwad26 Mar 17, 2025
5a83949
s
ayushgaikwad26 Mar 17, 2025
c2cea5d
Merge pull request #22 from ayushgaikwad26/Feature_6_Battle_Loop
ayushgaikwad26 Mar 17, 2025
c1d3406
s
ayushgaikwad26 Mar 17, 2025
6244d71
Merge pull request #23 from ayushgaikwad26/Feature_6_Battle_Loop
ayushgaikwad26 Mar 17, 2025
3ee7bea
Update WildEncounterManager.cpp
ayushgaikwad26 Mar 17, 2025
fb7f664
Merge pull request #24 from ayushgaikwad26/Feature_6_Battle_Loop
ayushgaikwad26 Mar 17, 2025
8ce3005
s
ayushgaikwad26 Mar 17, 2025
4b04c00
Merge pull request #25 from ayushgaikwad26/Feature_6_Battle_Loop
ayushgaikwad26 Mar 17, 2025
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
22 changes: 22 additions & 0 deletions Pokemon/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/.idea/.idea.Pokemon"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.22621.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
54 changes: 54 additions & 0 deletions Pokemon/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"files.associations": {
"iostream": "cpp",
"istream": "cpp",
"xstring": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"format": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iterator": "cpp",
"limits": "cpp",
"locale": "cpp",
"memory": "cpp",
"new": "cpp",
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xtr1common": "cpp",
"xutility": "cpp"
}
}
16 changes: 16 additions & 0 deletions Pokemon/include/Battle/BattleManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#include "Pokemon.hpp"
#include "Player.hpp"

class BattleManager {
public:
void startBattle(Player &player, Pokemon &wildPokemon);
private:
void battle(Pokemon &playerPokemon, Pokemon &wildPokemon);
void handleBattleOutcome(Player &player, bool playerWon);

void BattleManager::startBattle(Player &player, Pokemon &wildPokemon) {
std::cout << "A wild " << wildPokemon.name << " appeared!\n";
battle(player.chosenPokemon, wildPokemon);
}
};
8 changes: 8 additions & 0 deletions Pokemon/include/Battle/BattleState.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "Pokemon.hpp"

struct BattleState {
Pokemon *playerPokemon; // Pointer to the player's Pokémon
Pokemon *wildPokemon; // Pointer to the wild Pokémon
bool playerTurn; // True if it's the player's turn, false otherwise
bool battleOngoing; // True if the battle is still ongoing
};
Empty file.
13 changes: 13 additions & 0 deletions Pokemon/include/Character/Player/Player.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <string>
#include "Pokemon.hpp"
using namespace std;
class Player {
public:
string name;
Pokemon chosenPokemon;

Player(); // Default constructor
Player(string p_name, Pokemon p_chosenPokemon); // Parameterized constructor

void choosePokemon(int choice); // Method to choose a Pokemon
};
14 changes: 14 additions & 0 deletions Pokemon/include/Character/ProfessorOak.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <iostream>
using namespace std;

class Player;

class ProfessorOak {
public:
string name;

ProfessorOak(string p_name);
void greetPlayer(Player& player);
void offerPokemonChoices(Player& player);
void explainMainQuest(Player& player);
};
10 changes: 10 additions & 0 deletions Pokemon/include/Main/Game.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "Grass.h"

class Player;

class Game {

public:
Game();
void gameLoop(Player& player);
};
Empty file.
25 changes: 25 additions & 0 deletions Pokemon/include/Pokemon/Pokemon.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <string>
using namespace std;

enum class PokemonType;

class Pokemon {
public:
string name;
PokemonType type;
int health;

// Default constructor
Pokemon();

// Parameterized constructor
Pokemon(string p_name, PokemonType p_type, int p_health);

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

// Destructor
~Pokemon();

void attack();
};
6 changes: 6 additions & 0 deletions Pokemon/include/Pokemon/PokemonChoice.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enum class PokemonChoice {
CHARMANDER = 1,
BULBASAUR,
SQUIRTLE,
PIKACHU // Default choice
};
7 changes: 7 additions & 0 deletions Pokemon/include/Pokemon/PokemonType.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enum class PokemonType {
FIRE,
GRASS,
WATER,
ELECTRIC,
NORMAL // Added for the default constructor
};
Empty file.
Empty file.
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions Pokemon/include/Utility/Utility.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Utility {
public:
static void clearConsole();
static void waitForEnter();
static void clearInputBuffer(); // New helper function
};
6 changes: 0 additions & 6 deletions Pokemon/main.cpp

This file was deleted.

18 changes: 18 additions & 0 deletions Pokemon/src/Battle/BattleManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
void battle(Pokemon &playerPokemon, Pokemon &wildPokemon) {
cout << "A wild " << wildPokemon.name << " appeared!\\n";

while (!playerPokemon.isFainted() && !wildPokemon.isFainted()) {
playerPokemon.attack(wildPokemon); // Player attacks first

if (!wildPokemon.isFainted()) {
wildPokemon.attack(playerPokemon); // Wild Pokémon attacks back
}
}

if (playerPokemon.isFainted()) {
cout << playerPokemon.name << " has fainted! You lose the battle.\\n";
} else {
cout << "You defeated the wild " << wildPokemon.name << "!\\n";
}

}
12 changes: 12 additions & 0 deletions Pokemon/src/Battle/WildEncounterManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "../../include/Battle/WildEncounterManager.hpp"
#include <cstdlib> // For rand()
#include <ctime> // For time()

WildEncounterManager::WildEncounterManager() {
srand(time(0)); // Seed the random number generator
}

WildPokemon WildEncounterManager::getRandomPokemonFromGrass(const Grass& grass) {
int randomIndex = rand() % grass.wildPokemonList.size();
return grass.wildPokemonList[randomIndex];
}
34 changes: 34 additions & 0 deletions Pokemon/src/Character/Player/Player.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "../../../include/Character/Player/Player.hpp"
#include "../../include/Pokemon/PokemonChoice.hpp"
#include "../../include/Pokemon/PokemonType.hpp"
#include "../../include/Utility/Utility.hpp"
#include "iostream"

Player::Player() {
name = "Trainer";
chosenPokemon = Pokemon(); // Using the default Pokemon constructor
}

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

void Player::choosePokemon(int choice) {
switch ((PokemonChoice)choice) {
case PokemonChoice::CHARMANDER:
chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100);
break;
case PokemonChoice::BULBASAUR:
chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100);
break;
case PokemonChoice::SQUIRTLE:
chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100);
break;
default:
chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100);
break;
}
std::cout << "Player " << name << " chose " << chosenPokemon.name << "!\n";
Utility::waitForEnter(); // Wait for user to press Enter before proceeding
}
101 changes: 101 additions & 0 deletions Pokemon/src/Character/ProfessorOak.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#include "ProfessorOak.h"
#include "Player.h"
#include "Utility.h"
#include <iostream>
using namespace std;

ProfessorOak::ProfessorOak(string p_name) { name = p_name; }

void ProfessorOak::greetPlayer(Player& player) {

cout << name << ": Hello there! Welcome to the world of Pokemon!\n";
Utility::waitForEnter();
cout << name << ": My name is Oak. 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::offerPokemonChoices(Player& player) {

cout << name << ": First, tell me, what’s your name? \t [Please Enter 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’ll need a Pokemon of your own!\n";
Utility::waitForEnter();

// Presenting Pokemon choices
cout << name
<< ": I have three Pokemon here with me. They’re all quite feisty!\n";
Utility::waitForEnter();
cout << name << ": Choose wisely...\n";
cout << "1. Charmander - The fire type. A real hothead!\n";
cout << "2. Bulbasaur - The grass type. Calm and collected!\n";
cout << "3. Squirtle - The water type. Cool as a cucumber!\n";

int choice;
cout << name
<< ": So, which one will it be? Enter the number of your choice: ";
cin >> choice;

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

void ProfessorOak::explainMainQuest(Player& player) {

// Clear the console
Utility::clearConsole();

cout << "Professor Oak: " << player.name
<< "!, I am about to explain you about your upcoming grand "
"adventure.\n";
Utility::waitForEnter();
cout << "Professor Oak: You see, becoming a Pokémon Master is no easy "
"feat. It takes courage, wisdom, and a bit of luck!\n";
Utility::waitForEnter();
cout << "Professor Oak: Your mission, should you choose to accept it—and "
"trust me, you really don’t have a choice—is to collect all the "
"Pokémon Badges and conquer the Pokémon League.\n";
Utility::waitForEnter();

cout << "\n"
<< 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";
Utility::waitForEnter();

cout << "\nProfessor Oak: To achieve this, you’ll need to battle wild "
"Pokémon, challenge gym leaders, and of course, keep your "
"Pokémon healthy at the PokeCenter.\n";
Utility::waitForEnter();
cout << "Professor Oak: Along the way, you'll capture new Pokémon 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 << "\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 "
"challenges. And if you lose a battle... well, let’s just say "
"you'll be starting from square one.\n";
Utility::waitForEnter();

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";
Utility::waitForEnter();

cout << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n";
Utility::waitForEnter();
cout << "Professor Oak: But first... let's just pretend I didn't "
"forget to set up the actual game loop... Ahem, onwards!\n";
Utility::waitForEnter();
}
Loading