Conversation
| public Room CurrentRoom { get; private set; } | ||
|
|
||
| // the game map with connected rooms and contents | ||
| public void Initialize() |
There was a problem hiding this comment.
this method sets up the initial game environment
room creation
room connections (neighbors)
placing items and monsters
starting point
| } | ||
|
|
||
| // Move to the neighboring room based on direction | ||
| public void Move(string direction) |
There was a problem hiding this comment.
this method allows the player to navigate between rooms
if the direction the player is going is valid it updates "currentroom" to the new room
if the direction the player is going isnt valid it will print a message saying "you cant go that way" as stated in code
| @@ -0,0 +1,31 @@ | |||
| // Interface for anything that can take damage | |||
| public interface IDamageable | |||
There was a problem hiding this comment.
this interface is used for any object that can take damage - players and monsters
| } | ||
|
|
||
| // Interface for items that can be collected and used by the player | ||
| public interface ICollectible |
There was a problem hiding this comment.
this interface is for items that can be collected as well as used by the player - such as weapons and potions
| // File: Creature.cs | ||
|
|
||
| // Abstract base class for all creatures in the game | ||
| public abstract class Creature : IDamageable |
There was a problem hiding this comment.
base class for all living characters in the game (e.g. Player, Monster).
includes shared properties : name - the creatures name, health - their current health, IsAlive - a quick way to check if their health is above 0
| using System; | ||
|
|
||
| // Monster class inherits from Creature and represents enemies | ||
| public class Monster : Creature |
There was a problem hiding this comment.
declares a public class named Monster.
inherits from the abstract base class Creature, meaning it must implement the Attack() method and inherits properties like "Name", "Health", and "IsAlive".
|
|
||
| public Monster(string name, int health, int damage) | ||
| { | ||
| Name = name; |
There was a problem hiding this comment.
this is the constructor, used when creating a new monster. It sets the monster's name, starting health, and how much damage it deals.
| // Potion class inherits from Item and represents healing items | ||
| public class Potion : Item | ||
| { | ||
| public int HealAmount { get; set; } |
There was a problem hiding this comment.
stores how much health this potion will restore when used. This can be customised per potion for example a “Small Potion” might heal 10, while a “Greater Potion” heals 50.
| public class Room | ||
| { | ||
| public string Description { get; set; } | ||
| public List<Item> Items { get; set; } = new List<Item>(); |
There was a problem hiding this comment.
a list to store items that the player can collect within this room. This could include weapons, potions, or other collectibles within said room.
| @@ -0,0 +1,16 @@ | |||
| // Weapon class inherits from Item and represents damage-dealing items | |||
| public class Weapon : Item | |||
There was a problem hiding this comment.
the Weapon class inherits from the abstract Item class, meaning it shares properties like Name and must implement the Use method. this follows object-oriented principles such as inheritance and abstraction.
No description provided.