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
26 changes: 26 additions & 0 deletions Pokemon/BattleManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<iostream>
#include "Pokemon.hpp"


using namespace std;
class BattleManager
{
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";
}
}
};
92 changes: 92 additions & 0 deletions Pokemon/Game.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include "Game.hpp"
#include "Player.hpp"
#include "PokemonType.hpp"
#include "Utility.hpp"
#include "WildEncounterManager.hpp"
#include <iostream>
using namespace std;

Game::Game() {
forestGrass = {"Forest", {Pokemon {"Pidgey", PokemonType::NORMAL, 40}, Pokemon {"Caterpie", PokemonType::BUG, 35}}, 70};

/*caveGrass = {
"Cave",
{{"Zubat", PokemonType::POISON, 30, 10}, {"Geodude", PokemonType::ROCK, 50, 10}},
80
};

shallowWater = {
"Cave",
{{"Staryu", PokemonType::WATER, 40, 10}, {"Tentacool", PokemonType::POISON, 40, 10}},
80
};*/
}

void Game::gameLoop(Player& player) {

int choice;
bool keepPlaying = true;

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: {
// Create a scope within case 1
WildEncounterManager encounterManager;
Pokemon encounteredPokemon = encounterManager.getRandomPokemonFromGrass(forestGrass);
cout << "A wild " << encounteredPokemon.name << " appeared!\n";
break;
}
case 2: {
cout << "You head to the PokeCenter.\\n";
player.chosenPokemon.heal(); // Heal the player's Pok�mon
cout << player.chosenPokemon.name << "'s health is fully restored!\\n";
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;
}
}

Utility::waitForEnter();
}

cout << "Goodbye, " << player.name << "! Thanks for playing!\n";
}
16 changes: 16 additions & 0 deletions Pokemon/Game.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include "Grass.hpp"

class Player;

class Game {

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

private:
Grass forestGrass;
Grass caveGrass;
Grass shallowWater;
};
12 changes: 12 additions & 0 deletions Pokemon/Grass.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once
#include<string>
#include<vector>
#include"Pokemon.hpp"
#include"WildEncounterManager.hpp"
using namespace std;

struct Grass {
string environmentType; // Example: "Forest", "Cave", "Riverbank"
vector<Pokemon> wildPokemonList; // List of wild Pok�mon that live in this grass
int encounterRate; // Likelihood of encountering a wild Pok�mon, out of 100
};
8 changes: 4 additions & 4 deletions Pokemon/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ Player::Player(string p_name, Pokemon p_chosenPokemon) {
void Player::choosePokemon(int choice) {
switch ((PokemonChoice)choice) {
case PokemonChoice::CHARMANDER:
chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100);
chosenPokemon = Pokemon("Charmander", PokemonType::FIRE, 100, 10);
break;
case PokemonChoice::BULBASAUR:
chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100);
chosenPokemon = Pokemon("Bulbasaur", PokemonType::GRASS, 100, 10);
break;
case PokemonChoice::SQUIRTLE:
chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100);
chosenPokemon = Pokemon("Squirtle", PokemonType::WATER, 100, 10);
break;
default:
chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100);
chosenPokemon = Pokemon("Pikachu", PokemonType::ELECTRIC, 100, 10);
break;
}
cout << "Player " << name << " chose " << chosenPokemon.name << "!\n";
Expand Down
30 changes: 23 additions & 7 deletions Pokemon/Pokemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,39 @@ using namespace std;
health = 50;
}

// Parameterized constructor
Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health) {
Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health, int p_attackPower) {
name = p_name;
type = p_type;
health = p_health;
}

// Copy constructor
Pokemon::Pokemon(const Pokemon& other) {
name = other.name;
type = other.type;
health = other.health;
}

