Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f931091
Added greeting message and name input to main()
PranavBardiwale Jul 9, 2025
cd87361
Giving the choice to with adding their name
PranavBardiwale Jul 9, 2025
479c3a8
Enum done
PranavBardiwale Jul 18, 2025
de466fa
Function calls are done!
PranavBardiwale Jul 18, 2025
8f3dacf
Cmstructor scroll done
PranavBardiwale Jul 21, 2025
736cb67
Main quest done
PranavBardiwale Jul 22, 2025
dd1ccfd
head
PranavBardiwale Jul 28, 2025
17c4379
Can't understand the errord
PranavBardiwale Jul 28, 2025
b075054
assignment done
PranavBardiwale Jul 29, 2025
dad1bf5
Deaking with some errors
PranavBardiwale Jul 30, 2025
04b7834
facing errors in player.h and .cpp file
PranavBardiwale Jul 30, 2025
563d1aa
#included
PranavBardiwale Jul 30, 2025
3d8fd92
Good going
PranavBardiwale Jul 30, 2025
5c143c9
Can't understand the error,need help
PranavBardiwale Jul 30, 2025
3620d01
greetings
PranavBardiwale Jul 30, 2025
d2a4cbf
We did it misty!
PranavBardiwale Aug 1, 2025
dd40526
identifier "WildPokemon" is undefined
PranavBardiwale Aug 1, 2025
5cdff4a
identifier "WildPokemon" is undefined
PranavBardiwale Aug 1, 2025
c045e16
Ready for battle!
PranavBardiwale Aug 2, 2025
89ea3d4
Healing battle
PranavBardiwale Aug 2, 2025
bea99f1
Ready for Battle!
PranavBardiwale Aug 2, 2025
a44ff8d
*
PranavBardiwale Aug 2, 2025
d94efba
Don't want to do
PranavBardiwale Aug 2, 2025
3684eb2
Inherited!
PranavBardiwale Aug 6, 2025
1f1d6d8
Poor player!,showing the error
PranavBardiwale Aug 7, 2025
d4cec00
overridding burns!
PranavBardiwale Aug 16, 2025
c013c1f
Complex!
PranavBardiwale Aug 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
59 changes: 59 additions & 0 deletions Pokemon/BattleManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "BattleManager.h"
#include <iostream>
#include "Pokemon.h"
#include "PokemonType.h"
#include "player.h"
#include "utility.h"
#include "BattleState.h"
using namespace std;

BattleState BattleManager::battleState;

void BattleManager::startBattle(Player* player, Pokemon* wildPokemon) {
battleState.playerPokemon = player->chosenPokemon;
battleState.wildPokemon = wildPokemon;
battleState.playerTurn = true;
battleState.battleOngoing = true;

cout << "A wild " << wildPokemon->name << " appeared!\n";
Utility::waitForEnter();

battle();
}

void BattleManager::stopBattle() { battleState.battleOngoing = false; }

void BattleManager::battle() {
while (battleState.battleOngoing)
{
if (battleState.playerTurn)
battleState.playerPokemon->selectAndUseMove(battleState.wildPokemon);
else
battleState.wildPokemon->selectAndUseMove(battleState.playerPokemon);

updateBattleState();
battleState.playerTurn = !battleState.playerTurn;
Utility::waitForEnter();
}

handleBattleOutcome();
}

void BattleManager::updateBattleState() {
if (battleState.playerPokemon->isFainted()) {
battleState.battleOngoing = false;
}
else if (battleState.wildPokemon->isFainted()) {
battleState.battleOngoing = false;
}
}

void BattleManager::handleBattleOutcome() {
if (battleState.playerPokemon->isFainted()) {
cout << battleState.playerPokemon->name
<< " has fainted! You lose the battle.\n";
}
else {
cout << "You defeated the wild " << battleState.wildPokemon->name << "!\n";
}
}
18 changes: 18 additions & 0 deletions Pokemon/BattleManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include "BattleState.h"
#include "Player.h"


class Pokemon;

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

