In this project, you will:
Subnautica is an open-world adventure game that was initially released Unknown Worlds Entertainment in 2014. The main character of the game (our Diver) starts after crash landing on a mostly ocean covered planet named 4546B. The player is wearing a simple scuba suit initially and wanders around the planet exploring areas and gathering resources to build new items. For this project, you will be required to create a text-based version of this game. You may see a graphical version of the game online here:
https://www.youtube.com/watch?v=BtP8r8nRfko
In this implementation of Subnautica, you will be implementing the role of the Diver. For our purposes, the Diver can search for basic materials (such as lead or titanium), combine basic material into advanced material, and then combine advanced material into unique diving equipment. The goal is to build equipment to allow us to exceed the 1000-meter mark for our diving depth.
Initially, you will need to read in a list of materials and recipes from a file and load them into an array of Materials. The list of materials is static, and you can assume that the size can be stored in a constant (PROJ2_SIZE). The diver does not start with anything but can start searching for raw materials. Anytime a raw material is found, it is added to the diver's collection of items. Then when a specific recipe is met (two pieces of quartz becomes one piece of glass, for example), the diver can try and merge two pieces of raw material to make an advanced material. Then two items (raw or advanced) can be combined to build a unique item that increases the divers depth. The list of all available combinations is available below in section 9 of this document.
This is a list of the requirements of this application. For this project, you will be provided with header files to start you in the right direction. For you to earn all the points, however, you will need to meet all the defined requirements.
You must use the provided header files (Material.h, Diver.h, and Game.h) additionally, we provided you with the makefile and the proj2.cpp.
Here are some general implementation recommendations (do not follow these verbatim - these are GENERAL suggestions):
For this project, the input file is very simple. The only input file is called proj2_data.txt. You can code the file name as a constant.
The columns for proj2_data.txt are as follows: material name, material type (raw, advanced, or unique), first material required to make, second material required to make, and depth boost.
Raw materials have no first and second materials to make and provide no depth boost. They can only be found by searching.
Advanced materials are an intermediate material that are made by combining two raw materials. They provide no depth boost.
Unique materials are a final material that are created by combining two materials. These unique materials can have a maximum quantity of one. Some unique materials are made up of other unique materials.
For example, Copper Ore is raw and can be found by searching (option 2 in the main menu). Copper Wire is Advanced and can be made by merging copper ore with copper ore. Finally, a radiation suit can be made by merging fiber mesh with lead. Once the radiation suit has been made, the current depth would increase by 100.
Copper Ore,raw,0,0,0
Diamond,raw,0,0,0
Gold,raw,0,0,0
Copper Wire,advanced,Copper Ore,Copper Ore,0
Wiring Kit,advanced,Silver Ore,Silver Ore,0
Enameled Glass,advanced,Stalker Teeth,Glass,0
Radiation Suit,unique,Fiber Mesh,Lead,100
Rebreather,unique,Wiring Kit,Fiber Mesh,100
Reinforced Dive Suit,unique,Synthetic Fibers,Diamond,100
In the sample output below, user input is colored blue for clarity. After compiling and running proj2, the output would look like this:
[jdixon@linux2 proj2]$ make run
./proj2
**Subnautica Art from GameTitle**
50 materials loaded.
What is the name of your Diver?
JD
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
If you were to display Diver's Materials, it would look like this:
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
1
1. Cave Sulfur 0
2. Copper Ore 0
3. Diamond 0
4. Gold 0
5. Lead 0
… **5-47 omitted for space**
48. Ultra High Capacity Tank 0
49. Beacon 0
50. Seaglide 0
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
If the user would choose 2, Search for Raw Materials, then the output would look like this:
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
2
Diamond Found!
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
2
Acid Mushroom Found!
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
2
Table Coral Sample Found!
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
2
Silver Ore Found!
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
If the user would choose 2, Attempt To Combine Materials, then choose something that we have in inventory:
Which materials would you like to merge?
To list known materials enter -1
9
Which materials would you like to merge?
To list known materials enter -1
9
Silver Ore combined with Silver Ore to make Wiring Kit!
Your diver has built Wiring Kit.
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
Here is an example where after we used our 2 silver ore to build a wiring kit, if we go back and try to build another wiring kit, we don't have any silver ore left so the game indicates this.
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
3
Which materials would you like to merge?
To list known materials enter -1
9
Which materials would you like to merge?
To list known materials enter -1
9
You do not have enough Silver Ore or Silver Ore to attempt that merge
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
Now when we go back to the diver's materials (their inventory), we are showing a wiring kit but no silver (which we used to make the wiring kit).
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
1
1. Cave Sulfur 1
2. Copper Ore 0
3. Diamond 2
4. Gold 0
5. Lead 0
6. Lithium 0
7. Quartz 0
8. Ruby 1
9. Silver Ore 0
10. Stalker Teeth 1
11. Titanium 0
12. Table Coral Sample 1
13. Acid Mushroom 1
**14-21 Removed for Space**
22. Battery 0
23. Computer Chip 0
24. Copper Wire 0
25. Wiring Kit 1
**26-49 Removed for Space**
50. Seaglide 0
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
Here is an example where of the See Score is selected. As the unique items that boost the depth are acquired, the current depth should increase. Once the current depth meets or exceeds the maximum depth, the game ends and the player wins.
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
4
***The Diver***
The Great Diver JD
Maximum Depth: 1000
Current Depth: 0
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
Here are some example runs where additional input validation is being shown and where the name of the diver has a space:
50 materials loaded.
What is the name of your Diver?
Ellen DeGeneres
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
6
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
0
What would you like to do?
1. Display your Diver's Materials
2. Search for Raw Materials
3. Attempt to Merge Materials
4. See Score
5. Quit
3
Which materials would you like to merge?
To list known materials enter -1
0
Which materials would you like to merge?
To list known materials enter -1
100
Which materials would you like to merge?
To list known materials enter -1
-1
1. Cave Sulfur 0
2. Copper Ore 0
3. Diamond 0
**3-50 removed for space**
There is a longer run of the game available as proj2_sample1.txt with the other files.