Write a program using an object
Start to create your object-oriented text-based adventure game
Extend other people’s classes
Create an enemy in the room
Recap Week 3
Extending your knowledge of OOP
Finish your game
End of the course
Now it’s time to finish writing your game and put all the concepts you have learnt about into practice. Here are some ideas for things you might want to do. I’ll show my example solutions in the next step so that you can see how I solved these challenges.
Add the Item class you wrote in week two to your game. Follow the same process as for the Character class: add an attribute to Room so that it can store an Item, and then create the Item and assign it to the Room. Inside the game loop, check whether there is an Item in the room, and if so, describe it.
Add a backpack to allow the player to store items. This can be a list in the main part of the program, rather than a separate class:
backpack = [ ]
When a player enters a room that contains an Item, the command ‘take’ should put the name of the current room’s Item into the backpack, and also set the Item attribute of the Room to None.
Change your game so that when the player chooses an item to use in a fight, the game checks whether the player actually has an item with that name in their backpack.
Use a class variable to allow the player to win the game only after they have defeated a specific number of enemies, rather than winning it the instant they defeat a single enemy.