diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..013007bb
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "dotnet.preferCSharpExtension": true
+}
\ No newline at end of file
diff --git a/Battle.cs b/Battle.cs
new file mode 100644
index 00000000..5a0f2d4a
--- /dev/null
+++ b/Battle.cs
@@ -0,0 +1,87 @@
+using System;
+
+namespace DungeonExplorer
+{
+ public static class Battle // When enounter is called he battle is initiated
+ {
+ private static Random rng = new Random();
+
+ public static void Start(Player player, Orc orc)
+ {
+ Console.WriteLine($"\nA wild {orc.Name} appears! Prepare for battle!\n");
+
+ while (player.Health > 0 && orc.Health > 0)
+ {
+ Console.WriteLine("Your Turn:");
+ Console.WriteLine("1. Attack");
+ Console.WriteLine("2. Block");
+ Console.Write("Choose your action: ");
+ string input = Console.ReadLine();
+ int playerDamage = player.GetAttackDamage();
+
+ bool playerBlocked = false;
+
+ switch (input)
+ {
+ case "1":
+ if (rng.NextDouble() < 0.1) // Creates a potential for YOU to miss an attack
+ {
+ Console.WriteLine("You missed your attack!");
+ }
+ else
+ {
+ if (rng.NextDouble() < 0.2) // Creates a potential that the orc blocks your attack
+ {
+ Console.WriteLine($"{orc.Name} blocked your attack!");
+ }
+ else
+ {
+ orc.Health -= playerDamage; // Player Deals Damage to Orc
+ Console.WriteLine($"You hit the {orc.Name} for {playerDamage} damage.\n");
+ }
+ }
+ break;
+ case "2":
+ playerBlocked = true;
+ Console.WriteLine("You brace yourself and prepare to block the next attack.\n");
+ break;
+ default:
+ Console.WriteLine("Invalid input. You lost your turn.");
+ break;
+ }
+
+ if (orc.Health <= 0) break;
+
+ Console.WriteLine("Enemy Turn:");
+ if (rng.NextDouble() < 0.1) // Creates A Potential For The Orc To Miss An Attack
+ {
+ Console.WriteLine($"{orc.Name} missed their attack!\n");
+ }
+ else
+ {
+ int damage = orc.Damage;
+ if (playerBlocked)
+ {
+ damage /= 2;
+ Console.WriteLine($"You partially blocked the attack! You receive {damage} damage.");
+ }
+ else
+ {
+ Console.WriteLine($"{orc.Name} hits you for {damage} damage.");
+ }
+ player.Health -= damage;
+ }
+
+ Console.WriteLine($"\nPlayer Health: {player.Health}");
+ Console.WriteLine($"{orc.Name} Health: {orc.Health}\n");
+ }
+
+ if (player.Health > 0)
+ Console.WriteLine($"You defeated the {orc.Name}!");
+ else
+ Console.WriteLine("You were defeated. Game Over.");
+
+ Console.WriteLine();
+ }
+ }
+}
diff --git a/CMP1903M_2425_A01_Report (1).docx b/CMP1903M_2425_A01_Report (1).docx
new file mode 100644
index 00000000..ea422be4
Binary files /dev/null and b/CMP1903M_2425_A01_Report (1).docx differ
diff --git a/DungeonExplorer.csproj b/DungeonExplorer.csproj
index 32ff6101..6bb27bb6 100644
--- a/DungeonExplorer.csproj
+++ b/DungeonExplorer.csproj
@@ -43,11 +43,19 @@
+
+
-
+
+
+
+
+
+
+
diff --git a/Game.cs b/Game.cs
index dacdc422..4d5981d0 100644
--- a/Game.cs
+++ b/Game.cs
@@ -1,25 +1,86 @@
using System;
-using System.Media;
+using System.Runtime.InteropServices;
namespace DungeonExplorer
{
- internal class Game
+ public class Game
{
private Player player;
- private Room currentRoom;
+ private RoomOne roomOne;
+ private RoomTwo roomTwo;
+ private RoomThree roomThree;
+ private RoomFour roomFour;
+ private RoomFive roomFive;
public Game()
{
- // Initialize the game with one room and one player
-
+ Console.Write("Enter your name: ");
+ string playerName = Console.ReadLine();
+ if (string.IsNullOrWhiteSpace(playerName))
+ {
+ Console.WriteLine("Name cannot be empty. Using default name 'Steve'.");
+ playerName = "Steve";
+ }
+ player = new Player(playerName, 100);
+ roomOne = new RoomOne("\n You Slowly Push The Dungeon Doors Open Stumbling Down The Rocky Cavern, The Torch Lit Halls Flicker With Light\n "
+ + " You Reach A Wooden Door Which Swings Open To The Orcs Armoury - Bloodstained Weapons Are Hung on the wall but they still flicker with light \n"
+ + "You peer around the corner two old armour stands are idle in the room the armour looking new and polished untouched by war \n" +
+ "... You delve into the room to see whats around ..."); ;
+ roomTwo = new RoomTwo("\n You Pull Open A Door Handle, Its Rusted Iron Handle Chips In Your Hand It Opens Revealing A Cafeteria With An Orc Finishing Off His Meal \n");
+ roomThree = new RoomThree("\n You Hear Metal Clanging Through The Door You Rush Through Clutching Your Sword To See What Thw Noise Is -"
+ +"\n An Orc Drops His Tools And Grabs The Strong Sword He Has Just Finished Tempering \n");
+ roomFour = new RoomFour("The Blacksmiths Go Silent As The Flames Burn Out, A Chime Comes From A Door With A Cross On\n"+
+ "You Tap The Door With Your New Sword As It Swings Open Revealing the Orcs Church");
+ roomFive = new RoomFive("The Guard Topples Over Making A Horriffic Screach - You Hear A Massive Pound Come From The Double Doors Off to the Side \n"+
+ "You Jam The Key You Found In the Armoury Into The Lock And With A Hard Twist The Doors Swing Open Revealing The King And His Throne");
}
+
public void Start()
{
- // Change the playing logic into true and populate the while loop
- bool playing = false;
- while (playing)
+ Console.WriteLine("\n--- Room One: The Armory ---\n");
+ Console.WriteLine(roomOne.GetDescription() + "\n");
+
+ while (roomOne.HasRemainingItems())
+ {
+ Console.WriteLine("Choose a location to search:");
+ roomOne.ShowLocations();
+ int choice = GetUserChoice(1, roomOne.Locations.Count);
+ var item = roomOne.PickUpItemFromLocation(choice - 1);
+ if (item != null)
+ {
+ player.PickUpItem(item);
+ }
+ Console.WriteLine("\n" + player.GetStatus() + "\n");
+ }
+ Console.WriteLine("You collected all items in Room One.\n");
+
+ Console.WriteLine("\n--- Room Two: Cafeteria ---\n");
+ roomTwo.Enter(player);
+ if (player.Health <= 0) return;
+
+ Console.WriteLine("\n--- Room Three: Blacksmith's Forge ---\n");
+ roomThree.Enter(player);
+ if (player.Health <= 0) return;
+
+ Console.WriteLine("\n--- Room Four: The Church ---\n");
+ roomFour.Enter(player);
+ if (player.Health <= 0) return;
+
+ Console.WriteLine("\n--- Room Five: Throne Room ---\n");
+ roomFive.Enter(player);
+ }
+
+ private int GetUserChoice(int min, int max)
+ {
+ while (true)
{
- // Code your playing logic here
+ Console.Write("Option: ");
+ string input = Console.ReadLine();
+ if (int.TryParse(input, out int opt) && opt >= min && opt <= max)
+ {
+ return opt;
+ }
+ Console.WriteLine($"Please enter a number between {min} and {max}.");
}
}
}
diff --git a/Location.cs b/Location.cs
new file mode 100644
index 00000000..065e3de6
--- /dev/null
+++ b/Location.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace DungeonExplorer
+{
+ 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) //Class For Creating POIs in Rooms
+ {
+ Name = name;
+ Description = description;
+ Item = item;
+ }
+
+ public string PickUpItem() // Allows the player to pick up items
+ {
+ string foundItem = Item;
+ Item = null;
+ return foundItem;
+ }
+ }
+}
+
diff --git a/Orcs.cs b/Orcs.cs
new file mode 100644
index 00000000..d8a9702b
--- /dev/null
+++ b/Orcs.cs
@@ -0,0 +1,43 @@
+using System;
+using DungeonExplorer;
+
+namespace DungeonExplorer
+{
+ public class Orc // Enemy Class
+ {
+ public string Name { get; private set; }
+ public int Health { get; set; }
+ public int Damage { get; private set; }
+
+ public Orc(string name, int health, int damage)
+ {
+ Name = name;
+ Health = health;
+ Damage = damage;
+ }
+
+
+
+ // Specifying Which Orcs Can Spawn In
+ public class OrcGrunt : Orc
+ {
+ public OrcGrunt() : base("Orc Grunt", 20, 5) { }
+ }
+
+ public class OrcSoldier : Orc
+ {
+ public OrcSoldier() : base("Orc Soldier", 70, 15) { }
+ }
+
+ public class OrcWarlord : Orc
+ {
+ public OrcWarlord() : base("Orc Warlord", 100, 20) { }
+ }
+
+ public class OrcKing : Orc
+ {
+ public OrcKing() : base("Orc King", 150, 25) { }
+ }
+ }
+}
+
diff --git a/Player.cs b/Player.cs
index 21cc773f..64112f14 100644
--- a/Player.cs
+++ b/Player.cs
@@ -1,25 +1,67 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
namespace DungeonExplorer
{
public class Player
{
- public string Name { get; private set; }
- public int Health { get; private set; }
- private List inventory = new List();
+ private string name;
+ private int health;
+ private List inventory;
- public Player(string name, int health)
+ public Player(string name, int health)
{
- Name = name;
- Health = health;
+ this.name = name;
+ this.Health = health;
+ inventory = new List();
}
+
+ public string Name { get { return name; } }
+
+ public int Health
+ {
+ get { return health; }
+ set { health = value < 0 ? 0 : value; }
+ }
+
public void PickUpItem(string item)
{
+ inventory.Add(item);
+ Console.WriteLine($"{name} picked up {item}.");
+
+ // Picking up armour increases health
+ if (item == "Helmet")
+ {
+ Health += 25;
+ Console.WriteLine("The Orc's Helmet Fits Your Head Perfectly - Your Health Increased by 25!");
+ }
+ if (item == "Chestplate")
+ {
+ Health += 50;
+ Console.WriteLine("Its A Squeeze To Get Into However ... It fits - Your Health Increased by 50");
+ }
+
+ if (item == "Health Potion")
+ {
+ int healAmount = 75; // Heal amount for health potion
+ Health += healAmount;
+ Console.WriteLine($"You Gulp Down The Healing Potion - It Tastes Horrible But Your Wounds Heal - Your health restored by 75");
+ }
}
- public string InventoryContents()
+
+ public string GetStatus()
+ {
+ string invStatus = (inventory.Count > 0) ? string.Join(", ", inventory) : "No items";
+ return $"Player: {name}\nHealth: {health}\nInventory: {invStatus}";
+ }
+
+ public int GetAttackDamage()
{
- return string.Join(", ", inventory);
+ int damage = 10; // Default damage
+ if (inventory.Contains("Strong Sword"))
+ damage += 15; // Additional damage from Strong Sword
+ return damage;
}
}
-}
\ No newline at end of file
+}
diff --git a/Room.cs b/Room.cs
deleted file mode 100644
index cb092efb..00000000
--- a/Room.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace DungeonExplorer
-{
- public class Room
- {
- private string description;
-
- public Room(string description)
- {
- this.description = description;
- }
-
- public string GetDescription()
- {
- return description;
- }
- }
-}
\ No newline at end of file
diff --git a/RoomBase.cs b/RoomBase.cs
new file mode 100644
index 00000000..f723712a
--- /dev/null
+++ b/RoomBase.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ public abstract class Room // Base Class For Room Makes Rooms Accessible From The Game.cs Script
+ {
+ public string Description { get; protected set; }
+ public List Locations { get; private set; }
+
+ public Room(string description)
+ {
+ Description = description;
+ Locations = new List();
+ }
+
+ public void ShowLocations()
+ {
+ for (int i = 0; i < Locations.Count; i++)
+ {
+ var loc = Locations[i];
+ string status = loc.Item != null ? "Item available" : "Empty";
+ Console.WriteLine($"{i + 1}. {loc.Name} - {loc.Description} ({status})");
+ }
+ }
+
+ public bool HasRemainingItems() => Locations.Exists(loc => loc.Item != null);
+
+ public string PickUpItemFromLocation(int index)
+ {
+ var loc = Locations[index];
+ if (loc.Item != null)
+ {
+ Console.WriteLine($"\nYou search the {loc.Name} and find a {loc.Item}!");
+ return loc.PickUpItem();
+ }
+ Console.WriteLine($"\nYou search the {loc.Name} but find nothing.");
+ return null;
+ }
+ }
+}
diff --git a/RoomFive.cs b/RoomFive.cs
new file mode 100644
index 00000000..62d50026
--- /dev/null
+++ b/RoomFive.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+
+namespace DungeonExplorer
+{
+ public class RoomFive : Room
+ {
+ private string description;
+ public List Locations { get; private set; }
+
+ public RoomFive(string description) : base(description)
+ {
+ this.description = description;
+ Locations = new List
+ {
+ new Location("Throne", "A grand throne, now empty, with the orc king waiting to face you.", null)
+ };
+ }
+
+ public string GetDescription() => description;
+
+ public void ShowLocations()
+ {
+ for (int i = 0; i < Locations.Count; i++)
+ {
+ var loc = Locations[i];
+ string status = loc.Item != null ? "Item available" : "Empty";
+ Console.WriteLine($"{i + 1}. {loc.Name} - {loc.Description} ({status})");
+ }
+ }
+
+ public bool HasRemainingItems() => Locations.Exists(loc => loc.Item != null);
+
+ public string PickUpItemFromLocation(int index)
+ {
+ var loc = Locations[index];
+ if (loc.Item != null)
+ {
+ Console.WriteLine($"\nYou search the {loc.Name} and find a {loc.Item}!");
+ return loc.PickUpItem();
+ }
+ Console.WriteLine($"\nYou search the {loc.Name} but find nothing.");
+ return null;
+ }
+
+ // Encounter with the Orc King
+ public void Encounter(Player player)
+ {
+ Orc orc = new Orc("Orc King", 150, 25);
+ Battle.Start(player, orc);
+
+ if (player.Health > 0)
+ {
+ Console.WriteLine("You have defeated the Orc King and completed your journey!");
+ }
+ }
+
+ public void Enter(Player player)
+ {
+ Console.WriteLine(GetDescription() + "\n");
+
+ Encounter(player);
+ if (player.Health <= 0) return;
+
+ while (HasRemainingItems())
+ {
+ Console.WriteLine("Choose a location to search:");
+ ShowLocations();
+
+ int choice = GetUserChoice(1, Locations.Count);
+ var item = PickUpItemFromLocation(choice - 1);
+ if (item != null)
+ {
+ player.PickUpItem(item);
+ }
+
+ Console.WriteLine("\n" + player.GetStatus() + "\n");
+ }
+
+ Console.WriteLine("You have explored all of Room Five.\n");
+ }
+
+ private int GetUserChoice(int min, int max)
+ {
+ while (true)
+ {
+ Console.Write("Option: ");
+ string input = Console.ReadLine();
+ if (int.TryParse(input, out int opt) && opt >= min && opt <= max)
+ {
+ return opt;
+ }
+ Console.WriteLine($"Please enter a number between {min} and {max}.");
+ }
+ }
+ }
+}
diff --git a/RoomFour.cs b/RoomFour.cs
new file mode 100644
index 00000000..d1b1ac1a
--- /dev/null
+++ b/RoomFour.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+
+namespace DungeonExplorer
+{
+ public class RoomFour : Room
+ {
+ private string description;
+ public List Locations { get; private set; }
+
+ public RoomFour(string description) : base(description)
+ {
+ this.description = description;
+ Locations = new List
+ {
+ new Location("Altar", "A grand altar with inscriptions, dark and foreboding.", "Health Potion"),
+ new Location("Grand Door", "A massive door that leads further into the dungeon, guarded by the orc warlord.", null)
+ };
+ }
+
+ public string GetDescription() => description;
+
+ public void ShowLocations()
+ {
+ for (int i = 0; i < Locations.Count; i++)
+ {
+ var loc = Locations[i];
+ string status = loc.Item != null ? "Item available" : "Empty";
+ Console.WriteLine($"{i + 1}. {loc.Name} - {loc.Description} ({status})");
+ }
+ }
+
+ public bool HasRemainingItems() => Locations.Exists(loc => loc.Item != null);
+
+ public string PickUpItemFromLocation(int index)
+ {
+ var loc = Locations[index];
+ if (loc.Item != null)
+ {
+ Console.WriteLine($"\nYou search the {loc.Name} and find a {loc.Item}!");
+ return loc.PickUpItem();
+ }
+ Console.WriteLine($"\nYou search the {loc.Name} but find nothing.");
+ return null;
+ }
+
+ public void Encounter(Player player)
+ {
+ Orc orc = new Orc("Orc Warlord", 100, 20);
+ Battle.Start(player, orc);
+
+ if (player.Health > 0)
+ {
+ Console.WriteLine("The orc warlord drops a health potion! You can pick it up.");
+ PickUpItemFromLocation(0);
+ }
+ }
+
+ public void Enter(Player player)
+ {
+ Console.WriteLine(GetDescription() + "\n");
+
+ Encounter(player);
+ if (player.Health <= 0) return;
+
+ while (HasRemainingItems())
+ {
+ Console.WriteLine("Choose a location to search:");
+ ShowLocations();
+
+ int choice = GetUserChoice(1, Locations.Count);
+ var item = PickUpItemFromLocation(choice - 1);
+ if (item != null)
+ {
+ player.PickUpItem(item);
+ }
+
+ Console.WriteLine("\n" + player.GetStatus() + "\n");
+ }
+
+ Console.WriteLine("You collected all items in Room Four.\n");
+ }
+
+ private int GetUserChoice(int min, int max)
+ {
+ while (true)
+ {
+ Console.Write("Option: ");
+ string input = Console.ReadLine();
+ if (int.TryParse(input, out int opt) && opt >= min && opt <= max)
+ {
+ return opt;
+ }
+ Console.WriteLine($"Please enter a number between {min} and {max}.");
+ }
+ }
+ }
+}
diff --git a/RoomOne.cs b/RoomOne.cs
new file mode 100644
index 00000000..6274579f
--- /dev/null
+++ b/RoomOne.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+
+namespace DungeonExplorer
+{
+ public class RoomOne : Room
+ {
+ private string description;
+ public List Locations { get; private set; }
+
+ public RoomOne(string description) : base(description)
+ {
+ this.description = description;
+ Locations = new List // Creates The POIs in Room One
+ {
+ new Location("Weapon Rack", "A rack filled with rusted weapons, but something glints among them.", "Old Sword"),
+ new Location("Wooden Crate", "A battered crate with something inside.", "Shield"),
+ new Location("Armor Stand", "A broken suit of armor that might still have useful parts.", "Helmet"),
+ new Location("Wall Hooks", "Hooks that once held weapons. One still hangs there.", "Throne Room Key")
+ };
+ }
+
+ public string GetDescription() => description;
+
+ public void ShowLocations()
+ {
+ for (int i = 0; i < Locations.Count; i++)
+ {
+ var loc = Locations[i];
+ string status = loc.Item != null ? "Item available" : "Empty";
+ Console.WriteLine($"{i + 1}. {loc.Name} - {loc.Description} ({status})");
+ }
+ }
+
+ public bool HasRemainingItems() => Locations.Exists(loc => loc.Item != null);
+
+ public string PickUpItemFromLocation(int index)
+ {
+ var loc = Locations[index];
+ if (loc.Item != null)
+ {
+ Console.WriteLine($"\nYou search the {loc.Name} and find a {loc.Item}!");
+ return loc.PickUpItem();
+ }
+ Console.WriteLine($"\nYou search the {loc.Name} but find nothing.");
+ return null;
+ }
+ }
+}
diff --git a/RoomThree.cs b/RoomThree.cs
new file mode 100644
index 00000000..dc3dbe86
--- /dev/null
+++ b/RoomThree.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+
+namespace DungeonExplorer
+{
+ public class RoomThree : Room
+ {
+ private string description;
+ public List Locations { get; private set; }
+
+ public RoomThree(string description) : base(description)
+ {
+ this.description = description;
+ Locations = new List
+ {
+ new Location("Forge", "A large forge with glowing embers and unfinished weapons.", "Health Potion"),
+ new Location("Work Bench", "A workbench with a sword resting on it, waiting for refinement.", "Strong Sword")
+ };
+ }
+
+ public string GetDescription() => description;
+
+ public void ShowLocations()
+ {
+ for (int i = 0; i < Locations.Count; i++)
+ {
+ var loc = Locations[i];
+ string status = loc.Item != null ? "Item available" : "Empty";
+ Console.WriteLine($"{i + 1}. {loc.Name} - {loc.Description} ({status})");
+ }
+ }
+
+ public bool HasRemainingItems() => Locations.Exists(loc => loc.Item != null);
+
+ public string PickUpItemFromLocation(int index)
+ {
+ var loc = Locations[index];
+ if (loc.Item != null)
+ {
+ Console.WriteLine($"\nYou search the {loc.Name} and find a {loc.Item}!");
+ return loc.PickUpItem();
+ }
+ Console.WriteLine($"\nYou search the {loc.Name} but find nothing.");
+ return null;
+ }
+
+ public void Encounter(Player player)
+ {
+ Orc orc = new Orc("Orc Soldier", 70, 15);
+ Battle.Start(player, orc);
+
+ if (player.Health > 0)
+ {
+ Console.WriteLine("The orc drops a healing potion and a sword! You can pick them up.");
+ PickUpItemFromLocation(0);
+ PickUpItemFromLocation(1);
+ }
+ }
+
+ public void Enter(Player player)
+ {
+ Console.WriteLine(GetDescription() + "\n");
+
+ Encounter(player);
+
+ if (player.Health <= 0) return;
+
+ while (HasRemainingItems())
+ {
+ Console.WriteLine("Choose a location to search:");
+ ShowLocations();
+
+ int choice = GetUserChoice(1, Locations.Count);
+ var item = PickUpItemFromLocation(choice - 1);
+ if (item != null)
+ {
+ player.PickUpItem(item);
+ }
+
+ Console.WriteLine("\n" + player.GetStatus() + "\n");
+ }
+
+ Console.WriteLine("You Push Over The Hot Iron Tools However Cant Find Anything Else Worth Gathering.\n");
+ }
+
+ private int GetUserChoice(int min, int max)
+ {
+ while (true)
+ {
+ Console.Write("Option: ");
+ string input = Console.ReadLine();
+ if (int.TryParse(input, out int opt) && opt >= min && opt <= max)
+ {
+ return opt;
+ }
+ Console.WriteLine($"Please enter a number between {min} and {max}.");
+ }
+ }
+ }
+}
diff --git a/RoomTwo.cs b/RoomTwo.cs
new file mode 100644
index 00000000..30cd9de1
--- /dev/null
+++ b/RoomTwo.cs
@@ -0,0 +1,87 @@
+using System;
+using System.Collections.Generic;
+
+namespace DungeonExplorer
+{
+ public class RoomTwo : Room
+ {
+ private string description;
+ public List Locations { get; private set; }
+
+ public RoomTwo(string description) : base(description)
+ {
+ this.description = description;
+ Locations = new List
+ {
+ new Location("Benches", "A few benches with some broken plates around.", "Health Potion"),
+ new Location("Broken Plates", "Rusty and old plates scattered on the floor.", "Chestplate")
+ };
+ }
+
+ public string GetDescription() => description;
+
+ public void ShowLocations()
+ {
+ for (int i = 0; i < Locations.Count; i++)
+ {
+ var loc = Locations[i];
+ string status = loc.Item != null ? "Item available" : "Empty";
+ Console.WriteLine($"{i + 1}. {loc.Name} - {loc.Description} ({status})");
+ }
+ }
+
+ public bool HasRemainingItems() => Locations.Exists(loc => loc.Item != null);
+
+ public string PickUpItemFromLocation(int index)
+ {
+ var loc = Locations[index];
+ if (loc.Item != null)
+ {
+ Console.WriteLine($"\nYou search the {loc.Name} and find a {loc.Item}!");
+ return loc.PickUpItem();
+ }
+ Console.WriteLine($"\nYou search the {loc.Name} but find nothing.");
+ return null;
+ }
+
+ public void Encounter(Player player) // Creates the battle event
+ {
+ Orc orc = new Orc("Orc Grunt", 20, 5);
+ Battle.Start(player, orc);
+
+ if (player.Health > 0)
+ {
+ Console.WriteLine("The orc drops a health potion! You can pick it up.");
+ PickUpItemFromLocation(0); // Auto-pick health potion from Benches
+ }
+ }
+
+ public void Enter(Player player) // Allows the player to enter the room
+ {
+ Console.WriteLine(GetDescription());
+ Encounter(player);
+ if (player.Health <= 0) return;
+
+ while (HasRemainingItems() && player.Health > 0)
+ {
+ Console.WriteLine("\nChoose a location to search:");
+ ShowLocations();
+ Console.Write("Option: ");
+ if (int.TryParse(Console.ReadLine(), out int choice) && choice >= 1 && choice <= Locations.Count)
+ {
+ var item = PickUpItemFromLocation(choice - 1);
+ if (item != null)
+ {
+ player.PickUpItem(item);
+ }
+ }
+ else
+ {
+ Console.WriteLine("Invalid Input!");
+ }
+ }
+
+ Console.WriteLine("You Rummage Around But Can't Find Anything More Of Value In The Cafeteria");
+ }
+ }
+}