using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace DataServer.Data.Entities; /// /// A crafted item with randomly rolled stats /// This extends the base item definition with crafted bonuses /// [Table("dungeon_crafted_items")] public class DungeonCraftedItem { [Key] public ulong Id { get; set; } /// /// The base item definition this was crafted from /// [Required] public int BaseItemDefinitionId { get; set; } /// /// The character who crafted this item /// public ulong? CrafterId { get; set; } /// /// Name of the crafter (stored separately in case character is deleted) /// [MaxLength(32)] public string? CrafterName { get; set; } /// /// The recipe used to craft this /// public int? RecipeId { get; set; } /// /// When this item was crafted /// public DateTime CraftedAt { get; set; } = DateTime.UtcNow; /// /// Crafting skill level when this was made /// public int CraftingLevelAtCreation { get; set; } = 1; // Rolled stat bonuses (added to base item stats) public int RolledBonusStrength { get; set; } = 0; public int RolledBonusIntelligence { get; set; } = 0; public int RolledBonusWisdom { get; set; } = 0; public int RolledBonusEndurance { get; set; } = 0; public int RolledBonusDexterity { get; set; } = 0; public int RolledBonusHealth { get; set; } = 0; public int RolledBonusMana { get; set; } = 0; public int RolledBonusArmor { get; set; } = 0; public int RolledBonusMagicResist { get; set; } = 0; public int RolledBonusMinDamage { get; set; } = 0; public int RolledBonusMaxDamage { get; set; } = 0; public int RolledBonusHealAmount { get; set; } = 0; public int RolledBonusManaRestore { get; set; } = 0; /// /// Quality rating based on how good the rolls were (0-100) /// public int QualityRating { get; set; } = 50; /// /// Custom name given by crafter (optional) /// [MaxLength(64)] public string? CustomName { get; set; } /// /// JSON storing the individual rolls for display /// e.g., [{"stat": "BonusStrength", "value": 5}, {"stat": "MinDamage", "value": 3}] /// [MaxLength(1024)] public string? RollHistoryJson { get; set; } // Navigation public virtual DungeonItemDefinition? BaseItemDefinition { get; set; } public virtual DungeonCharacter? Crafter { get; set; } public virtual DungeonCraftingRecipe? Recipe { get; set; } /// /// Get the display name (custom name or base item name with quality prefix) /// [NotMapped] public string DisplayName { get { if (!string.IsNullOrEmpty(CustomName)) return CustomName; string prefix = QualityRating switch { >= 95 => "Masterwork ", >= 85 => "Exceptional ", >= 70 => "Fine ", >= 50 => "", >= 30 => "Crude ", _ => "Poor " }; return prefix + (BaseItemDefinition?.Name ?? "Item"); } } /// /// Get total bonus value for sorting/comparison /// [NotMapped] public int TotalBonusValue => RolledBonusStrength + RolledBonusIntelligence + RolledBonusWisdom + RolledBonusEndurance + RolledBonusDexterity + RolledBonusHealth + RolledBonusMana + RolledBonusArmor + RolledBonusMagicResist + RolledBonusMinDamage + RolledBonusMaxDamage + RolledBonusHealAmount + RolledBonusManaRestore; } /// /// Maps a DungeonCharacterItem to a DungeonCraftedItem if it was crafted /// [Table("dungeon_character_item_crafted_link")] public class DungeonCharacterItemCraftedLink { [Key] public ulong Id { get; set; } /// /// The character's inventory item /// [Required] public ulong CharacterItemId { get; set; } /// /// The crafted item data /// [Required] public ulong CraftedItemId { get; set; } // Navigation public virtual DungeonCharacterItem? CharacterItem { get; set; } public virtual DungeonCraftedItem? CraftedItem { get; set; } }