From 9c2a6e9c97d9fdfbdcd4c126c87a04bac9996abf Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:51:09 +0100 Subject: [PATCH] Add simple enemy builder and weapon class --- .../Games/Roguelike/Builders/EnemyBuilder.cs | 34 +++++++++++++++++++ .../Pages/Games/Roguelike/Models/Enemy.cs | 14 ++++++++ .../Pages/Games/Roguelike/Models/Weapon.cs | 15 ++++++++ src/TextLore/Shared/Logic/IBuilder.cs | 6 ++++ .../Shared/Models/Level/IRoomObject.cs | 6 ++++ .../Shared/Models/Player/IInventoryItem.cs | 10 ++++++ 6 files changed, 85 insertions(+) create mode 100644 src/TextLore/Components/Pages/Games/Roguelike/Builders/EnemyBuilder.cs create mode 100644 src/TextLore/Components/Pages/Games/Roguelike/Models/Enemy.cs create mode 100644 src/TextLore/Components/Pages/Games/Roguelike/Models/Weapon.cs create mode 100644 src/TextLore/Shared/Logic/IBuilder.cs create mode 100644 src/TextLore/Shared/Models/Level/IRoomObject.cs create mode 100644 src/TextLore/Shared/Models/Player/IInventoryItem.cs diff --git a/src/TextLore/Components/Pages/Games/Roguelike/Builders/EnemyBuilder.cs b/src/TextLore/Components/Pages/Games/Roguelike/Builders/EnemyBuilder.cs new file mode 100644 index 0000000..21ef914 --- /dev/null +++ b/src/TextLore/Components/Pages/Games/Roguelike/Builders/EnemyBuilder.cs @@ -0,0 +1,34 @@ +using TextLore.Components.Pages.Games.Roguelike.Models; +using TextLore.Shared.Logic; + +namespace TextLore.Components.Pages.Games.Roguelike.Builders; + +public class EnemyBuilder : IBuilder +{ + private string name = string.Empty; + private string description = string.Empty; + private int maxHealth = 0; + + public EnemyBuilder WithName(string name) + { + this.name = name; + return this; + } + + public EnemyBuilder WithDescription(string description) + { + this.description = description; + return this; + } + + public EnemyBuilder WithMaxHealth(int maxHealth) + { + this.maxHealth = maxHealth; + return this; + } + + public Enemy Build() + { + return new Enemy(name, description, maxHealth); + } +} \ No newline at end of file diff --git a/src/TextLore/Components/Pages/Games/Roguelike/Models/Enemy.cs b/src/TextLore/Components/Pages/Games/Roguelike/Models/Enemy.cs new file mode 100644 index 0000000..ad195d2 --- /dev/null +++ b/src/TextLore/Components/Pages/Games/Roguelike/Models/Enemy.cs @@ -0,0 +1,14 @@ +using TextLore.Shared.Models.Level; + +namespace TextLore.Components.Pages.Games.Roguelike.Models; + +public class Enemy(string name, string description, int maxHealth) : IRoomObject +{ + public string Name => name; + + public string Description => description; + + public int MaxHealth { get; } = maxHealth; + + public int Health { get; set; } = maxHealth; +} \ No newline at end of file diff --git a/src/TextLore/Components/Pages/Games/Roguelike/Models/Weapon.cs b/src/TextLore/Components/Pages/Games/Roguelike/Models/Weapon.cs new file mode 100644 index 0000000..0c56657 --- /dev/null +++ b/src/TextLore/Components/Pages/Games/Roguelike/Models/Weapon.cs @@ -0,0 +1,15 @@ +using TextLore.Shared.Models.Player; + +namespace TextLore.Components.Pages.Games.Roguelike.Models; + +public class Weapon(string name, string description, string tag) : IInventoryItem +{ + public string Name { get; } = name; + public string Description { get; } = description; + public string Tag { get; } = tag; + + public void Shoot() + { + // Shoot the weapon + } +} \ No newline at end of file diff --git a/src/TextLore/Shared/Logic/IBuilder.cs b/src/TextLore/Shared/Logic/IBuilder.cs new file mode 100644 index 0000000..c5f4a77 --- /dev/null +++ b/src/TextLore/Shared/Logic/IBuilder.cs @@ -0,0 +1,6 @@ +namespace TextLore.Shared.Logic; + +public interface IBuilder where T : class +{ + T Build(); +} \ No newline at end of file diff --git a/src/TextLore/Shared/Models/Level/IRoomObject.cs b/src/TextLore/Shared/Models/Level/IRoomObject.cs new file mode 100644 index 0000000..095e2d1 --- /dev/null +++ b/src/TextLore/Shared/Models/Level/IRoomObject.cs @@ -0,0 +1,6 @@ +namespace TextLore.Shared.Models.Level; + +public interface IRoomObject +{ + public string Name { get; } +} \ No newline at end of file diff --git a/src/TextLore/Shared/Models/Player/IInventoryItem.cs b/src/TextLore/Shared/Models/Player/IInventoryItem.cs new file mode 100644 index 0000000..891ead2 --- /dev/null +++ b/src/TextLore/Shared/Models/Player/IInventoryItem.cs @@ -0,0 +1,10 @@ +namespace TextLore.Shared.Models.Player; + +public interface IInventoryItem +{ + public string Name { get; } + + public string Description { get; } + + public string Tag { get; } +} \ No newline at end of file