You are tasked with creating a basic treasure hunt game in
C
, where players navigate a map to find hidden treasures using command-line inputs.
You should design your code to be
defensive
and handle a range of errors in a graceful way, without crashing unexpectedly. Consider the full range of mistakes which a user could make when trying to run the program.
iuww520iuww520iuww520iuww520iuww520iuww520iuww520iuww520
Treasure Island Game
The game loads a map file, which is provided on the command line in the format:
./island <mapfilepath> <dimension>
A map file can contain:
And is always a square with the width and height
dimension
which is also provided on the command line.
The game involves the player moving around the island looking for hidden treasure. The player can move using the WASD keys (w/W = up, a/A = left, s/S = down, d/D = right) or display a map using the m/M key.
The locations of the hidden treasure and the starting point should
not
be shown by the map, these should be showed by blank spaces ‘ ‘.
When the player finds the hidden treasure, they should receive some message telling them how many they have found such as ‘You have found 1 out of 3 hidden treasures’.
When the player has found all 3 hidden treasures, they have won and the game ends successfully.
There is no exit or quit option, so the only way to complete the game is to find all treasures.
Return codes and Outputs to the User
Any outputs such as error messages can be any text you like, as the grader does not read them.
However, there are certain return codes which you have to use:
0 = success (the game was able to run correctly)
1 = argument error (bad number of arguments, or bad dimension)
2 = file error (the file cannot be read – doesn’t exist or no read permissions)
3 = data error (the file is not a valid map)
Where an error could fall into multiple categories, the autograder will accept either – or you can ask me via Teams.