// Destructor
Pokemon::~Pokemon() {
// Destructor message removed
Pokemon::~Pokemon() { }

void Pokemon::attack(Pokemon& target) {
int damage = attackPower; // Use attack power for damage calculation
std::cout << name << " attacks " << target.name << " for " << damage << " damage!\n";
target.takeDamage(damage);
}

void Pokemon::takeDamage(int damage)
{
health -= damage;
if (health <= 0)
health = 0;
}

bool Pokemon::isFainted() const
{
return (health <= 0);
}

void Pokemon::attack() { std::cout << name << " attacks with a powerful move!\n"; }
void Pokemon::heal()
{
health = maxHealth;
}
12 changes: 10 additions & 2 deletions Pokemon/Pokemon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,25 @@ class Pokemon {
string name;
PokemonType type;
int health;
int maxHealth;
int attackPower;

// Default constructor
Pokemon();

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

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

~Pokemon();

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

void heal();

void takeDamage(int damage);

bool isFainted() const;
};
9 changes: 8 additions & 1 deletion Pokemon/Pokemon.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="BattleManager.cpp" />
<ClCompile Include="Game.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="Player.cpp" />
<ClCompile Include="Pokemon.cpp" />
<ClCompile Include="ProfessorOak.cpp" />
<ClCompile Include="Utility.cpp" />
<ClCompile Include="WildEncounterManager.cpp" />
</ItemGroup>
<ItemGroup>
<Content Include=".idea\.idea.Pokemon\.idea\indexLayout.xml" />
Expand All @@ -166,12 +170,15 @@
<Content Include="Pokemon.vcxproj.filters" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Header.hpp" />
<ClInclude Include="Game.hpp" />
<ClInclude Include="Grass.hpp" />
<ClInclude Include="Player.hpp" />
<ClInclude Include="Pokemon.hpp" />
<ClInclude Include="PokemonChoice.hpp" />
<ClInclude Include="PokemonType.hpp" />
<ClInclude Include="ProfessorOak.hpp" />
<ClInclude Include="Utility.hpp" />
<ClInclude Include="WildEncounterManager.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
27 changes: 24 additions & 3 deletions Pokemon/Pokemon.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,20 @@
<ClCompile Include="Pokemon.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ProfessorOak.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Game.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="WildEncounterManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BattleManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Header.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Player.hpp">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -47,5 +56,17 @@
<ClInclude Include="Pokemon.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ProfessorOak.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Grass.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Game.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WildEncounterManager.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
Binary file modified Pokemon/Pokemon/x64/Debug/Pokemon.ilk
Binary file not shown.
5 changes: 3 additions & 2 deletions Pokemon/Pokemon/x64/Debug/Pokemon.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
 main.cpp
Pokemon.vcxproj -> C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\x64\Debug\Pokemon.exe
 Game.cpp
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Game.cpp(10,39): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'Pokemon'
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Game.cpp(10,84): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'Pokemon'
Binary file modified Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.command.1.tlog
Binary file not shown.
Binary file modified Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.write.1.tlog
Binary file not shown.
4 changes: 4 additions & 0 deletions Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\BattleManager.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\BattleManager.obj
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Game.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Game.obj
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\main.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\main.obj
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Player.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Player.obj
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Pokemon.obj
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\ProfessorOak.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\ProfessorOak.obj
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Utility.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Utility.obj
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\WildEncounterManager.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\WildEncounterManager.obj
Binary file modified Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.command.1.tlog
Binary file not shown.
Binary file modified Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.read.1.tlog
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
^C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\MAIN.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\PLAYER.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\POKEMON.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\UTILITY.OBJ
^C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\BATTLEMANAGER.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\GAME.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\MAIN.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\PLAYER.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\POKEMON.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\PROFESSOROAK.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\UTILITY.OBJ|C:\USERS\WASIS\ONEDRIVE\DESKTOP\MY REPOS\POKEMON\POKEMON\POKEMON\X64\DEBUG\WILDENCOUNTERMANAGER.OBJ
C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Pokemon.ilk
Binary file modified Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.write.1.tlog
Binary file not shown.
Empty file.
Binary file modified Pokemon/Pokemon/x64/Debug/vc143.idb
Binary file not shown.
Binary file modified Pokemon/Pokemon/x64/Debug/vc143.pdb
Binary file not shown.
3 changes: 3 additions & 0 deletions Pokemon/PokemonType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ enum class PokemonType {
GRASS,
WATER,
ELECTRIC,
POISON,
BUG,
ROCK,
NORMAL // Added for the default constructor
};
Loading