Skip to content

assignment 2 commits #136

Open
ameliabond6 wants to merge 3 commits intocfrantzidis:masterfrom
ameliabond6:master
Open

assignment 2 commits #136
ameliabond6 wants to merge 3 commits intocfrantzidis:masterfrom
ameliabond6:master

Conversation

@ameliabond6
Copy link
Copy Markdown

No description provided.

Comment thread gamemap.cs
public Room CurrentRoom { get; private set; }

// the game map with connected rooms and contents
public void Initialize()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this method sets up the initial game environment
room creation
room connections (neighbors)
placing items and monsters
starting point

Comment thread gamemap.cs
}

// Move to the neighboring room based on direction
public void Move(string direction)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Comment thread interface.cs
@@ -0,0 +1,31 @@
// Interface for anything that can take damage
public interface IDamageable
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this interface is used for any object that can take damage - players and monsters

Comment thread interface.cs
}

// Interface for items that can be collected and used by the player
public interface ICollectible
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this interface is for items that can be collected as well as used by the player - such as weapons and potions

Comment thread interface.cs
// File: Creature.cs

// Abstract base class for all creatures in the game
public abstract class Creature : IDamageable
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Comment thread monster.cs
using System;

// Monster class inherits from Creature and represents enemies
public class Monster : Creature
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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".

Comment thread monster.cs

public Monster(string name, int health, int damage)
{
Name = name;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this is the constructor, used when creating a new monster. It sets the monster's name, starting health, and how much damage it deals.

Comment thread potion.cs
// Potion class inherits from Item and represents healing items
public class Potion : Item
{
public int HealAmount { get; set; }
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Comment thread room.cs
public class Room
{
public string Description { get; set; }
public List<Item> Items { get; set; } = new List<Item>();
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

a list to store items that the player can collect within this room. This could include weapons, potions, or other collectibles within said room.

Comment thread weapon.cs
@@ -0,0 +1,16 @@
// Weapon class inherits from Item and represents damage-dealing items
public class Weapon : Item
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

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.

1 participant