CMSC 202 Project 2 – Pokémon

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (4 votes)

1. Overview
In this project you will:
• Write a program using classes and objects
• Use vectors to manage your data
• Incorporate file I/O to help manage your data
• Use pass-by-value and pass-by-reference for parameters
2. Background
For this project, we are going to be designing a simple implementation of the famous Pokémon franchise. If you are not familiar with Pokémon, it is a game where you act as a trainer of pocket monsters (Pokémon). You search the world in hopes of finding powerful Pokémon. Additionally, you can train the Pokémon once you have caught them. Finally, after you have found some Pokémon, you can battle them against other people.
There are two pieces of information that are important in this game. The first is the list of all of the Pokémon that are available. Currently, there are 151 Pokémon available in the pokeDex.txt file (which is provided). The information about each of the Pokémon provided includes their number (1-151), their name, their maximum combat points, their minimum combat points, and their rarity (1-5). **For Pokémon fans – the numbers used in this project are pretty random and do not represent actual Pokémon values!
The second piece of important information is the list of Pokémon that the user has managed to catch. A user has the ability go out and try and catch a Pokémon but the more powerful the Pokémon is, the harder they are to catch! Once a user has caught a Pokémon, the information such as number (1-151), name, combat points (CP), hit points (HP), and their rarity (1-5) will be tracked. Additionally, even when a user quits the game, their collection of Pokémon should be saved to a file named myCollection.txt.
For our implementation of the game, we will be designing some basic functionality including: listing all available Pokémon, listing your collection of Pokémon, trying to catch Pokémon, training your Pokémon, and finally, battling against other Pokémon.
3. Assignment Description
Your assignment is to develop a Pokémon application that allows you to include some gaming aspects. The application should:
1. Load all available Pokémon into the pokeDex (which is a vector). The pokeDex is just a system that lists all available Pokémon by number and name. Load a user’s collection into the myCollection (which is a vector).
2. Have a main menu that asks the user if they want to:
a. What would you like to do?:
i. See the PokeDex
ii. See your collection
iii. Search for a new Pokémon
iv. Battle Your Pokémon
v. Train your Pokémon
vi. Exit
1. Upon exit, my collection should be saved to a file.

