Add simple enemy builder and weapon class

This commit is contained in:
Stone_Red
2024-02-07 21:51:09 +01:00
parent 6cc7b05501
commit 9c2a6e9c97
6 changed files with 85 additions and 0 deletions
@@ -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<Enemy>
{
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);
}
}
@@ -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;
}
@@ -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
}
}
+6
View File
@@ -0,0 +1,6 @@
namespace TextLore.Shared.Logic;
public interface IBuilder<out T> where T : class
{
T Build();
}
@@ -0,0 +1,6 @@
namespace TextLore.Shared.Models.Level;
public interface IRoomObject
{
public string Name { get; }
}
@@ -0,0 +1,10 @@
namespace TextLore.Shared.Models.Player;
public interface IInventoryItem
{
public string Name { get; }
public string Description { get; }
public string Tag { get; }
}