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

Game::Game() {
// Create a sample grass environment with actual Pokemon objects
forestGrass = { "Forest",
{Pokemon("Pidgey", PokemonType::NORMAL, 40),
Pokemon("Caterpie", PokemonType::BUG, 35),
Pokemon("Zubat", PokemonType::POISON, 30)},
70 };
}

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, but Nurse Joy is out on a coffee "
"break. Guess your Pok�mon will have to tough it out for now!\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;
}
}

// 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";
}
11 changes: 11 additions & 0 deletions Pokemon/Game.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "Grass.h"

class Player;

class Game {
private:
Grass forestGrass;
public:
Game();
void gameLoop(Player& player);
};
14 changes: 14 additions & 0 deletions Pokemon/Grass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "Grass.h"
#include"PokemonType.h"

Grass forestGrass = {
"Forest",
{{"Pidgey", PokemonType::NORMAL, 40}, {"Caterpie", PokemonType::BUG, 35}},
70
};

Grass caveGrass = {
"Cave",
{{"Zubat", PokemonType::POISON, 30}, {"Geodude", PokemonType::ROCK, 50}},
80
};
12 changes: 12 additions & 0 deletions Pokemon/Grass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<string>
#include<vector>
#include"Pokemon.h"
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

};

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

Pokemon::Pokemon():name("unknown"),type(PokemonType::NORMAL),health(50){}
// Parameterized constructor
Pokemon::Pokemon(string p_name, PokemonType p_type, int p_health): 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
}

void Pokemon::attack() { cout << name << " attacks with a powerful move!\n"; }
25 changes: 25 additions & 0 deletions Pokemon/Pokemon.h
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();
};
19 changes: 19 additions & 0 deletions Pokemon/Pokemon.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36310.24 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Pokemon", "Pokemon.vcxproj", "{872261CB-D6AC-488B-91C5-1B44032596F2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Header.h", "..\Header.h\Header.h.vcxproj", "{47FEE16B-AAEB-4576-91E7-3C9C5225D963}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand All @@ -18,5 +23,19 @@ Global
{872261CB-D6AC-488B-91C5-1B44032596F2}.Release|Win32.Build.0 = Release|Win32
{872261CB-D6AC-488B-91C5-1B44032596F2}.Release|x64.ActiveCfg = Release|x64
{872261CB-D6AC-488B-91C5-1B44032596F2}.Release|x64.Build.0 = Release|x64
{47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|Win32.ActiveCfg = Debug|Win32
{47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|Win32.Build.0 = Debug|Win32
{47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|x64.ActiveCfg = Debug|x64
{47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Debug|x64.Build.0 = Debug|x64
{47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|Win32.ActiveCfg = Release|Win32
{47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|Win32.Build.0 = Release|Win32
{47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|x64.ActiveCfg = Release|x64
{47FEE16B-AAEB-4576-91E7-3C9C5225D963}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AA496C07-30CF-4C3C-ABFF-0573647E3200}
EndGlobalSection
EndGlobal
10 changes: 10 additions & 0 deletions Pokemon/Pokemon.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,24 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="player.cpp" />
<ClCompile Include="PokemonChoice.cpp" />
<ClCompile Include="PokemonType.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="utility.cpp" />
</ItemGroup>
<ItemGroup>
<Content Include=".idea\.idea.Pokemon\.idea\indexLayout.xml" />
<Content Include=".idea\.idea.Pokemon\.idea\vcs.xml" />
<Content Include=".idea\.idea.Pokemon\.idea\workspace.xml" />
<Content Include="Pokemon.vcxproj.filters" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="player.h" />
<ClInclude Include="PokemonChoice.h" />
<ClInclude Include="PokemonType.h" />
<ClInclude Include="utility.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
26 changes: 26 additions & 0 deletions Pokemon/Pokemon.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,31 @@
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PokemonType.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PokemonChoice.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="utility.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="player.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="PokemonType.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PokemonChoice.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="utility.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="player.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions Pokemon/Pokemon.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
Empty file added Pokemon/PokemonChoice.cpp
Empty file.
7 changes: 7 additions & 0 deletions Pokemon/PokemonChoice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Define an enum for Pokemon choices
enum class PokemonChoice {
CHARMANDER = 1,
BULBASAUR,
SQUIRTLE,
PIKACHU // Default choice
};
1 change: 1 addition & 0 deletions Pokemon/PokemonType.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 11 additions & 0 deletions Pokemon/PokemonType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Define an enum for Pokemon types
enum class PokemonType {
FIRE,
GRASS,
WATER,
ELECTRIC,
NORMAL,
BUG,
POISON,
ROCK // Added for the default constructor
};
Loading