In this project you will:
For this project, we are going to be designing a simple implementation of the famous Pokemon franchise. If you are not familiar with Pokemon, it is a game where you act as a trainer of pocket monsters (Pokemon). You carefully choose the roster finding the perfect Pokemon to matchup against the computer. Finally, after you build your roster of Pokemon, you can battle them against the computer!
For this project, each node in our linked list is going to be a Pokemon. Each Pokemon has a name, an index, a type, and a type that it is strong against. The name, type, and strong are all strings and the index are an integer.
Our linked list is going to be a little bit special because it is designed to hold and manage Pokemon. We can insert Pokemon into the linked list, we can remove Pokemon from a specific location in our linked list, we can Attack Pokemon, we can Swap Pokemon, and a variety of other things.
Finally, the game itself will allow us to battle our roster of Pokemon against a randomly assigned roster of enemy Pokemon. The skill in this game is to find a preferable roster that can defeat the enemies. Each Pokemon has a strength and identifying that strength is required to defeat the enemies - especially when the enemies are stronger than we are!
Your assignment is to build an application that can allow us to battle two linked lists of Pokemon.
1.The input file will hold some number of Pokemon with the following order: index (int), name (string), type (string), and strong (string).
2.All Pokemon should be inserted at the end of the linked list.
3.The m_list holds all of the Pokemon for the entire game. A pocket is a linked list representing a team. The m_userPocket holds the user's Pokemon and the m_enemyPocket holds the enemy Pokemon.
4.The data file (proj3_data.txt) is loaded via command line argument (included in the provided makefile and proj3.cpp).
Figure 1. Input File Details see image.
5.When a Pokemon is added to either the m_userPocket or m_enemyPocket, it is permantently removed from m_list.
6.The user's pocket will be populated by asking the user to choose Pokemon for their team. After the user has chosen their pocket, the enemys pocket will be randomly populated from the remaining Pokemon.
7.Initially, each Pokemon team (user and enemy) will have 5 Pokemon. As a Pokemon is defeated, it is removed from the team. The battle (and game) ends when there are no Pokemon left on one of the teams.
8.All user inputs will be assumed to be the correct data type. For example, if you ask the user for an integer, they will provide an integer.
9.Regardless of the sample output below, all user input must be validated. If you ask for a number between 1 and 5 with the user entering an 8, the user should be re-prompted.
10.The general game flow:
Initially, you will have to use the following files Pokemon.h, PokemonList.h, Game.h, makefile, proj3.cpp, and a simple test file. You can copy the files from Prof. Dixon's folder at:
/afs/umbc.edu/users/j/d/jdixon/pub/cs202/proj3
To copy it into your project folder, just navigate to your project 3 folder in your home folder and use the command:
cp /afs/umbc.edu/users/j/d/jdixon/pub/cs202/proj3/* .
Notice the trailing period is required (it says copy it into this folder).
5.1.Sample Run
An additional file named proj3_sample1.txt is available in /afs/umbc.edu/users/j/d/jdixon/pub/cs202/proj3
A normal run of the compiled code would look like this with user input highlighted in blue:
[jdixon@linux4 proj3]$ make run
./proj3 proj3_data.txt
Welcome to the game
Here is a list of Pokemon you can choose from:
------------------------------
Index: 1 Name: Bulbasaur Type: Grass Health: 9
Index: 2 Name: Ivysaur Type: Grass Health: 9
**Index 3 to 149 Removed for Space**
Index: 150 Name: Mewtwo Type: Psychic Health: 9
Index: 151 Name: Mew Type: Psychic Health: 9
------------------------------
Pick a Pokemon by enter the index (5 left):
Here is an example where the user is starting a battle and they swap their Pokemon for a better matchup (the real way you win this game!).
Pick a pokemon by enter the index (1 left): 5
------------------------------
Print player pocket
Index: 1 Name: Bulbasaur Type: Grass Health: 9
Index: 2 Name: Ivysaur Type: Grass Health: 9
Index: 3 Name: Venusaur Type: Grass Health: 9
Index: 4 Name: Charmander Type: Fire Health: 9
Index: 5 Name: Charmeleon Type: Fire Health: 9
------------------------------
Print cpu pocket
Index: 143 Name: Snorlax Type: Normal Health: 9
Index: 77 Name: Ponyta Type: Fire Health: 9
Index: 117 Name: Seadra Type: Water Health: 9
Index: 23 Name: Ekans Type: Poison Health: 9
------------------------------
Round 1:
CPU's Pokemon: Snorlax (Normal:9 health)
Your Pokemon: Bulbasaur (Grass:9 health)
------------------------------
Menu:
1. Attack
2. Swap
3. Forfeit
2
------------------------------
Which Pokemon would you like to choose? (Enter the index#)
Index: 1 Name: Bulbasaur Type: Grass Health: 9
Index: 2 Name: Ivysaur Type: Grass Health: 9
Index: 3 Name: Venusaur Type: Grass Health: 9
Index: 4 Name: Charmander Type: Fire Health: 9
Index: 5 Name: Charmeleon Type: Fire Health: 9
4
------------------------------
Round 2:
CPU's Pokemon: Snorlax (Normal:9 health)
Your Pokemon: Charmander (Fire:9 health)
------------------------------
Menu:
1. Attack
2. Swap
3. Forfeit
Here is an example where the user forfeits.
Menu:
1. Attack
2. Swap
3. Forfeit
3
------------------------------
CPU won!!!
Here is an example with some validation.
Round 1:
CPU's Pokemon: Tangela (Grass:9 health)
Your Pokemon: Bulbasaur (Grass:9 health)
------------------------------
Menu:
1. Attack
2. Swap
3. Forfeit
0
Please enter a valid choice: 4
Please enter a valid choice: 5
Please enter a valid choice: 2
------------------------------
Which Pokemon would you like to choose? (Enter the index#)
Index: 1 Name: Bulbasaur Type: Grass Health: 9
Index: 23 Name: Ekans Type: Poison Health: 9
Index: 4 Name: Charmander Type: Fire Health: 9
Index: 5 Name: Charmeleon Type: Fire Health: 9
Index: 6 Name: Charizard Type: Fire Health: 9
7
This is not a valid index, please try again
1
choice is head
------------------------------
Round 2:
CPU's Pokemon: Tangela (Grass:9 health)
Your Pokemon: Bulbasaur (Grass:9 health)
------------------------------
Menu:
1. Attack
2. Swap
3. Forfeit
Because we are using a significant amount of dynamic memory for this project, you are required to manage any memory leaks that might be created. For a linked list, this is most commonly related to the dynamically allocated nodes. Remember, in general, for each item that is dynamically created, it should be deleted using a destructor.
One way to test to make sure that you have successfully removed any of the memory leaks is to use the valgrind command.
Since this project makes extensive use of dynamic memory, it is important that you test your program for memory leaks using valgrind:
valgrind ./proj3
Note: If you accidently use valgrind make run, you may end up with some memory that is still reachable. Do not test this - test using the command above where you include the input file. The makefile should include make val1 (which is ok).
If you have no memory leaks, you should see output like the following:
==5606==
==5606== HEAP SUMMARY:
==5606== in use at exit: 0 bytes in 0 blocks
==5606== total heap usage: 87 allocs, 87 frees, 10,684 bytes allocated
==5606==
==5606== All heap blocks were freed -- no leaks are possible
==5606==
==5606== For counts of detected and suppressed errors, rerun with: -v
==5606== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
The important part is "in use at exit: 0 bytes 0 blocks," which tells me all the dynamic memory was deleted before the program exited. If you see anything other than "0 bytes 0 blocks" there is probably an error in one of your destructors. We will evaluate this as part of the grading for this project.
Additional information on valgrind can be found here: http://valgrind.org/docs/manual/quick-start.html
Once you have compiled using your makefile, enter the command ./proj3 to run your program. You can use make val1 to test each of the input files using valgrind (do NOT use valgrind make run!). They have differing sizes. If your executable is not proj3, you will lose points. It should look like the sample output provided above.