C++ Text adventure game , ANYONE WHO CAN GIVE ME A LOWER BID THAN £10 I MAY ACCEPT
For this work, you will be creating a simple game engine for a text adventure. Note that you are not required to write an actual adventure, only the back-end program code that would support one. You will need to add some material to the program in order to test it, but this may just be simple test material.
You are provided with a CLion project containing a very simple game harness which supports only two commands: going north (north or n), and quitting (quit). Extend it by doing the exercises below.
In the current system you can only move North. Extend the engine to allow movement in all four compass directions.
• Add properties to the Room class for storing east, south, and west exits. These properties will need accessor methods.
• Add code to the gameLoop method to understand the commands east, south, and west(and the abbreviations e, s and w) and to handle them in a similar way to north.
• Modify initRooms to create more rooms using the new exits in order to test your code.
• Can you find a more elegant way of implementing these exits without repeating code?
A key part of most text adventure games is the ability to move objects around. Objects can be found in rooms and can be picked up and put down by the player. Add this capability to the game engine.
• Create an GameObject class. It should contain at least a short name, a long description, and a keyword (for the player to use when typing commands).
• Extend the Room class so that each Room includes a list of GameObjects in the room.
• Extend the State class to include a list of GameObjects the player is carrying, called inventory.
• Extend the Room::describe() method to also print out the short names of all the objects in the room, formatted as nicely as possible.
• Modify the gameLoop method to pay attention to the second word of the command the player enters, if there is one.
• Modify the gameLoop command to search through a) objects in the current room, and b) objects in the inventory, for an object with a keyword matching the second word of the command the player typed.
• Implement the player command get which, when typed with an object keyword, will move that object from the current room list into the inventory. It should display appropriate errors if the object is not in the room or the object does not exist.
• Implement the player command drop which, when typed with an object keyword, will move that object from the inventory into the current room list.
• Implement the player command inventory which will print out the short names of all the objects in the inventory.
• Implement the player command examine which, when typed with an object keyword, will print out the long description of that object.
• Modify initRooms to create some GameObjects and put them in the rooms. Use this to test your program.
Since most players will not want to play an entire game at one sitting, most games include save and load (or restore) commands. Implement these commands. They should ask the user for a filename and then write or read the current game state, to or from that file.
Note that the layout and descriptions of rooms, and the list and descriptions of objects, are not part of the game state because they do not change during the game. These should not be included in the save file and saving them will lose marks.
Some important things to think about:
The “game state” may also include the locations of objects the player has dropped in rooms. Would it be a good idea to restructure how object locations are stored?
The State object stores the current room, and objects, using pointers. Pointers cannot safely be written to disk since addresses may be different when the program is reloaded. How can you enable this data to be safely saved and reloaded?