Conversation
submission for review
Game.cs
Outdated
| "As you push open the rustic wooden doors, the air thickens. The Orcs throne glistens from the dying flame in the centre of the floor. " + | ||
| "The rugged red carpet underneath your feet tears as you tread into the room, the breeze from the hall follows you in giving life back to the now roaring fire. " + | ||
| "The room, now engulfed in a flickering light, uncovers the throne room from its dark veil ... you decide to explore the room." | ||
| ); |
There was a problem hiding this comment.
Very nice that the player can select their own name if they want
Game.cs
Outdated
| while (currentRoom.HasRemainingItems()) | ||
| { | ||
| Console.WriteLine("Where would you like to check out? Choose an option by number:"); | ||
| currentRoom.ShowLocations(); | ||
|
|
||
| int choice = GetUserChoice(); | ||
| // Valid index check (user enters 1-4) | ||
| if (choice < 1 || choice > currentRoom.Locations.Count) | ||
| { | ||
| Console.WriteLine("Invalid option. Please choose a valid number."); | ||
| continue; | ||
| } | ||
|
|
||
| // Pick up the item (if available) from the chosen location. | ||
| string itemFound = currentRoom.PickUpItemFromLocation(choice - 1); | ||
| if (itemFound != null) | ||
| { | ||
| player.PickUpItem(itemFound); | ||
| } | ||
| Console.WriteLine("\nPlayer Status:"); | ||
| Console.WriteLine(player.GetStatus()); | ||
| Console.WriteLine(); | ||
| } |
Game.cs
Outdated
| int option; | ||
| if (int.TryParse(input, out option)) | ||
| { | ||
| // Code your playing logic here | ||
| return option; | ||
| } | ||
| return -1; |
There was a problem hiding this comment.
int.TryParse's function doesnt need an if statement, it will either return 0 or the number inputted for that variable
Try changing this whole block to just int.TryParse(input, out int option)
There was a problem hiding this comment.
Good use of OOP to further abstract the location of the rooms
There was a problem hiding this comment.
Code Review
William Viziteu - 29171215
- Code works well and runs without crashing, with good error handling
- Readability is difficult at times, try also to use XML comments instead
- Good use of basic OOP techniques
- Implemented a story to the game
bofagit
left a comment
There was a problem hiding this comment.
Overall, you have successfully implemented the requirements of the brief to your game. The code runs well and is quite efficient. You have made good use of methods and encapsulation throughout your code.
I would recommend adding more comments to your Player class to further explain what your code does, as well as expanding on previous comments.
I would also recommend changing your naming conventions as I mentioned in the Player class; PascalCase for public members ect.
Nice work.
| public class Location | ||
| { | ||
| public string Name { get; private set; } | ||
| public string Description { get; private set; } | ||
| public string Item { get; private set; } | ||
|
|
||
| public Location(string name, string description, string item) | ||
| { | ||
| Name = name; | ||
| Description = description; | ||
| Item = item; | ||
| } |
There was a problem hiding this comment.
Good use of encapsulation in the class.
Game.cs
Outdated
| currentRoom = new Room( | ||
| "As you push open the rustic wooden doors, the air thickens. The Orcs throne glistens from the dying flame in the centre of the floor. " + | ||
| "The rugged red carpet underneath your feet tears as you tread into the room, the breeze from the hall follows you in giving life back to the now roaring fire. " + | ||
| "The room, now engulfed in a flickering light, uncovers the throne room from its dark veil ... you decide to explore the room." | ||
| ); |
There was a problem hiding this comment.
Detailed description of the room is good. You could potentially add a method to the Room.cs file to pick from a random selection of descriptions to create a randomly generated start.
Room.cs
Outdated
| public string PickUpItemFromLocation(int index) | ||
| { | ||
| Location loc = Locations[index]; | ||
| if (loc.Item != null) | ||
| { | ||
| Console.WriteLine($"\nYou travel to the {loc.Name} and find a {loc.Item}!"); | ||
| return loc.PickUpItem(); | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine($"\nYou travel to the {loc.Name} but find nothing of value."); | ||
| return null; | ||
| } | ||
| } |
There was a problem hiding this comment.
Good use of the list of items to check if there are items or not in the area.
| public class Player | ||
| { | ||
| public string Name { get; private set; } | ||
| public int Health { get; private set; } | ||
| private List<string> inventory = new List<string>(); | ||
| private string name; | ||
| private int health; | ||
| private List<string> inventory; |
There was a problem hiding this comment.
Great use of encapsulation here to get and set the values of the player.
| public class Player | ||
| { | ||
| public string Name { get; private set; } | ||
| public int Health { get; private set; } | ||
| private List<string> inventory = new List<string>(); | ||
| private string name; | ||
| private int health; | ||
| private List<string> inventory; |
There was a problem hiding this comment.
Your naming conventions here are a little inconsistent in some of your classes, maybe try PascalCase for public members, and lowercase for private.
Tasha53
left a comment
There was a problem hiding this comment.
Overall your code is very well written and commented making it easy to follow. The game also runs smoothly and has some good features, making it fun to play. A few additions which may give your game more depth would be to include monsters in some of the locations for the player to fight and maybe implement a difficulty selector, so the player can choose to play on easy, medium or hard mode - the difficulty could determine the abundance and strength of the monsters.
Game.cs
Outdated
| Console.WriteLine("\nGame started...\n"); | ||
|
|
||
| // Display the room's description. | ||
| Console.WriteLine(currentRoom.GetDescription()); |
There was a problem hiding this comment.
good use of a function for the description of the room - keeps the code tidy
Game.cs
Outdated
| // Show travel options until all items have been collected. | ||
| while (currentRoom.HasRemainingItems()) | ||
| { | ||
| Console.WriteLine("Where would you like to check out? Choose an option by number:"); |
There was a problem hiding this comment.
I like how the user can choose different locations to explore - adds depth to the game and gives each round some uniqueness.
Room.cs
Outdated
| // Create four locations with specific items. | ||
| Locations = new List<Location> | ||
| { | ||
| new Location("Warped Wooden Table", "A creaky wooden table, scarred by time.", "Healing Chalice"), |
There was a problem hiding this comment.
Nice detailed descriptions of different locations
Room.cs
Outdated
| } | ||
|
|
||
| // When a location is visited, pick up the item if available. | ||
| public string PickUpItemFromLocation(int index) |
There was a problem hiding this comment.
I like the idea that the player has to collect all of the items, however to give the game more depth you could have some locations generate with a monster that the player can battle. This would also give items such as health potions some functionality as the player could use the items to heal after battles
Game.cs
Outdated
| // Valid index check (user enters 1-4) | ||
| if (choice < 1 || choice > currentRoom.Locations.Count) | ||
| { | ||
| Console.WriteLine("Invalid option. Please choose a valid number."); |
There was a problem hiding this comment.
Good error checking to ensure the user gives a valid input
Final Commit
code for review