Development#1
Conversation
|
I like the use of encapsulation, the use of getters and setters, and the overall idea of the code to layout the game design. |
| case RoomT.passive: | ||
| description += " | PASSIVE ZONE |"; | ||
| break; | ||
| case RoomType.normal: | ||
| description += " | NORMAL ROOM |"; | ||
| break; | ||
| case RoomType.encounter: | ||
| description += " | ENCOUNTER ROOM |"; | ||
| break; | ||
|
|
||
| case RoomType.Store: | ||
| description += " | STORE ROOM |"; | ||
| break; | ||
|
|
||
| case RoomType.Event: | ||
| description += " | EVENT ROOM |"; | ||
| break; | ||
| default: | ||
| break; | ||
|
|
||
| } | ||
|
|
||
| this.description = description; | ||
|
|
||
| this.roomT = roomT; | ||
| } | ||
|
|
||
|
|
||
| public string GetDescription() { | ||
|
|
||
| return description; | ||
| } | ||
|
|
There was a problem hiding this comment.
Add more comments! Make it clearer what the code is doing.
Legopeeps
left a comment
There was a problem hiding this comment.
Overall, good pieces of code here, should get the job done. Looking at the requirements, it's clear that abstraction and encapsulation have been applied throughout to make quite a robust application. Error checking is evident, the code makes use of Object Oriented featrures as well as methods and classes. Add more comments throughout though I kept getting lost in the spaghetti code, and I saw you started using .XML Commenting Standards about midway down - keep that up they are very useful !!
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace DungeonExplorer.Player { |
There was a problem hiding this comment.
Interesting use of folders within the project, with a prototype of this size I wouldn't have expected it but it does future-proof the project
| public const int MAX_HEALTH = 100; | ||
| public const int MAX_DAMAGE = 40; | ||
| public string Name { get; set; } | ||
| public int Health { get; set; } | ||
| public int Damage { get; set; } | ||
| private List<Item.Item> inventory = new List<Item.Item>(); |
There was a problem hiding this comment.
using encapsulation for these variables and object, the ideas have been abstracted down well
| public Player(string name, int health, int damage) | ||
| { | ||
| Name = name; | ||
| Health = health; | ||
| Damage = damage; | ||
| } |
There was a problem hiding this comment.
initialising the values, nicely done
| public void UseItem(Item.Item item) | ||
| { | ||
| // item usage logic here | ||
| if (InventoryContents().Contains(item)) | ||
| { | ||
| Console.WriteLine($"{Name} uses {item.Name}"); | ||
| // Apply item effects | ||
| item.Use(this); | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine($"{Name} does not have {item.Name}"); | ||
| } | ||
| } |
There was a problem hiding this comment.
.XML commenting standards could have been implemented here (and throughout) to make the document more readable
| { | ||
| // Initialize the game with one room and one player | ||
| Player = new Player.Player("Player", 100); | ||
| Player.PickUpItem(new DamageBooster()); |
There was a problem hiding this comment.
Comments could help aid ambiguity of what a DamageBooster is
| private bool HandlePlayerAction(string action) | ||
| { | ||
| // Method to handle player actions | ||
| if (int.TryParse(action, out int itemId)) | ||
| { | ||
| var item = Player.InventoryContents().FirstOrDefault(i => i.Id == itemId); | ||
| if (item != null && item.Useable) | ||
| { | ||
| Player.UseItem(item); | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine("Invalid action. Please try again."); | ||
| } | ||
| } | ||
| else if (action.Equals("move up", StringComparison.OrdinalIgnoreCase) || | ||
| action.Equals("move down", StringComparison.OrdinalIgnoreCase) || | ||
| action.Equals("move left", StringComparison.OrdinalIgnoreCase) || | ||
| action.Equals("move right", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| string direction = action.Split(' ')[1]; | ||
| if (!RoomManager.MovePlayer(direction, Player)) | ||
| { | ||
| Console.WriteLine("You can't move in that direction."); | ||
| } | ||
| } | ||
| else if (action.Equals("exit", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| return false; | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine("Invalid action. Please try again."); | ||
| } | ||
| return true; | ||
| } |
There was a problem hiding this comment.
this needs more comments all around even in the same style as the rest of the class, however shows good signs, from what I can tell, of error checking. Looks robust to say the least.
|
|
||
| /// Represents a Damage Booster item. | ||
|
|
||
| public class DamageBooster : Item { |
There was a problem hiding this comment.
inheriting from the item class, highlighting further encapsulation through inheritance
| /// Uses the Damage booster on the player. | ||
|
|
||
| /// <param name="player">The player to use the Talisman on.</param> |
There was a problem hiding this comment.
started using .xml commenting here, could have been throughout the whole doc
| protected Item(string name, string description, bool useable) | ||
| { | ||
| Name = name; | ||
| Description = description; | ||
| Useable = useable; | ||
| Id = nextId++; | ||
| } |
There was a problem hiding this comment.
very robust way of creating items through object instantiation
| public enum RoomType | ||
| { | ||
| Safe, | ||
| Normal, | ||
| Boss, | ||
| Shop, | ||
| Event | ||
| } |
There was a problem hiding this comment.
very nice touch using enums
No description provided.