using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json; using DataServer.Data.Enums; namespace DataServer.Data.Entities; /// /// Item template/definition - what an item IS /// [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 /// /// Damage type key (references DamageResistanceType.Key) /// e.g., "physical", "fire", "poison" /// [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; /// /// Duration in seconds for consumable buff effects (resistances, stat boosts) /// 0 = instant effect only, no buff /// public int BuffDuration { get; set; } = 0; /// /// JSON block for temporary resistance buffs when consumed /// Example: {"fire": 0.25, "poison": 0.5} /// Only applies if BuffDuration > 0 /// [MaxLength(1024)] public string BuffResistancesJson { get; set; } = "{}"; /// /// Helper to get/set buff resistances dictionary /// [NotMapped] public Dictionary BuffResistances { get { try { return JsonSerializer.Deserialize>(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 /// /// Whether this weapon requires ammunition to fire (bows, crossbows) /// Throwable weapons (knives, javelins) don't require ammo but consume themselves /// public bool RequiresAmmunition { get; set; } = false; /// /// Type of ammunition required (e.g., "arrow", "bolt") /// Null for melee weapons and throwables /// [MaxLength(32)] public string? AmmunitionType { get; set; } /// /// Projectile speed in pixels per second (0 = melee weapon) /// public float ProjectileSpeed { get; set; } = 0; /// /// Max range in pixels before projectile expires (0 = melee weapon) /// public int ProjectileRange { get; set; } = 0; /// /// 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 /// public float ArrowRecoveryChance { get; set; } = 0.05f; /// /// For quiver containers: number of ammo slots available /// 0 = not a container /// public int QuiverCapacity { get; set; } = 0; /// /// Whether this item is throwable (consumes from inventory) /// public bool IsThrowable { get; set; } = false; /// /// Whether projectile flies linearly (true) or spins (false) /// Linear projectiles use front/back coordinates /// Spinning projectiles rotate as they fly /// public bool IsLinearProjectile { get; set; } = false; /// /// X coordinate of arrow tip (front) in the sprite image /// Only used when IsLinearProjectile = true /// public int ProjectileFrontX { get; set; } = 0; /// /// Y coordinate of arrow tip (front) in the sprite image /// Only used when IsLinearProjectile = true /// public int ProjectileFrontY { get; set; } = 0; /// /// X coordinate of arrow tail (back) in the sprite image /// Only used when IsLinearProjectile = true /// public int ProjectileBackX { get; set; } = 0; /// /// Y coordinate of arrow tail (back) in the sprite image /// Only used when IsLinearProjectile = true /// public int ProjectileBackY { get; set; } = 0; // Visuals /// /// 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 /// [MaxLength(256)] public string? SpritePath { get; set; } /// /// Optional color tint as hex (e.g., "#ff0000" for red tint) /// [MaxLength(16)] public string? TintColor { get; set; } // Legacy field - kept for backwards compatibility public int SpriteId { get; set; } = 0; /// /// JSON block for resistance bonuses when equipped /// Example: {"fire": 0.15, "ice": 0.10} /// Values are percentage (0.15 = 15% resistance) /// [MaxLength(1024)] public string ResistancesJson { get; set; } = "{}"; /// /// Helper to get/set resistances dictionary /// [NotMapped] public Dictionary Resistances { get { try { return JsonSerializer.Deserialize>(ResistancesJson) ?? new(); } catch { return new(); } } set { ResistancesJson = JsonSerializer.Serialize(value); } } public bool IsEnabled { get; set; } = true; }