diff --git a/Creatures.cs b/Creatures.cs
new file mode 100644
index 00000000..84d21ff2
--- /dev/null
+++ b/Creatures.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ public abstract class Creatures
+ {
+ public string Name { get; private set; }
+ public int Health { get; set; }
+ public int NumberOfCoins { get; set; }
+
+ public Creatures(string name, int health, int numberOfCoins)
+ {
+ Name = name;
+ Health = health;
+ NumberOfCoins = numberOfCoins;
+ }
+
+ public abstract void PickUpCoins(bool pickingUpCoins, int coins);
+ public abstract void Attack(IDamagable attacked, int damageTaken);
+ public abstract void Defense(bool defended, int damage, int damageReduction, int damageTaken);
+ }
+}
diff --git a/DungeonExplorer.csproj b/DungeonExplorer.csproj
index 32ff6101..90bda67e 100644
--- a/DungeonExplorer.csproj
+++ b/DungeonExplorer.csproj
@@ -43,11 +43,22 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Game.cs b/Game.cs
index dacdc422..c8a8d1db 100644
--- a/Game.cs
+++ b/Game.cs
@@ -1,26 +1,407 @@
using System;
+using System.Diagnostics;
+using System.Diagnostics.Eventing.Reader;
+using System.Globalization;
using System.Media;
+using System.Runtime.CompilerServices;
+using System.Xml.Linq;
namespace DungeonExplorer
{
internal class Game
{
private Player player;
- private Room currentRoom;
+ private Monster goblin;
+ private Monster skeleton;
+ private Monster ogre;
+ private Monster dragon;
+ private Room startingRoom;
+ private Room roomA;
+ private Room roomB;
+ private Room roomC;
+ private Room roomD;
+ private Room roomE;
+ private Room finalRoom;
+ private Inventory playerInventory;
+ private Inventory monsterInventory;
+ private Heals healthPotion;
+ private Melee sword;
+ private Melee axe;
+ private LongRange fireBall;
+ private LongRange bowAndArrow;
+ private Test test;
+ private Statistics statistics;
+ bool skeletonDead = false;
+ bool goblinDead = false;
+ bool ogreDead = false;
+ bool dragonDead = false;
public Game()
{
- // Initialize the game with one room and one player
+ test = new Test();
+ bool inOptions = true;
+
+ while (inOptions = true)
+ {
+ try
+ {
+ Console.WriteLine("Please enter a username: ");
+ string playerUsername = Console.ReadLine();
+ player = new Player(playerUsername, 100, 0, 0, 0, 0);
+
+ if (playerUsername.Length == 0)
+ {
+ Debug.Assert(playerUsername.Length != 0, test.TestMethod());
+ throw new ArgumentNullException("No name entered, please try again");
+ }
+
+ if (playerUsername.Length > 0)
+ {
+ break;
+ }
+ }
+
+ catch (ArgumentNullException ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
+ }
+ Console.WriteLine($"Welcome {player.Name}");
+ startingRoom = new Room("Starting Room", false, false, "starting room", "A cold and dark empty room",
+ "There are no enemies in this room");
+ roomA = new Room("Room A", false, false, "combat room", "A room covered in bones and skulls",
+ "There is 1 skeleton in the room");
+ roomB = new Room("Room B", false, false, "combat room", "A room with loud laughing and growling sounds",
+ "There is 1 goblin in the room");
+ roomC = new Room("Room C", false, true, "mini boss room", "A room made of cobblestone with a huge door",
+ "There is a mini boss in the room");
+ finalRoom = new Room("Final Room", false, true, "boss room", "A room surrounded by a pool of lava",
+ "There is 1 dragon boss in the room");
+ goblin = new Monster("Goblin", 50, 10, "Regular", "Sword Attack", 20);
+ skeleton = new Monster("Skeleton", 60, 20, "Regular", "Bow and Arrow Attack", 30);
+ ogre = new Monster("Ogre", 80, 50, "Mini Boss", "Punch Attack", 40);
+ dragon = new Monster("Dragon", 95, 75, "Boss", "Fire Breath Attack", 60);
+ healthPotion = new Heals("Health Potion", "This item increases health points", 1, "Heal item", 80);
+ sword = new Melee("Sword", "This is a melee item", 10, "Melee item", "Fire effect", 20);
+ axe = new Melee("Axe", "This is a melee item", 15, "Melee item", "No effect", 30);
+ fireBall = new LongRange("Fire Ball", "This is a long range item", 3, "Long Range item",
+ 10, 3);
+ bowAndArrow = new LongRange("Bow And Arrow", "This is a long range item", 10, "Long Range item",
+ 5, 5);
+ playerInventory = new Inventory();
+ monsterInventory = new Inventory();
+ statistics = new Statistics(player.NumberOfCoins);
}
+
public void Start()
{
- // Change the playing logic into true and populate the while loop
bool playing = false;
- while (playing)
+
+ playing = true;
+ while (playing == true)
{
- // Code your playing logic here
+ startingRoom.EnterRoom();
+ sword.Collected();
+ playerInventory.AddItem($"{sword.ItemName}", $"{sword.ItemType}");
+ playerInventory.AddItem($"{healthPotion.ItemName}", $"{healthPotion.ItemType}");
+
+ Console.WriteLine($"There are 3 doors in front of you, enter one of the following keys \n" +
+ $"Room A: A\n" +
+ $"Room B: B\n" +
+ $"Room C: C\n");
+
+ bool choosingRoom = true;
+ while (choosingRoom == true)
+ {
+ string userInput = Console.ReadLine();
+ if (userInput == "A")
+ {
+ roomA.EnterRoom();
+
+
+ if (skeletonDead == true)
+ {
+ Console.WriteLine("Please choose room B or C");
+ continue;
+ }
+
+ bool battle = true;
+ while (battle == true)
+ {
+ string userInput2 = Console.ReadLine();
+ if (userInput2 == "X" || userInput2 == "x")
+ {
+ player.Attack(skeleton, sword.ItemDamage);
+ if (skeleton.Health <= 0)
+ {
+ player.GainXP(50);
+ player.PickUpCoins(true, skeleton.NumberOfCoins);
+ Console.WriteLine($"There is a {fireBall.ItemName} on the ground");
+ playerInventory.AddItem(fireBall.ItemName, fireBall.ItemType);
+ Console.WriteLine($"Would you like to use {healthPotion.ItemName}\n" +
+ $"press H to use {healthPotion.ItemName}");
+ string userInput3 = Console.ReadLine();
+ if (userInput3 == "h" || userInput3 == "H")
+ {
+ playerInventory.GetItemType(healthPotion.ItemType);
+ Console.WriteLine($"Healing by {healthPotion.HealthIncrease}...");
+ player.Health += healthPotion.HealthIncrease;
+ if (player.Health > 100)
+ {
+ player.Health = 100;
+ }
+ Console.WriteLine($"{player.Name} current health is {player.Health}");
+ }
+
+ else
+ {
+ Console.WriteLine("You did not heal");
+ }
+
+ Console.WriteLine($"Please choose the next room to enter \n" +
+ $"Room B: B\n" +
+ $"Room C: C");
+ skeletonDead = true;
+ battle = false;
+ break;
+ }
+ else
+ {
+ skeleton.Attack(player, skeleton.MonsterStrength);
+ }
+ }
+
+ else
+ {
+ Console.WriteLine($"{player.Name} did not attack");
+ skeleton.Attack(player, skeleton.MonsterStrength);
+ if (player.Health <= 0)
+ {
+ choosingRoom = false;
+ playing = false;
+ break;
+ }
+ }
+
+ }
+
+
+
+ }
+ else if (userInput == "B")
+ {
+ roomB.EnterRoom();
+ if (goblinDead == true)
+ {
+ Console.WriteLine("Please choose room A or C");
+ continue;
+ }
+
+ bool battle = true;
+ while (battle == true)
+ {
+ string userInput2 = Console.ReadLine();
+ if (userInput2 == "X" || userInput2 == "x")
+ {
+ player.Attack(goblin, fireBall.ItemDamage);
+ if (goblin.Health <= 0)
+ {
+ roomC.UnlockRoom();
+ player.GainXP(50);
+ player.PickUpCoins(true, goblin.NumberOfCoins);
+ Console.WriteLine($"There is a {bowAndArrow.ItemName} on the ground");
+ playerInventory.AddItem(bowAndArrow.ItemName, bowAndArrow.ItemType);
+ Console.WriteLine($"Would you like to use {healthPotion.ItemName}\n" +
+ $"press H to use {healthPotion.ItemName}");
+ string userInput3 = Console.ReadLine();
+ if (userInput3 == "h" || userInput3 == "H")
+ {
+ playerInventory.GetItemType(healthPotion.ItemType);
+ playerInventory.GetItemType(healthPotion.ItemType);
+ Console.WriteLine($"Healing by {healthPotion.HealthIncrease}...");
+ player.Health += healthPotion.HealthIncrease;
+ if (player.Health > 100)
+ {
+ player.Health = 100;
+ }
+ Console.WriteLine($"{player.Name} current health is {player.Health}");
+ }
+
+ else
+ {
+ Console.WriteLine("You did not heal");
+ }
+ Console.WriteLine($"{roomC} has unlocked");
+ Console.WriteLine($"Please choose the next room to enter \n" +
+ $"Room A: A\n" +
+ $"Room C: C");
+ goblinDead = true;
+ battle = false;
+
+ break;
+ }
+ else
+ {
+ goblin.Attack(player, goblin.MonsterStrength);
+ }
+ }
+
+ else
+ {
+ Console.WriteLine($"{player.Name} did not attack");
+ goblin.Attack(player, goblin.MonsterStrength);
+ if (player.Health <= 0)
+ {
+ choosingRoom = false;
+ playing = false;
+ break;
+ }
+ }
+
+ }
+ }
+ else if (userInput == "C")
+ {
+ roomC.EnterRoom();
+
+ if (ogreDead == true)
+ {
+ Console.WriteLine("Please choose room A or C");
+ continue;
+ }
+
+ bool battle = true;
+ while (battle == true)
+ {
+ string userInput2 = Console.ReadLine();
+ if (userInput2 == "X" || userInput2 == "x")
+ {
+ player.Attack(ogre, bowAndArrow.ItemDamage);
+ if (ogre.Health <= 0)
+ {
+ player.GainXP(50);
+ player.PickUpCoins(true, ogre.NumberOfCoins);
+ Console.WriteLine($"Would you like to use {healthPotion.ItemName}\n" +
+ $"press H to use {healthPotion.ItemName}");
+ string userInput3 = Console.ReadLine();
+ if (userInput3 == "h" || userInput3 == "H")
+ {
+ playerInventory.GetItemType(healthPotion.ItemType);
+ Console.WriteLine($"Healing by {healthPotion.HealthIncrease}...");
+ player.Health += healthPotion.HealthIncrease;
+ if (player.Health > 100)
+ {
+ player.Health = 100;
+ }
+ Console.WriteLine($"{player.Name} current health is {player.Health}");
+ }
+
+ else
+ {
+ Console.WriteLine("You did not heal");
+ }
+ finalRoom.UnlockRoom();
+ Console.WriteLine($"You can now enter the final room, press E to enter");
+ ogreDead = true;
+ battle = false;
+
+ break;
+ }
+ else
+ {
+ ogre.Attack(player, ogre.MonsterStrength);
+ }
+ }
+
+ else
+ {
+ Console.WriteLine($"{player.Name} did not attack");
+ ogre.Attack(player, ogre.MonsterStrength);
+ if (player.Health <= 0)
+ {
+ choosingRoom = false;
+ playing = false;
+ break;
+ }
+ }
+
+ }
+ }
+
+
+ else if (userInput == "E")
+ {
+ finalRoom.EnterRoom();
+ if (dragonDead == true)
+ {
+ Console.WriteLine("Gaame over");
+ }
+
+ bool battle = true;
+ while (battle == true)
+ {
+ string userInput2 = Console.ReadLine();
+ if (userInput2 == "X" || userInput2 == "x")
+ {
+
+
+
+ player.Attack(dragon, axe.ItemDamage);
+ if (dragon.Health <= 0)
+ {
+ player.GainXP(50);
+ player.PickUpCoins(true, dragon.NumberOfCoins);
+ dragonDead = true;
+ statistics.CalculateAverageCoins(goblin.NumberOfCoins, skeleton.NumberOfCoins,
+ ogre.NumberOfCoins, dragon.NumberOfCoins, player.NumberOfCoins);
+
+ choosingRoom = false;
+ playing = false;
+ break;
+ }
+ else
+ {
+ dragon.Attack(player, dragon.MonsterStrength);
+ }
+ }
+
+ else
+ {
+ Console.WriteLine($"{player.Name} did not attack");
+ dragon.Attack(player, dragon.MonsterStrength);
+ if (player.Health <= 0)
+ {
+ choosingRoom = false;
+ playing = false;
+ break;
+ }
+ }
+ }
+ }
+
+
+ else
+ {
+ Console.WriteLine("Please choose an appropriate room");
+ }
+
+ if (player.Health <= 0)
+ {
+ statistics.CalculateAverageCoins(goblin.NumberOfCoins, skeleton.NumberOfCoins,
+ ogre.NumberOfCoins, dragon.NumberOfCoins, player.NumberOfCoins);
+ playing = false;
+ }
+
+
+ }
+
+
+
+ break;
}
}
}
+
+
}
\ No newline at end of file
diff --git a/GameMap.cs b/GameMap.cs
new file mode 100644
index 00000000..83adb515
--- /dev/null
+++ b/GameMap.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ abstract class GameMap
+ {
+ public string RoomName { get; private set; }
+ public bool RoomEntered { get; set; }
+ public bool RoomLocked { get; set; }
+ public string RoomType { get; private set; }
+ public string RoomDescription { get; private set; }
+
+ public GameMap(string roomName, bool roomEntered, bool roomLocked, string roomType, string roomDescription)
+ {
+ RoomName = roomName;
+ RoomEntered = roomEntered;
+ RoomLocked = roomLocked;
+ RoomType = roomType;
+ RoomDescription = roomDescription;
+ }
+
+ abstract public void EnterRoom();
+
+ abstract public void UnlockRoom();
+
+ abstract public string GetDescription();
+ }
+}
diff --git a/Heals.cs b/Heals.cs
new file mode 100644
index 00000000..773e22e0
--- /dev/null
+++ b/Heals.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ class Heals : Item, ICollectible
+ {
+ public int HealthIncrease { get; set; }
+
+ public Heals(string itemName, string itemDescription,
+ int itemDurability, string itemType, int healthIncrease) :
+ base(itemName, itemDescription, itemDurability, itemType)
+ {
+ HealthIncrease = healthIncrease;
+ }
+
+ public void Collected()
+ {
+ Console.WriteLine($"{ItemName}s can heal by {HealthIncrease}");
+ Console.WriteLine($"There is a {ItemName} on the ground, press X to pick it up");
+ }
+
+ }
+}
diff --git a/Interfaces.cs b/Interfaces.cs
new file mode 100644
index 00000000..819b07f9
--- /dev/null
+++ b/Interfaces.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ public interface IDamagable
+ {
+ void Damaged(int damageTaken);
+ }
+
+ public interface ICollectible
+ {
+ void Collected();
+ }
+
+}
diff --git a/Inventory.cs b/Inventory.cs
new file mode 100644
index 00000000..98d43e00
--- /dev/null
+++ b/Inventory.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Eventing.Reader;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ class Inventory
+ {
+ private Dictionary inventoryItems;
+
+ public Inventory()
+ {
+ inventoryItems = new Dictionary();
+ }
+
+ public Dictionary GetItemType(string itemType)
+ {
+ Dictionary ItemsToReturn = new Dictionary();
+ foreach (var item in inventoryItems)
+ {
+ if (item.Value == itemType)
+ {
+ ItemsToReturn.Add(item.Key, item.Value);
+ }
+ }
+ return ItemsToReturn;
+
+ }
+
+
+ public void AddItem(string itemName, string itemType)
+ {
+ Console.ReadKey();
+ inventoryItems.Add(itemName, itemType);
+ Console.WriteLine($"{itemName} has been added to inventory");
+ }
+
+ public void RemoveItem(string itemName)
+ {
+ inventoryItems.Remove(itemName);
+ Console.WriteLine($"{itemName} has been removed from inventory");
+ }
+
+ public string InventoryContents()
+ {
+ return string.Join(", ", inventoryItems);
+ }
+ }
+}
diff --git a/Item.cs b/Item.cs
new file mode 100644
index 00000000..e5812be7
--- /dev/null
+++ b/Item.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ abstract class Item
+ {
+ public string ItemName { get; private set; }
+ public string ItemDescription { get; private set; }
+ public int ItemDurability { get; set; }
+ public string ItemType { get; private set; }
+ public int ItemSpace { get; private set; }
+
+ public Item(string itemName, string itemDescription, int itemDurability, string itemType)
+ {
+ ItemName = itemName;
+ ItemDescription = itemDescription;
+ ItemDurability = itemDurability;
+ ItemType = itemType;
+ }
+
+
+ }
+}
diff --git a/LongRange.cs b/LongRange.cs
new file mode 100644
index 00000000..897c4b17
--- /dev/null
+++ b/LongRange.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ class LongRange : Item, ICollectible
+ {
+ public int ItemDamage { get; set; }
+ public int AmmoNumber { get; set; }
+
+ public LongRange(string itemName, string itemDescriptiom,
+ int itemDurability, string itemType,int itemDamage, int ammoNumber) :
+ base(itemName, itemDescriptiom, itemDurability, itemType)
+ {
+ ItemDamage = itemDamage;
+ AmmoNumber = ammoNumber;
+
+ }
+
+ public void Collected()
+ {
+ Console.WriteLine($"{ItemName}s can do {ItemDamage}");
+ Console.WriteLine($"There is a {ItemName} on the ground, press X to pick it up");
+ }
+
+
+ }
+}
diff --git a/Melee.cs b/Melee.cs
new file mode 100644
index 00000000..24c299de
--- /dev/null
+++ b/Melee.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ class Melee : Item, ICollectible
+ {
+
+ public string ItemEffect { get; set; }
+ public int ItemDamage { get; set; }
+ public Melee(string itemName, string itemDescription,
+ int itemDurability, string itemType, string itemEffect, int itemDamage) :
+ base(itemName, itemDescription, itemDurability, itemType)
+ {
+ ItemEffect = itemEffect;
+ ItemDamage = itemDamage;
+ }
+
+ public void Collected()
+ {
+ Console.WriteLine($"{ItemName} can do {ItemDamage} damage");
+ Console.WriteLine($"There is a {ItemName} on the ground, press any key to pick it up");
+ }
+ }
+}
diff --git a/Monster.cs b/Monster.cs
new file mode 100644
index 00000000..ceaa4a38
--- /dev/null
+++ b/Monster.cs
@@ -0,0 +1,132 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ class Monster : Creatures, IDamagable
+ {
+ public string MonsterType { get; private set; }
+ public string MonsterAttackType { get; private set; }
+ public int MonsterStrength { get; set; }
+
+ public Monster(string name, int health, int numberOfCoins, string monsterType, string monsterAttackType,
+ int monsterStrength) : base(name, health, numberOfCoins)
+ {
+ MonsterType = monsterType;
+ MonsterAttackType = monsterAttackType;
+ MonsterStrength = monsterStrength;
+ }
+
+ public void Damaged(int damageTaken)
+ {
+ if (MonsterType == "Regular" && Name == "Skeleton")
+ {
+ damageTaken = 30;
+ }
+
+ else if (MonsterType == "Regular" && Name == "Goblin")
+ {
+ damageTaken = 20;
+ }
+
+ else if (MonsterType == "Mini Boss")
+ {
+ damageTaken = 40;
+ }
+
+ else if (MonsterType == "Boss")
+ {
+ damageTaken = 60;
+ }
+ Health -= damageTaken;
+
+
+ bool playerDead = false;
+
+ Console.WriteLine($"{Name} has taken {damageTaken} damage \n" +
+ $"{Name}'s current health is: {Health}");
+
+ if (Health <= 0)
+ {
+ Health = 0;
+ Console.WriteLine($"{Name} has reached {Health} health");
+ Console.WriteLine($"{Name} has dropped {NumberOfCoins} coins");
+ }
+ }
+
+ public override void Attack(IDamagable attacked, int damageTaken)
+ {
+ Console.WriteLine($"{Name} has used {MonsterAttackType} attack");
+ attacked.Damaged(damageTaken);
+ }
+
+ public override void Defense(bool defended, int damage, int damageReduction, int damageTaken)
+ {
+ if (MonsterType == "Regular")
+ {
+ Random regularRandom = new Random();
+ int randomNum = regularRandom.Next(1, 10);
+ if (randomNum == 1)
+ {
+ defended = true;
+ }
+ else
+ {
+ defended = false;
+ }
+ }
+
+ else if (MonsterType == "Mini Boss")
+ {
+ Random regularRandom = new Random();
+ int randomNum = regularRandom.Next(1, 4);
+ if (randomNum == 1)
+ {
+ defended = true;
+ }
+ else
+ {
+ defended = false;
+ }
+ }
+
+ else if (MonsterType == "Boss")
+ {
+ Random regularRandom = new Random();
+ int randomNum = regularRandom.Next(1, 2);
+ if (randomNum == 1)
+ {
+ defended = true;
+ }
+ else
+ {
+ defended = false;
+ }
+ }
+
+ if (defended == true)
+ {
+ Console.WriteLine($"{Name} has defended \n" +
+ $"{damage} reduced by {damageReduction}");
+ damageTaken = damage - damageReduction;
+ }
+
+ else
+ {
+ Console.WriteLine($"{Name} has not defended");
+ }
+ }
+
+ public override void PickUpCoins(bool pickingUpCoins, int coins)
+ {
+ if (pickingUpCoins = true)
+ {
+ NumberOfCoins += coins;
+ Console.WriteLine($"{Name} now has {coins} coins");
+ }
+ }
+ }
+}
diff --git a/Player.cs b/Player.cs
index 21cc773f..53306e75 100644
--- a/Player.cs
+++ b/Player.cs
@@ -1,25 +1,76 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
namespace DungeonExplorer
{
- public class Player
+ public class Player : Creatures, IDamagable
{
- public string Name { get; private set; }
- public int Health { get; private set; }
- private List inventory = new List();
+ public int NumberOfRoomsEntered { get; set; }
+ public int PlayerXp { get; set; }
+ public int PlayerLevel { get; set; }
- public Player(string name, int health)
+
+ public Player(string name, int health, int numberOfCoins, int numberOfRoomsEntered, int playerXp, int playerLevel)
+ : base(name, health, numberOfCoins)
+ {
+ NumberOfRoomsEntered = numberOfRoomsEntered;
+ PlayerXp = playerXp;
+ PlayerLevel = playerLevel;
+ }
+
+ public void Damaged(int damageTaken)
+ {
+ Health -= damageTaken;
+ Console.WriteLine($"{Name} has taken {damageTaken} damage");
+ if (Health <= 0)
+ {
+ Health = 0;
+ Console.WriteLine($"{Name} has reached {Health} health. You have died");
+ Console.WriteLine($"You had {NumberOfCoins} coins");
+ Console.WriteLine($"You had {PlayerXp} XP");
+ }
+ Console.WriteLine($"{Name} current health is {Health}");
+ }
+
+ public override void Attack(IDamagable attacked, int damageTaken)
{
- Name = name;
- Health = health;
+ if (attacked is Creatures target)
+ {
+ Console.WriteLine($"{Name} has attacked {target.Name}");
+ }
+
+ attacked.Damaged(damageTaken);
}
- public void PickUpItem(string item)
+
+ public override void Defense(bool defended, int damage, int damageReduction, int damageTaken)
{
+ if (defended == true)
+ {
+ Console.WriteLine($"{Name} has defended \n" +
+ $"{damage} reduced by {damageReduction}");
+ damageTaken = damage - damageReduction;
+ }
+
+ else
+ {
+ Console.WriteLine($"{Name} has not defended");
+ }
+ }
+ public override void PickUpCoins(bool pickingUpCoins, int coins)
+ {
+ if (pickingUpCoins = true)
+ {
+ NumberOfCoins += coins;
+ Console.WriteLine($"{Name} now has {coins} coins");
+ }
}
- public string InventoryContents()
+
+ public void GainXP(int XP)
{
- return string.Join(", ", inventory);
+ PlayerXp += XP;
+ Console.WriteLine($"{Name} now has {XP} XP");
}
}
}
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
index 452cda8c..9d363e8d 100644
--- a/Program.cs
+++ b/Program.cs
@@ -6,15 +6,45 @@
namespace DungeonExplorer
{
+ ///
+ /// main code logic for running of the program
+ ///
internal class Program
{
+ ///
+ /// the main function is the code which will run, causing the program to run
+ ///
static void Main(string[] args)
{
- Game game = new Game();
- game.Start();
- Console.WriteLine("Waiting for your Implementation");
- Console.WriteLine("Press any key to exit...");
- Console.ReadKey();
+ try
+ {
+ Console.WriteLine("Welcome to dungeon explorer");
+ ///
+ ///a new instance of the game class is initialized
+ ///causing the code in the class to run, the start method in the game class
+ ///is called so that the code in the start method runs
+ ///
+ Game game = new Game();
+ game.Start();
+ }
+
+ catch (Exception)
+ {
+ ///
+ ///if there is an error in the try, this message will be displayed
+ ///
+ Console.WriteLine("Error has Occured");
+ }
+
+ finally
+ {
+ ///
+ ///this code will run regardless of whether there is an exception or not
+ ///
+ Console.WriteLine("Waiting for your Implementation");
+ Console.WriteLine("Press any key to exit...");
+ Console.ReadKey();
+ }
}
}
}
diff --git a/Room.cs b/Room.cs
index cb092efb..69059829 100644
--- a/Room.cs
+++ b/Room.cs
@@ -1,17 +1,59 @@
-namespace DungeonExplorer
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Globalization;
+using System.Threading;
+
+namespace DungeonExplorer
{
- public class Room
+ class Room : GameMap
{
- private string description;
+ public string MonstersInRoom { get; set; }
+ public Room(string roomName, bool roomEntered, bool roomLocked, string roomType, string roomDescription
+ , string monstersInRoom) :
+ base(roomName, roomEntered, roomLocked, roomType, roomDescription)
+ {
+ MonstersInRoom = monstersInRoom;
+ }
+
+ override public void EnterRoom()
+ {
+ if (RoomEntered == true)
+ {
+ Console.WriteLine("You have already entered this room");
+ }
+
+ else if (RoomEntered == false)
+ {
+ if (RoomLocked == false)
+ {
+ Console.WriteLine($"Entering {RoomName}");
+ if (RoomType == "combat room" || RoomType == "boss room" || RoomType == "mini boss room")
+ {
+ Console.WriteLine($"{MonstersInRoom}");
+ Console.WriteLine("press x to attack");
+ }
+ RoomEntered = true;
+ }
+
+ else if (RoomLocked == true)
+ {
+ Console.WriteLine($"{RoomName} is locked");
+ Console.WriteLine($"Please unlock {RoomName} to enter");
+ Console.WriteLine("Enter another room");
+ }
+ }
+ }
- public Room(string description)
+ override public void UnlockRoom()
{
- this.description = description;
+ Console.WriteLine($"Unlocking {RoomName}");
+ RoomLocked = false;
}
- public string GetDescription()
+ override public string GetDescription()
{
- return description;
+ return RoomDescription;
}
}
}
\ No newline at end of file
diff --git a/Statistics.cs b/Statistics.cs
new file mode 100644
index 00000000..bd15798a
--- /dev/null
+++ b/Statistics.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ class Statistics
+ {
+ public int PlayerCoins { get; set; }
+
+ public Statistics(int playerCoins)
+ {
+ PlayerCoins = playerCoins;
+ }
+
+ public void CalculateAverageCoins(int goblinCoins, int skeletonCoins, int ogreCoins,
+ int dragonCoins, int playerCoins)
+ {
+ int totalCoins = goblinCoins + skeletonCoins + ogreCoins + dragonCoins;
+ int averageCoins = totalCoins / 4;
+ Console.WriteLine($"The average of coins are {averageCoins}");
+ Console.WriteLine($"You had {playerCoins}");
+ }
+ }
+}
diff --git a/Test.cs b/Test.cs
new file mode 100644
index 00000000..95eef173
--- /dev/null
+++ b/Test.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DungeonExplorer
+{
+ class Test
+ {
+ ///
+ /// the main code for the testing of the code for bugs
+ ///
+
+ ///
+ ///the TestMethod method creates a string to be displayed when there is an error
+ ///
+ public string TestMethod()
+ {
+ string errorMessage = "Error found";
+ ///
+ ///the error message is returned when this function is called
+ ///
+ return errorMessage;
+ }
+ }
+}