4. Requirements:
Initially, you will have to use the following files Pokemon.h, MyPokemon.h, pokeDex.txt, and proj2.h for the project. You can copy the files from Prof. Dixon’s folder at:
/afs/umbc.edu/users/j/d/jdixon/pub/cs202/proj2
To copy it into your project folder, just navigate to your project 2 folder in your home folder and use the command:
cp /afs/umbc.edu/users/j/d/jdixon/pub/cs202/proj2/*.* .
Notice the trailing period is required (it says copy it into this folder).
• The project must be completed in C++. You may not use any libraries or data structures that we have not learned in class. Libraries we have learned include , , , , , , and . You should only use namespace std. Although we haven’t discussed it in detail, you can use in order to access the random functions. Similarly, we use to access the time for our random number generator seed.
• For various parts of this project, you will be using a random number generator. To use the srand() and rand() you will need to #include and to seed srand() you will need to #include .
o The class notes on random numbers should help with this topic.
o value = rand() % max + min gives you a range between min and max.
o For example, exam1 = rand() % 100 + 1 gives you a range between 1 and 100.
• You must use the function prototypes as outlined in the proj2.h header file. The proj2.h file includes additional comments describing what the function is expected to do. You may not edit the proj2.h file. You can include the proj2.h file in your program by using #include “proj2.h” Additionally, you will need to use the Pokemon.h and MyPokemon.h as templates for your class definition files.
• You first need to write the functions for the classes (Pokemon.cpp and MyPokemon.cpp) based on the header files (Pokemon.h and MyPokemon.h) respectively:
o All of the getters simply return the corresponding member variable.
o All of the setters take in the new value and update the member variable (with no checks).
o Train() – simply adds 10 CP to the Pokémon. Updates the CP of the Pokémon that trained and what their new CP is.
• Next you need to code up the various functions that are called in the proj2.cpp file that are prototyped in proj2.h.
o mainMenu() – Provided in the proj2.cpp file. It must validate the choice to be in the valid range.
o getPokeDex(pokeDex) – Upon the loading of the application, takes a provided input file (pokeDex.txt) and imports it into a vector called pokeDex. Made up of Pokemon objects.
o getMyCollection(myCollection) – Upon the loading of the application, takes a provided input file (myCollection.txt) and imports it into a vector called myCollection. Made up of MyPokemon objects.
o printPokeDex(pokeDex) – Prints (num and name) of all of the Pokémon in the pokeDex vector.
o printMyCollection(myCollection) – Prints (num, name, CP, HP, rarity) of the Pokémon in the myCollection vector.
o catchPokemon(pokeDex, myCollection) – Based on rarity, allows the user to try and catch a Pokémon. The more rare the Pokémon, the more difficult they are to catch.
o foundPokemon(rarity, pokeDex, myCollection) – Once a Pokémon is caught, it identifies which one (random based on rarity) and adds it to the myCollection vector. The combat points are a random number between the minimum combat points (CP) and the maximum combat points listed in the pokeDex. The hit points are based on 10% of the calculated CP.
o battlePokemon(pokeDex, myCollection) – Pits a random Pokémon from the pokeDex vector against a user’s owned Pokémon from the myCollection vector. Only compares CP and outputs if the user won or lost the battle.
o trainPokemon(pokeDex, myCollection) – Takes a specific Pokémon from the user collection and adds 10 CP to the Pokémon by calling the Train() member function.
o exitPokemon(myCollection) – Exits the application and calls saveMyCollection
o saveMyCollection(myCollection) – Uses file I/O to write out the entire myCollection vector to the myCollection.txt file.
o main() – Provided in the proj2.cpp file.

5. Sample Input and Output
5.1. Input
The input file for this project includes a data file that has all 151 of the original Pokémon listed. The file, pokeDex.txt is one of the two text files that are used in this project. The data is num, name, minimum CP, maximum CP, and rarity.
1 Bulbasaur 321 1072 2
The second text file will be written to after the user has caught some Pokémon. The data in this file is slightly different and includes: num, name, combat points, hit points, and rarity.
93 Haunter 1311 90 3
5.2. Output
In the sample output below, user input is colored blue for clarity. After compiling and running the makefile, the output would look like this:
–bash-4.1$ ./proj2
What would you like to do?:
1. See the PokeDex
2. See your collection
3. Search for a new Pokemon
4. Battle Your Pokemon
5. Train your Pokemon
6. Exit
If the user would choose 1 then the output would look like this:
1 Bulbasaur
2 Ivysaur
3 Venusaur
4 Charmander
5 Charmeleon
6 Charizard
7 Squirtle
8 Wartortle
9 Blastoise
10 Caterpie
11 Metapod
12 Butterfree
13 Weedle
//13-148 HERE!
148 Dragonair
149 Dragonite
150 Mewtwo
151 Mew
What would you like to do?:
1. See the PokeDex
2. See your collection
3. Search for a new Pokemon
4. Battle Your Pokemon
5. Train your Pokemon
6. Exit
If you choose 2 (and you had already caught some Pokémon then it would look like this:
2
0. 27 Sandshrew 77 7 1
1. 27 Sandshrew 87 7 1
2. 27 Sandshrew 117 7 1
3. 27 Sandshrew 77 7 1
4. 27 Sandshrew 77 7 1
5. 93 Haunter 1311 90 3
6. 93 Haunter 1061 90 3
7. 43 Oddish 361 36 3
8. 63 Abra 601 60 1
9. 79 Slowpoke 1078 107 3
If you try and search for a Pokémon, it will ask you how rare you want to search. Very Common are found 65% per try, Common are found 45% per try, Uncommon are found 25% per try, Rare are found 10% per try, and Ultra Rare are found 1% per try. After you find a Pokémon, it is added to your collection.
3
What type of Pokemon would you like to try and catch?:
1. Very Common (Very High Probability)
2. Common (High Probability)
3. Uncommon (Normal Probability)
4. Rare (Low Probability)
5. Ultra Rare (Extremely Low Probability)
1
You start to search.
Congrats! You found a Geodude
What would you like to do?:
Battles (for this project) do not take into consideration hit points (HP) at all. They are just a comparison of combat points (CP).
If you are trying to battle by choosing 4 from the main menu, it should look like this:
4
0. 27 Sandshrew 77 7 1
1. 93 Haunter 1311 90 3
2. 93 Haunter 1061 90 3
3. 43 Oddish 361 36 3
4. 63 Abra 601 60 1
5. 79 Slowpoke 1078 107 3
6. 43 Oddish 1102 110 3
7. 82 Magneton 614 56 4
8. 82 Magneton 614 56 4
9. 122 MrMime 1009 100 3
10. 140 Kabuto 593 59 3
11. 140 Kabuto 593 59 3
12. 74 Geodude 278 27 1
13. 74 Geodude 278 27 1
You are going to fight a Nidorina
The enemy has a CP of 714
Which of your Pokemon would you like to use?:
1
You won!!
What would you like to do?:
Training (which is done by a call to the Train member function) adds 10 to the selected Pokémon. It should look like this:
5
Which of your Pokemon would you like to use?:
0. 27 Sandshrew 77 7 1
1. 93 Haunter 1311 90 3
2. 93 Haunter 1061 90 3
3. 43 Oddish 361 36 3
4. 63 Abra 601 60 1
5. 79 Slowpoke 1078 107 3
6. 43 Oddish 1112 110 3
7. 82 Magneton 614 56 4
8. 82 Magneton 614 56 4
9. 122 MrMime 1009 100 3
10. 140 Kabuto 593 59 3
11. 140 Kabuto 593 59 3
12. 74 Geodude 278 27 1
13. 74 Geodude 278 27 1
6
Your Oddish trained.
Your CP is now 1122.
What would you like to do?:
Finally, if the user tries to exit, the user’s collection should be saved out to the myCollection.txt file and the application should close with a quick note to the user.
What would you like to do?:
1. See the PokeDex
2. See your collection
3. Search for a new Pokemon
4. Battle Your Pokemon
5. Train your Pokemon
6. Exit
6
File Saved
Thank you for playing Pokemon UMBC
-bash-4.1$
6. Compiling and Running
Based on our practice this semester, you need to write your own makefile to compile and run your code. As there are two classes, you will need to create at least two object files after you compile the two classes. Your final output file should be proj2.
Once you have compiled using your makefile, enter the command ./proj2 to run your program. If your executable is not proj2, you will lose points. It should look like the sample output provided above.
7. Completing your Project
When you have completed your project, you can copy it into the submission folder. You can copy your files into the submission folder as many times as you like (before the due date). We will only grade what is in your submission folder.
For this project, you should submit these files to the proj2 subdirectory:
proj2.h — should be unchanged except if you choose to add additional constants.
proj2.cpp — should include your implementations of the required functions.
Pokemon.cpp – should include your implementations of the class functions
MyPokemon.cpp – should include your implementations of the class functions
As you should have already set up your symbolic link for this class, you can just copy your files listed above to the submission folder
b. cd to your project 2 folder. An example might be cd ~/202/projects/proj2
c. cp proj2.cpp proj2.h Pokemon.cpp MyPokemon.cpp ~/cs202proj/proj2
You can check to make sure that your files were successfully copied over to the submission directory by entering the command
ls ~/cs202proj/proj2
You can check that your program compiles and runs in the proj2 directory, but please clean up any .o and executable files. Again, do not develop your code in this directory and you should not have the only copy of your program here.
For additional information about project submissions, there is a more complete document available in Blackboard under “Course Materials” and “Project Submission.”
IMPORTANT: If you want to submit the project late (after the due date), you will need to copy your files to the appropriate late folder. If you can no longer copy the files into the proj2 folder, it is because the due date has passed. You should be able to see your proj2 files but you can no longer edit or copy the files in to your proj2 folder. (They will be read only)
• If it is 0-24 hours late, copy your files to ~/cs202proj/proj2-late1
• If it is 24-48 hours late, copy your files to ~/cs202proj/proj2-late2
• If it is after 48 hours late, it is too late to be submitted.