Assignment 2 development#2
Open
ciaranparker wants to merge 11 commits into
Open
Conversation
… player in the games class as well as some user input for movement using if else statements. I also included the pick up item function in the player class to allow the user to pick up an item and add it to inventory as well as a function to view the inventory contents and the player information.
… the room. The item is then added to the players inventory and the contents of the inventory is then displayed. The user is also required to enter appropriate inputs for player movements, requesting an appropriate input be entered if an inappropriate input is entered. I have also added break at the end of the while playing loop to prevent the content in the loop to keep looping.
…emy attack each other, dealing random damage. Player which reached 0 or less health first dies and loses. Changed the health to public setter so that can be changed in the main game code. I also put the looting of the room code into a while loop so that I could break the loop when the user picks up an item, preventing the code from repeating unless the user does not enter a correct input.
…oop. This means that while the respective code is running if there is an inapproprriate input the exception will be recognised and the error will be displayed to the user until they enter an appropriate input. I also made the boolean playing false when the user dies, so that the while playing loop ends when the user die allowing them to close the game.
…r the code does not endlessly loop
…enemy are below 0 the health is not displayed. This means that the user cannot see the health if it is in the negatives.
…l as the inventory. If the user enters the appropriate input the description/inventory will be displayed. I also added an item string which varies depending on the user input while looting, this should allow the item to be used if required incase new needs from the game in the future.
…ecific parts of the code. I have also created a test class to return an error message and called this method of the class in a debug.Assert. Therefore whenever there is a certain bug the error message will appear.
…he room class includes 3 items. These items can then be initialized in the game class and displayed and added to inventory.
…r overwhelming, making it easier to read. I have also added logical or in if statements so that if a user enters a lowercase letter instead of capital it still runs. I also added the \n feature in some writeline statements so that it is not as overwhelming and easier to read in the terminal. I also added the items to the room class and defined them in the game class when the room was initialized. This will allow me to create different items for different rooms and easily reuse the items throughout the code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.