diff --git a/Pokemon/Player.cpp b/Pokemon/Player.cpp new file mode 100644 index 00000000..fc82cefe --- /dev/null +++ b/Pokemon/Player.cpp @@ -0,0 +1,34 @@ +#pragma once +#include "Player.hpp" +#include +using namespace std; + + +Player::Player() { + name = "Trainer"; + chosenPokemon = Pokemon(); // Using the default Pokemon constructor +} + +Player::Player(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; + } + cout << "Player " << name << " chose " << chosenPokemon.name << "!\n"; + Utility::waitForEnter(); // Wait for user to press Enter before proceeding +} \ No newline at end of file diff --git a/Pokemon/Player.hpp b/Pokemon/Player.hpp new file mode 100644 index 00000000..6089fdb6 --- /dev/null +++ b/Pokemon/Player.hpp @@ -0,0 +1,25 @@ +#pragma once +#include +#include +#include "PokemonType.hpp" +#include "PokemonChoice.hpp" +#include "Utility.hpp" +#include "Pokemon.hpp" +using namespace std; + +class Pokemon; + +class Player { +public: + string name; + Pokemon chosenPokemon; + + // Default constructor + Player(); + + // Parameterized constructor + Player(string p_name, Pokemon p_chosenPokemon); + + + void choosePokemon(int choice); +}; \ No newline at end of file diff --git a/Pokemon/Pokemon.cpp b/Pokemon/Pokemon.cpp new file mode 100644 index 00000000..371886cb --- /dev/null +++ b/Pokemon/Pokemon.cpp @@ -0,0 +1,33 @@ +#pragma once +#include +#include +#include +#include "Pokemon.hpp" +using namespace std; + + 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() { std::cout << name << " attacks with a powerful move!\n"; } \ No newline at end of file diff --git a/Pokemon/Pokemon.hpp b/Pokemon/Pokemon.hpp new file mode 100644 index 00000000..116d4522 --- /dev/null +++ b/Pokemon/Pokemon.hpp @@ -0,0 +1,27 @@ +#pragma once +#include +#include +#include +#include "PokemonType.hpp" +#include "PokemonChoice.hpp" +using namespace std; + +class Pokemon { +public: + string name; + PokemonType type; + int health; + + // Default constructor + Pokemon(); + + // Parameterized constructor + Pokemon(std::string p_name, PokemonType p_type, int p_health); + + // Copy constructor + Pokemon(const Pokemon& other); + + ~Pokemon(); + + void attack(); +}; \ No newline at end of file diff --git a/Pokemon/Pokemon.vcxproj b/Pokemon/Pokemon.vcxproj index 9e6331ef..ab142809 100644 --- a/Pokemon/Pokemon.vcxproj +++ b/Pokemon/Pokemon.vcxproj @@ -155,6 +155,9 @@ + + + @@ -162,6 +165,14 @@ + + + + + + + + diff --git a/Pokemon/Pokemon.vcxproj.filters b/Pokemon/Pokemon.vcxproj.filters index 644f8bee..a65475d3 100644 --- a/Pokemon/Pokemon.vcxproj.filters +++ b/Pokemon/Pokemon.vcxproj.filters @@ -18,5 +18,34 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.exe.recipe b/Pokemon/Pokemon/x64/Debug/Pokemon.exe.recipe index 174cf739..cdf3fded 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.exe.recipe +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.exe.recipe @@ -2,7 +2,7 @@ - C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\x64\Debug\Pokemon.exe + C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\x64\Debug\Pokemon.exe diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.ilk b/Pokemon/Pokemon/x64/Debug/Pokemon.ilk index e4b71c97..df4921c9 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.ilk and b/Pokemon/Pokemon/x64/Debug/Pokemon.ilk differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.log b/Pokemon/Pokemon/x64/Debug/Pokemon.log index e8098c7a..72912f4a 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.log +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.log @@ -1,2 +1,2 @@  main.cpp - Pokemon.vcxproj -> C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\x64\Debug\Pokemon.exe + Pokemon.vcxproj -> C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\x64\Debug\Pokemon.exe diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.command.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.command.1.tlog index 3e0a2a6e..ba9ef440 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.command.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.command.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.read.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.read.1.tlog index ef05d014..0321cbc6 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.read.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.read.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.write.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.write.1.tlog index 989f443d..19d28472 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.write.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/CL.write.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog index b4ab6a91..41ad9d1f 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Cl.items.tlog @@ -1 +1,4 @@ -C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\main.cpp;C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\Pokemon\x64\Debug\main.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\Utility.cpp;C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\Pokemon\x64\Debug\Utility.obj diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Pokemon.lastbuildstate b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Pokemon.lastbuildstate index 8b6bc897..beed68b5 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Pokemon.lastbuildstate +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/Pokemon.lastbuildstate @@ -1,2 +1,2 @@ PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.40.33807:TargetPlatformVersion=10.0.22621.0: -Debug|x64|C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\| +Debug|x64|C:\Users\wasis\OneDrive\Desktop\My repos\Pokemon\Pokemon\| diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.command.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.command.1.tlog index e808d322..966f28f3 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.command.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.command.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.read.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.read.1.tlog index 100191ee..1613e2e1 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.read.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.read.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.secondary.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.secondary.1.tlog index 8274f392..ec39e7c3 100644 --- a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.secondary.1.tlog +++ b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.secondary.1.tlog @@ -1,2 +1,2 @@ -^C:\USERS\WASIS\DESKTOP\PROJECT\DUCK_HUNT\POKEMON\POKEMON\POKEMON\X64\DEBUG\MAIN.OBJ -C:\Users\wasis\Desktop\Project\Duck_Hunt\Pokemon\Pokemon\Pokemon\x64\Debug\Pokemon.ilk +^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\Pokemon.ilk diff --git a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.write.1.tlog b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.write.1.tlog index c4ad2b8b..7ff96532 100644 Binary files a/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.write.1.tlog and b/Pokemon/Pokemon/x64/Debug/Pokemon.tlog/link.write.1.tlog differ diff --git a/Pokemon/Pokemon/x64/Debug/vc143.idb b/Pokemon/Pokemon/x64/Debug/vc143.idb index f4f9a2f9..a24d216f 100644 Binary files a/Pokemon/Pokemon/x64/Debug/vc143.idb and b/Pokemon/Pokemon/x64/Debug/vc143.idb differ diff --git a/Pokemon/Pokemon/x64/Debug/vc143.pdb b/Pokemon/Pokemon/x64/Debug/vc143.pdb index 31fd2907..5a607333 100644 Binary files a/Pokemon/Pokemon/x64/Debug/vc143.pdb and b/Pokemon/Pokemon/x64/Debug/vc143.pdb differ diff --git a/Pokemon/PokemonChoice.hpp b/Pokemon/PokemonChoice.hpp new file mode 100644 index 00000000..d69dc90e --- /dev/null +++ b/Pokemon/PokemonChoice.hpp @@ -0,0 +1,7 @@ +#pragma once +enum class PokemonChoice { + CHARMANDER = 1, + BULBASAUR, + SQUIRTLE, + PIKACHU // Default choice +}; \ No newline at end of file diff --git a/Pokemon/PokemonType.hpp b/Pokemon/PokemonType.hpp new file mode 100644 index 00000000..f56102f3 --- /dev/null +++ b/Pokemon/PokemonType.hpp @@ -0,0 +1,8 @@ +#pragma once +enum class PokemonType { + FIRE, + GRASS, + WATER, + ELECTRIC, + NORMAL // Added for the default constructor +}; \ No newline at end of file diff --git a/Pokemon/Utility.cpp b/Pokemon/Utility.cpp new file mode 100644 index 00000000..37ef8c2f --- /dev/null +++ b/Pokemon/Utility.cpp @@ -0,0 +1,24 @@ +#pragma once +#include"Utility.hpp" +#include +#include +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::max(), '\n'); +} \ No newline at end of file diff --git a/Pokemon/Utility.hpp b/Pokemon/Utility.hpp new file mode 100644 index 00000000..0b41e490 --- /dev/null +++ b/Pokemon/Utility.hpp @@ -0,0 +1,7 @@ +#pragma once +class Utility { +public: + static void clearConsole(); + static void waitForEnter(); + static void clearInputBuffer(); // New helper function +}; \ No newline at end of file diff --git a/Pokemon/main.cpp b/Pokemon/main.cpp index c8ebdcb2..5162a332 100644 --- a/Pokemon/main.cpp +++ b/Pokemon/main.cpp @@ -1,114 +1,12 @@ #include #include // Include this header to use numeric_limits #include +#include"PokemonType.hpp" +#include"PokemonChoice.hpp" +#include"Utility.hpp" +#include"Player.hpp" using namespace std; -// Function to clear the console -void clearConsole() { - // Platform-specific clear console command -#ifdef _WIN32 - system("cls"); -#else - (void)system("clear"); -#endif -} - -// Function to wait for user to press Enter -void waitForEnter() { - cin.get(); // Wait for Enter key -} - -// Define an enum for Pokemon choices -enum class PokemonChoice { - CHARMANDER = 1, - BULBASAUR, - SQUIRTLE, - PIKACHU // Default choice -}; - -// Define an enum for Pokemon types -enum class PokemonType { - FIRE, - GRASS, - WATER, - ELECTRIC, - NORMAL // Added for the default constructor -}; - -// 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"; - waitForEnter(); // Wait for user to press Enter before proceeding - } -}; - // ProfessorOak class definition class ProfessorOak { public: @@ -119,12 +17,12 @@ class ProfessorOak { void greetPlayer(Player& player) { cout << name << ": Hello there! Welcome to the world of Pokemon!\n"; - waitForEnter(); + Utility::waitForEnter(); cout << name << ": My name is Oak. People call me the Pokemon Professor!\n"; - waitForEnter(); + Utility::waitForEnter(); cout << name << ": But enough about me. Let's talk about you!\n"; - waitForEnter(); + Utility::waitForEnter(); } void offerPokemonChoices(Player& player) { @@ -134,17 +32,17 @@ class ProfessorOak { getline(std::cin, player.name); cout << name << ": Ah, " << player.name << "! What a fantastic name!\n"; - waitForEnter(); + Utility::waitForEnter(); cout << name << ": You must be eager to start your adventure. But first, " "you’ll need a Pokemon of your own!\n"; - waitForEnter(); + Utility::waitForEnter(); // Presenting Pokemon choices cout << name << ": I have three Pokemon here with me. They’re all quite feisty!\n"; - waitForEnter(); + 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"; @@ -157,66 +55,66 @@ class ProfessorOak { cin >> choice; player.choosePokemon(choice); - waitForEnter(); + Utility::waitForEnter(); } // New method for the main quest conversation void explainMainQuest(Player& player) { // Clear the console - clearConsole(); + Utility::clearConsole(); cout << "Professor Oak: " << player.name << "!, I am about to explain you about your upcoming grand " "adventure.\n"; - waitForEnter(); + 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"; - waitForEnter(); + 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"; - waitForEnter(); + Utility::waitForEnter(); cout << "\n" << player.name << ": Wait... that sounds a lot like every other Pokémon game " "out there...\n"; - waitForEnter(); + Utility::waitForEnter(); cout << "Professor Oak: Shhh! Don't break the fourth wall, " << player.name << "! This is serious business!\n"; - waitForEnter(); + 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"; - waitForEnter(); + 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"; - waitForEnter(); + Utility::waitForEnter(); cout << "\n" << player.name << ": Sounds like a walk in the park... right?\n"; - waitForEnter(); + 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"; - waitForEnter(); + Utility::waitForEnter(); cout << "\nProfessor Oak: So, what do you say? Are you ready to " "become the next Pokémon Champion?\n"; - waitForEnter(); + Utility::waitForEnter(); cout << "\n" << player.name << ": Ready as I’ll ever be, Professor!\n"; - waitForEnter(); + Utility::waitForEnter(); cout << "\nProfessor Oak: That’s the spirit! Now, your journey begins...\n"; - waitForEnter(); + 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"; - waitForEnter(); + Utility::waitForEnter(); } }; @@ -227,7 +125,7 @@ void gameLoop(Player& player) { while (keepPlaying) { // Clear console before showing options - clearConsole(); + Utility::clearConsole(); // Display options to the player cout << "\nWhat would you like to do next, " << player.name << "?\n"; @@ -279,7 +177,7 @@ void gameLoop(Player& player) { // Wait for Enter key before the screen is cleared and the menu is shown // again - waitForEnter(); + Utility::waitForEnter(); } cout << "Goodbye, " << player.name << "! Thanks for playing!\n"; @@ -305,4 +203,6 @@ int main() { gameLoop(player); return 0; -} \ No newline at end of file +} + +//test \ No newline at end of file diff --git a/Pokemon/x64/Debug/Pokemon.pdb b/Pokemon/x64/Debug/Pokemon.pdb index 9f54d85f..d3c8925f 100644 Binary files a/Pokemon/x64/Debug/Pokemon.pdb and b/Pokemon/x64/Debug/Pokemon.pdb differ