void battle();
void handleBattleOutcome();
void updateBattleState();
};
1 change: 1 addition & 0 deletions Pokemon/BattleState.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "BattleState.h"
9 changes: 9 additions & 0 deletions Pokemon/BattleState.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
#include "Pokemon.h"

struct BattleState {
Pokemon* playerPokemon;
Pokemon* wildPokemon;
bool playerTurn;
bool battleOngoing;
};
30 changes: 30 additions & 0 deletions Pokemon/Bulbasaur.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "Bulbasaur.h"
#include<iostream>
#include "PokemonType.h"
using namespace std;

Bulbasaur::Bulbasaur()
: Pokemon("Bulbasaur", PokemonType::GRASS, 110, {
Move("VINE WHIP", 25),
Move("TACKLE", 10)
}) {
}

void Bulbasaur::attack(Move selectedMove, Pokemon* target)
{
Pokemon::attack(selectedMove, target);

if (selectedMove.name == "VINE WHIP")
{
// Chance for a second hit (50% chance)
int secondHitChance = rand() % 2;

if (secondHitChance == 1)
{
Pokemon::attack(selectedMove, target);
std::cout << name << " hits again with a second " << selectedMove.name << "!\n";
}
else
std::cout << target->name << " dodged the second hit!\n";
}
}
9 changes: 9 additions & 0 deletions Pokemon/Bulbasaur.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
#include "Pokemon.h"

class Bulbasaur : public Pokemon {
public:
Bulbasaur();
void attack(Move selectedMove, Pokemon* target) override;
};

25 changes: 25 additions & 0 deletions Pokemon/Caterpie.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "Caterpie.h"
#include "PokemonType.h"
#include <iostream>
using namespace std;

Caterpie::Caterpie()
: Pokemon("Caterpie", PokemonType::BUG, 75, {
Move("TACKLE", 10),
Move("STRING SHOT", 5),
Move("STICKY WEB", 10)
}) {
}

void Caterpie::attack(Move selectedMove, Pokemon* target)
{
Pokemon::attack(selectedMove, target);

if (selectedMove.name == "STICKY WEB")
{
// Reduce the target's next attack damage (for simplicity, reducing by a fixed value)
int reducedDamage = 5;
target->reduceAttackPower(reducedDamage);
std::cout << target->name << "'s next attack will be reduced by " << reducedDamage << " damage!\n";
}
}
8 changes: 8 additions & 0 deletions Pokemon/Caterpie.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include"Pokemon.h"
#pragma once

class Caterpie : public Pokemon {
public:
Caterpie();
void attack(Move selectedMove, Pokemon* target) override;
};
27 changes: 27 additions & 0 deletions Pokemon/Charmander.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "Charmander.h"
#include "PokemonType.h"
#include "Move.h"
#include "Utility.h"
#include <iostream>
using namespace std;

Charmander::Charmander()
: Pokemon("Charmander", PokemonType::FIRE, 95, {
Move("EMBER", 20),
Move("SCRATCH", 15),
Move("BLAZING CHARGE", 70)
}) {
}

void Charmander::attack(Move selectedMove, Pokemon* target)
{
Pokemon::attack(selectedMove, target);

if (selectedMove.name == "BLAZING CHARGE")
{
// Recoil effect: Charmander takes recoil damage
this->takeDamage(10); // Fixed recoil damage
std::cout << name << " takes 10 recoil damage from the Blazing Charge!\n";
Utility::Utility::waitForEnter();
}
}
8 changes: 8 additions & 0 deletions Pokemon/Charmander.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include"Pokemon.h"
#pragma once

class Charmander : public Pokemon {
public:
Charmander();
void attack(Move selectedMove, Pokemon* target) override;
};
109 changes: 109 additions & 0 deletions Pokemon/Game.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#include "Game.h"
#include "Player.h"
#include "PokemonType.h"
#include "utility.h"
#include "WildEncounterManager.h"
#include <iostream>
#include"BattleManager.h"
#include "Caterpie.h"
#include "Pidgey.h"
#include "Zubat.h"
#include "Utility.h"
#include <iostream>
using namespace std;

