Skip to content

Development#116

Open
Yoshae101 wants to merge 3 commits intocfrantzidis:masterfrom
Yoshae101:Development
Open

Development#116
Yoshae101 wants to merge 3 commits intocfrantzidis:masterfrom
Yoshae101:Development

Conversation

@Yoshae101
Copy link

code 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."
);
Copy link

@VizzWizz VizzWizz Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice that the player can select their own name if they want

Game.cs Outdated
Comment on lines +39 to +61
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();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good error checking

Game.cs Outdated
Comment on lines +72 to +77
int option;
if (int.TryParse(input, out option))
{
// Code your playing logic here
return option;
}
return -1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of OOP to further abstract the location of the rooms

Copy link

@VizzWizz VizzWizz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link

@bofagit bofagit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +3 to +14
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;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of encapsulation in the class.

Game.cs Outdated
Comment on lines +23 to +27
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."
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Comment on lines +52 to +65
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;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of the list of items to check if there are items or not in the area.

Comment on lines 6 to +10
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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great use of encapsulation here to get and set the values of the player.

Comment on lines 6 to +10
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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your naming conventions here are a little inconsistent in some of your classes, maybe try PascalCase for public members, and lowercase for private.

Copy link

@Tasha53 Tasha53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good error checking to ensure the user gives a valid input

Final Commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants