using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace DataServer.Data.Entities; /// /// A crafting recipe that can produce an item /// Recipes are discovered through trial-and-error /// [Table("dungeon_crafting_recipes")] public class DungeonCraftingRecipe { [Key] public int Id { get; set; } /// /// Name of the recipe (e.g., "Iron Sword", "Health Potion") /// [Required] [MaxLength(64)] public string Name { get; set; } = ""; /// /// Description of the recipe /// [MaxLength(256)] public string Description { get; set; } = ""; /// /// Which crafting skill is used /// public CraftingSkillType SkillType { get; set; } /// /// Minimum crafting level required to craft this recipe /// public int RequiredLevel { get; set; } = 1; /// /// Item definition ID that this recipe produces /// public int OutputItemDefinitionId { get; set; } /// /// How many items are produced per craft /// public int OutputQuantity { get; set; } = 1; /// /// Tier of the recipe (affects XP gain and stat rolls) /// public int Tier { get; set; } = 1; /// /// Base XP awarded for crafting (modified by level difference) /// public int BaseXp { get; set; } = 25; /// /// Whether this is a "base" recipe everyone knows, or must be discovered /// public bool IsBaseRecipe { get; set; } = false; /// /// If true, the output item gets random stat rolls /// If false, it's a fixed item (like potions) /// public bool HasStatRolls { get; set; } = false; /// /// JSON array of possible stats that can roll on this item /// e.g., ["BonusStrength", "BonusDexterity", "MinDamage", "MaxDamage"] /// [MaxLength(1024)] public string? PossibleStatsJson { get; set; } // Bonus output system - at higher levels, chance to get upgraded item /// /// Alternative item to produce at higher levels (null = no bonus output) /// public int? BonusOutputItemDefinitionId { get; set; } /// /// Minimum level to start getting bonus output chance (e.g., 10) /// public int BonusOutputMinLevel { get; set; } = 0; /// /// Chance percentage at min level (e.g., 10 for 10%) /// public float BonusOutputChanceAtMinLevel { get; set; } = 0; /// /// Level at which bonus chance reaches 100% (e.g., 100) /// public int BonusOutputMaxLevel { get; set; } = 100; /// /// Quantity of bonus item to give /// public int BonusOutputQuantity { get; set; } = 1; public bool IsEnabled { get; set; } = true; // Navigation [ForeignKey("OutputItemDefinitionId")] public virtual DungeonItemDefinition? OutputItem { get; set; } public virtual ICollection Ingredients { get; set; } = new List(); // Helper to get possible stats [NotMapped] public List PossibleStats { get { if (string.IsNullOrEmpty(PossibleStatsJson)) return new List(); try { return System.Text.Json.JsonSerializer.Deserialize>(PossibleStatsJson) ?? new List(); } catch { return new List(); } } } } /// /// An ingredient required for a recipe /// [Table("dungeon_crafting_recipe_ingredients")] public class DungeonCraftingRecipeIngredient { [Key] public int Id { get; set; } [Required] public int RecipeId { get; set; } /// /// Item definition ID of the required ingredient /// [Required] public int ItemDefinitionId { get; set; } /// /// How many of this item are needed /// public int Quantity { get; set; } = 1; /// /// Order for recipe matching (ingredients must match in order for discovery) /// public int SlotOrder { get; set; } = 0; // Navigation public virtual DungeonCraftingRecipe? Recipe { get; set; } [ForeignKey("ItemDefinitionId")] public virtual DungeonItemDefinition? ItemDefinition { get; set; } } /// /// Tracks which recipes a character has discovered /// [Table("dungeon_character_known_recipes")] public class DungeonCharacterKnownRecipe { [Key] public ulong Id { get; set; } [Required] public ulong CharacterId { get; set; } [Required] public int RecipeId { get; set; } /// /// When the recipe was discovered /// public DateTime DiscoveredAt { get; set; } = DateTime.UtcNow; /// /// How many times this recipe has been crafted /// public int TimesCrafted { get; set; } = 0; // Navigation public virtual DungeonCharacter? Character { get; set; } public virtual DungeonCraftingRecipe? Recipe { get; set; } } /// /// A recipe scroll item that can teach a recipe when used /// [Table("dungeon_recipe_scrolls")] public class DungeonRecipeScroll { [Key] public int Id { get; set; } /// /// The item definition ID of this scroll /// [Required] public int ItemDefinitionId { get; set; } /// /// The recipe this scroll teaches /// [Required] public int RecipeId { get; set; } // Navigation public virtual DungeonItemDefinition? ItemDefinition { get; set; } public virtual DungeonCraftingRecipe? Recipe { get; set; } }