Game::Game() {
// Create a sample grass environment with actual Pokemon objects
forestGrass = { "Forest", {new Pidgey(), new Caterpie(), new Zubat()}, 70 };
}

void Game::gameLoop(Player* player) {

int choice;
bool keepPlaying = true;
BattleManager* battleManager = new BattleManager();
WildEncounterManager* encounterManager = new WildEncounterManager();

while (keepPlaying) {
// Clear console before showing options
Utility::clearConsole();

// Display options to the player
cout << "\nWhat would you like to do next, " << player->name << "?\n";
cout << "1. Battle Wild Pok�mon\n";
cout << "2. Visit PokeCenter\n";
cout << "3. Challenge Gyms\n";
cout << "4. Enter Pok�mon League\n";
cout << "5. Quit\n";
cout << "Enter your choice: ";
cin >> choice;

Utility::clearInputBuffer(); // Clear the input buffer

// Process the player's choice and display the corresponding message
switch (choice) {
case 1: {
wildPokemon = encounterManager->getRandomPokemonFromGrass(forestGrass);
battleManager->startBattle(player, wildPokemon);
break;
}
case 2: {
visitPokeCenter(player);
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 Pok�mon 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 Pok�mon 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;
}
}

// Wait for Enter key before the screen is cleared and the menu is shown
// again
Utility::waitForEnter();
}

cout << "Goodbye, " << player->name << "! Thanks for playing!\n";

delete(encounterManager);
delete(battleManager);
}

void Game::visitPokeCenter(Player* player) {
if (player->chosenPokemon->health == player->chosenPokemon->maxHealth) {
std::cout << "Your Pok�mon is already at full health!\n";
}
else {
std::cout << "You head to the PokeCenter.\n";
std::cout << "Healing your Pok�mon...\n";
Utility::waitForEnter(); // Simulate a short pause for the
// healing process
player->chosenPokemon->heal(); // Heal the player's Pok�mon
std::cout << player->chosenPokemon->name << "'s health is fully restored!\n";
}
}

Game::~Game()
{
delete(wildPokemon);
}
17 changes: 17 additions & 0 deletions Pokemon/Game.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include "Player.h"
#include "Grass.h"

// class Player;

class Game {
private:
Grass forestGrass;
Pokemon* wildPokemon;

public:
Game();
~Game();
void gameLoop(Player* player);
void visitPokeCenter(Player* player);
};
21 changes: 21 additions & 0 deletions Pokemon/Grass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "Grass.h"
#include "PokemonType.h"
#include "Move.h"

Grass forestGrass = {
"Forest",
{
new Pokemon("Pidgey", PokemonType::NORMAL, 40, {Move("GUST", 15), Move("TACKLE", 10)}),
new Pokemon("Caterpie", PokemonType::BUG, 35, {Move("TACKLE", 10), Move("STRING SHOT", 5)})
},
70
};

Grass caveGrass = {
"Cave",
{
new Pokemon("Zubat", PokemonType::POISON, 30, {Move("BITE", 12), Move("WING ATTACK", 10)}),
new Pokemon("Geodude", PokemonType::ROCK, 50, {Move("TACKLE", 10), Move("DEFENSE CURL", 5)})
},
80
};
13 changes: 13 additions & 0 deletions Pokemon/Grass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include<string>
#include<vector>
#include"Pokemon.h"
#include <iostream>
using namespace std;
class Pokemon;

struct Grass {
std::string environmentType; // Example: "Forest", "Cave", "Riverbank"
std::vector<Pokemon*> wildPokemonList; // List of wild Pok�mon in this grass
int encounterRate; // Likelihood of encountering a wild Pok�mon, out of 100
};

1 change: 1 addition & 0 deletions Pokemon/Move.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "Move.h"
16 changes: 16 additions & 0 deletions Pokemon/Move.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include <string>
using namespace std;


struct Move
{
string name;
int power;

Move(const string& moveName, int movePower)
{
name = moveName;
power = movePower;
}
};
1 change: 1 addition & 0 deletions Pokemon/MoveName.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "MoveName.h"
Loading