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
7 changes: 7 additions & 0 deletions Pokemon/PokemonChoice.hpp
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
};
8 changes: 8 additions & 0 deletions Pokemon/PokemonType.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Define an enum for Pokemon types
enum class PokemonType {
FIRE,
GRASS,
WATER,
ELECTRIC,
NORMAL // Added for the default constructor
};
20 changes: 20 additions & 0 deletions Pokemon/Utility.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "Utility.hpp"
#include <iostream>

using namespace std;

void Utility::clearConsole(){
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
}

void Utility::waitForEnter(){
cin.get();
}

void Utility :: clearInputBuffer() {
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
6 changes: 6 additions & 0 deletions Pokemon/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
}
Binary file added Pokemon/main
Binary file not shown.
276 changes: 275 additions & 1 deletion Pokemon/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,280 @@
#include <iostream>
#include <string>
#include "PokemonType.hpp"
#include "PokemonChoice.hpp"
#include "Utility.hpp"

using namespace std;

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

// Default constructor
Pokemon() {
name = "Unknown";
type = PokemonType::NORMAL;
health = 50;
}

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

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

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

void attack() { std::cout << name << " attacks with a powerful move!\n"; }
};

// Player class definition
class Player {
public:
string name;
Pokemon chosenPokemon;

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

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

void 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;
}
cout << "Player " << name << " chose " << chosenPokemon.name << "!\n";
Utility::waitForEnter(); // Wait for user to press Enter before proceeding
}
};

// ProfessorOak class definition
class ProfessorOak {
public:
string name;

// Parameterized constructor
ProfessorOak(string p_name) { name = p_name; }

void 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 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
<< "! 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();
}

// New method for the main quest conversation
void 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();
}
};

// Function to handle the main game loop
void 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;

// Clear the newline character left in the buffer after cin >> choice
cin.ignore(numeric_limits<streamsize>::max(), '\n');


// Process the player's choice and display the corresponding message
switch (choice) {
case 1:
cout << "You look around... but all the wild Pokémon are on "
"vacation. Maybe try again later?\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";
}

int main() {
// Create Pokemon and Player objects for the game
Pokemon charmander("Charmander", PokemonType::FIRE,
100); // Using parameterized constructor

// Continue with the main flow of the game
ProfessorOak professor("Professor Oak");
Player player("Ash", charmander);

// Greet the player and offer Pokemon choices
professor.greetPlayer(player);
professor.offerPokemonChoices(player);

// Explain the main quest
professor.explainMainQuest(player);

// Start the main game loop
gameLoop(player);

return 0;
return 0;
}

27 changes: 27 additions & 0 deletions Pokemon/mys.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
#include <string> // include for to_string
using namespace std;

void castSpell(int magicLevel)
{
cout << "Casting spell with magic level: " << to_string(magicLevel) << endl;
}

void brewElixer(int &magicLevel){
magicLevel += 10;
castSpell(magicLevel);
}

void brewPotion(int magicLevel){
magicLevel += 50;
castSpell(magicLevel);
}

int main()
{
int magicLevel = 30;
brewElixer(magicLevel); // Pass by reference: modifies original
brewPotion(magicLevel); // Pass by value: does not modify original
cout << magicLevel;
return 0;
}
Binary file added Pokemon/naim
Binary file not shown.
Binary file added Pokemon/scroll
Binary file not shown.
18 changes: 18 additions & 0 deletions Pokemon/scroll.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include<iostream>
using namespace std;

void waitForEnter(){
cin.get();
}

int main(){
cout << "Hello , I am Professor Oak." << endl;
waitForEnter();
cout << "I want to take rest." << endl;
waitForEnter();
cout << "I have to Enjoy this winter." << endl;
waitForEnter()
cout << "I want to eat Pizza." << endl;

return 0;
}