mirror of
https://github.com/Stone-Red-Code/TextLore.git
synced 2026-09-04 00:56:26 +02:00
Add simple enemy builder and weapon class
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
Reference in New Issue
Block a user