242 lines
8.1 KiB
C#
242 lines
8.1 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Text.Json;
|
|
using DataServer.Data.Enums;
|
|
|
|
namespace DataServer.Data.Entities;
|
|
|
|
/// <summary>
|
|
/// Item template/definition - what an item IS
|
|
/// </summary>
|
|
[Table("dungeon_item_definitions")]
|
|
public class DungeonItemDefinition
|
|
{
|
|
[Key]
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(64)]
|
|
public string Name { get; set; } = "";
|
|
|
|
[MaxLength(256)]
|
|
public string Description { get; set; } = "";
|
|
|
|
public ItemType Type { get; set; }
|
|
public ItemRarity Rarity { get; set; } = ItemRarity.Common;
|
|
public DungeonEquipmentSlot? EquipSlot { get; set; } // Null if not equippable
|
|
|
|
// Stat requirements to equip/use
|
|
public int RequiredStrength { get; set; } = 0;
|
|
public int RequiredIntelligence { get; set; } = 0;
|
|
public int RequiredWisdom { get; set; } = 0;
|
|
public int RequiredDexterity { get; set; } = 0;
|
|
public int RequiredLevel { get; set; } = 1;
|
|
|
|
// Stat bonuses when equipped (base values - used for drops/purchases)
|
|
public int BonusStrength { get; set; } = 0;
|
|
public int BonusIntelligence { get; set; } = 0;
|
|
public int BonusWisdom { get; set; } = 0;
|
|
public int BonusEndurance { get; set; } = 0;
|
|
public int BonusDexterity { get; set; } = 0;
|
|
public int BonusHealth { get; set; } = 0;
|
|
public int BonusMana { get; set; } = 0;
|
|
|
|
// Stat ranges for crafting (if HasStatRolls on recipe)
|
|
// When crafting, each stat is rolled between Min and Max
|
|
// Higher crafting skill = higher chance for max rolls
|
|
public int MinBonusStrength { get; set; } = 0;
|
|
public int MaxBonusStrength { get; set; } = 0;
|
|
public int MinBonusIntelligence { get; set; } = 0;
|
|
public int MaxBonusIntelligence { get; set; } = 0;
|
|
public int MinBonusWisdom { get; set; } = 0;
|
|
public int MaxBonusWisdom { get; set; } = 0;
|
|
public int MinBonusEndurance { get; set; } = 0;
|
|
public int MaxBonusEndurance { get; set; } = 0;
|
|
public int MinBonusDexterity { get; set; } = 0;
|
|
public int MaxBonusDexterity { get; set; } = 0;
|
|
public int MinBonusHealth { get; set; } = 0;
|
|
public int MaxBonusHealth { get; set; } = 0;
|
|
public int MinBonusMana { get; set; } = 0;
|
|
public int MaxBonusMana { get; set; } = 0;
|
|
|
|
// Weapon damage ranges for crafting
|
|
public int MinMinDamage { get; set; } = 0;
|
|
public int MaxMinDamage { get; set; } = 0;
|
|
public int MinMaxDamage { get; set; } = 0;
|
|
public int MaxMaxDamage { get; set; } = 0;
|
|
|
|
// Armor range for crafting
|
|
public int MinArmor { get; set; } = 0;
|
|
public int MaxArmor { get; set; } = 0;
|
|
|
|
// Weapon stats (base values)
|
|
public int MinDamage { get; set; } = 0;
|
|
public int MaxDamage { get; set; } = 0;
|
|
public float AttackRange { get; set; } = 0; // 0 = melee
|
|
|
|
/// <summary>
|
|
/// Damage type key (references DamageResistanceType.Key)
|
|
/// e.g., "physical", "fire", "poison"
|
|
/// </summary>
|
|
[MaxLength(32)]
|
|
public string DamageTypeKey { get; set; } = "physical";
|
|
|
|
// Armor stats (flat damage reduction for all damage types)
|
|
public int Armor { get; set; } = 0;
|
|
|
|
// Consumable effects
|
|
public int HealAmount { get; set; } = 0;
|
|
public int ManaRestore { get; set; } = 0;
|
|
public int StaminaRestore { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Duration in seconds for consumable buff effects (resistances, stat boosts)
|
|
/// 0 = instant effect only, no buff
|
|
/// </summary>
|
|
public int BuffDuration { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// JSON block for temporary resistance buffs when consumed
|
|
/// Example: {"fire": 0.25, "poison": 0.5}
|
|
/// Only applies if BuffDuration > 0
|
|
/// </summary>
|
|
[MaxLength(1024)]
|
|
public string BuffResistancesJson { get; set; } = "{}";
|
|
|
|
/// <summary>
|
|
/// Helper to get/set buff resistances dictionary
|
|
/// </summary>
|
|
[NotMapped]
|
|
public Dictionary<string, float> BuffResistances
|
|
{
|
|
get
|
|
{
|
|
try { return JsonSerializer.Deserialize<Dictionary<string, float>>(BuffResistancesJson) ?? new(); }
|
|
catch { return new(); }
|
|
}
|
|
set { BuffResistancesJson = JsonSerializer.Serialize(value); }
|
|
}
|
|
|
|
// Special
|
|
public bool IsTeleportScroll { get; set; } = false;
|
|
public int? TeachesSpellId { get; set; } // For spell tomes
|
|
|
|
// Stacking
|
|
public bool Stackable { get; set; } = false;
|
|
public int MaxStack { get; set; } = 1;
|
|
|
|
// Projectile/Ranged Weapon Properties
|
|
/// <summary>
|
|
/// Whether this weapon requires ammunition to fire (bows, crossbows)
|
|
/// Throwable weapons (knives, javelins) don't require ammo but consume themselves
|
|
/// </summary>
|
|
public bool RequiresAmmunition { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Type of ammunition required (e.g., "arrow", "bolt")
|
|
/// Null for melee weapons and throwables
|
|
/// </summary>
|
|
[MaxLength(32)]
|
|
public string? AmmunitionType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Projectile speed in pixels per second (0 = melee weapon)
|
|
/// </summary>
|
|
public float ProjectileSpeed { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Max range in pixels before projectile expires (0 = melee weapon)
|
|
/// </summary>
|
|
public int ProjectileRange { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Chance (0.0 to 1.0) to recover this ammunition after hitting a target
|
|
/// 0.05 = 5%, 0.20 = 20%, etc.
|
|
/// Only applies to ammunition items
|
|
/// </summary>
|
|
public float ArrowRecoveryChance { get; set; } = 0.05f;
|
|
|
|
/// <summary>
|
|
/// For quiver containers: number of ammo slots available
|
|
/// 0 = not a container
|
|
/// </summary>
|
|
public int QuiverCapacity { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Whether this item is throwable (consumes from inventory)
|
|
/// </summary>
|
|
public bool IsThrowable { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Whether projectile flies linearly (true) or spins (false)
|
|
/// Linear projectiles use front/back coordinates
|
|
/// Spinning projectiles rotate as they fly
|
|
/// </summary>
|
|
public bool IsLinearProjectile { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// X coordinate of arrow tip (front) in the sprite image
|
|
/// Only used when IsLinearProjectile = true
|
|
/// </summary>
|
|
public int ProjectileFrontX { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Y coordinate of arrow tip (front) in the sprite image
|
|
/// Only used when IsLinearProjectile = true
|
|
/// </summary>
|
|
public int ProjectileFrontY { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// X coordinate of arrow tail (back) in the sprite image
|
|
/// Only used when IsLinearProjectile = true
|
|
/// </summary>
|
|
public int ProjectileBackX { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Y coordinate of arrow tail (back) in the sprite image
|
|
/// Only used when IsLinearProjectile = true
|
|
/// </summary>
|
|
public int ProjectileBackY { get; set; } = 0;
|
|
|
|
// Visuals
|
|
/// <summary>
|
|
/// Path to the item's sprite image on CDN (e.g., "textures/items/sword_iron.png")
|
|
/// If null/empty, client uses fallback placeholder based on item type
|
|
/// </summary>
|
|
[MaxLength(256)]
|
|
public string? SpritePath { get; set; }
|
|
|
|
/// <summary>
|
|
/// Optional color tint as hex (e.g., "#ff0000" for red tint)
|
|
/// </summary>
|
|
[MaxLength(16)]
|
|
public string? TintColor { get; set; }
|
|
|
|
// Legacy field - kept for backwards compatibility
|
|
public int SpriteId { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// JSON block for resistance bonuses when equipped
|
|
/// Example: {"fire": 0.15, "ice": 0.10}
|
|
/// Values are percentage (0.15 = 15% resistance)
|
|
/// </summary>
|
|
[MaxLength(1024)]
|
|
public string ResistancesJson { get; set; } = "{}";
|
|
|
|
/// <summary>
|
|
/// Helper to get/set resistances dictionary
|
|
/// </summary>
|
|
[NotMapped]
|
|
public Dictionary<string, float> Resistances
|
|
{
|
|
get
|
|
{
|
|
try { return JsonSerializer.Deserialize<Dictionary<string, float>>(ResistancesJson) ?? new(); }
|
|
catch { return new(); }
|
|
}
|
|
set { ResistancesJson = JsonSerializer.Serialize(value); }
|
|
}
|
|
|
|
public bool IsEnabled { get; set; } = true;
|
|
}
|