using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using DataServer.Data.Enums; namespace DataServer.Data.Entities; /// /// Types of crafting skills /// public enum CraftingSkillType { Smithing = 0, // Weapons, Armor (metal-based) Fletching = 1, // Bows, Arrows, Crossbows Jewelry = 2, // Rings, Amulets, Accessories Alchemy = 3, // Potions, Resource Transmutation Academic = 4 // Scrolls, Spellbooks, Enchantments } /// /// A character's progress in a crafting skill /// [Table("dungeon_character_crafting_skills")] public class DungeonCharacterCraftingSkill { [Key] public ulong Id { get; set; } [Required] public ulong CharacterId { get; set; } [Required] public CraftingSkillType SkillType { get; set; } /// /// Current level in this crafting skill (1-100) /// public int Level { get; set; } = 1; /// /// XP progress toward next level /// public long Experience { get; set; } = 0; /// /// Total items crafted with this skill /// public int TotalItemsCrafted { get; set; } = 0; // Navigation public virtual DungeonCharacter? Character { get; set; } // Helper methods [NotMapped] public long ExperienceForNextLevel => GetXpForLevel(Level + 1); [NotMapped] public float ProgressToNextLevel => Level >= 100 ? 1f : (float)Experience / ExperienceForNextLevel; /// /// Number of stat rolls when crafting (increases with level) /// Level 1-19: 1 roll /// Level 20-39: 2 rolls /// Level 40-59: 3 rolls /// Level 60-79: 4 rolls /// Level 80-99: 5 rolls /// Level 100: 6 rolls /// [NotMapped] public int StatRollCount => Math.Min(6, 1 + (Level / 20)); /// /// Minimum stat roll value (increases with level) /// [NotMapped] public int MinStatRoll => 1 + (Level / 10); /// /// Maximum stat roll value (increases with level) /// [NotMapped] public int MaxStatRoll => 5 + (Level / 5); /// /// XP required to reach a specific level /// Uses exponential curve: base * level^2 /// public static long GetXpForLevel(int level) { if (level <= 1) return 0; return (long)(100 * Math.Pow(level, 2.2)); } /// /// XP gained from crafting an item of a certain tier /// public static int GetCraftingXp(int itemTier, int craftingLevel) { // Base XP from tier int baseXp = itemTier * 25; // Bonus for crafting items near your level int levelDiff = Math.Abs(itemTier * 10 - craftingLevel); float multiplier = Math.Max(0.1f, 1.0f - (levelDiff * 0.05f)); return (int)(baseXp * multiplier); } } /// /// Static helper for crafting skill calculations /// public static class CraftingSkillHelper { /// /// Get which crafting skill is used for a given item type /// public static CraftingSkillType? GetSkillForItemType(ItemType itemType, string itemName = "") { switch (itemType) { case ItemType.Weapon: // Check if it's a bow/crossbow (fletching) or metal weapon (smithing) if (itemName.Contains("bow", StringComparison.OrdinalIgnoreCase) || itemName.Contains("arrow", StringComparison.OrdinalIgnoreCase) || itemName.Contains("crossbow", StringComparison.OrdinalIgnoreCase)) return CraftingSkillType.Fletching; return CraftingSkillType.Smithing; case ItemType.Armor: return CraftingSkillType.Smithing; case ItemType.Accessory: return CraftingSkillType.Jewelry; case ItemType.Consumable: // Check if it's a scroll (academic) or potion (alchemy) if (itemName.Contains("scroll", StringComparison.OrdinalIgnoreCase) || itemName.Contains("tome", StringComparison.OrdinalIgnoreCase) || itemName.Contains("book", StringComparison.OrdinalIgnoreCase)) return CraftingSkillType.Academic; return CraftingSkillType.Alchemy; case ItemType.Material: return null; // Materials aren't crafted directly default: return null; } } }