diff --git a/Game/Dungeon/CraftingHandler.cs b/Game/Dungeon/CraftingHandler.cs index 2b9ad9b..3a653bb 100644 --- a/Game/Dungeon/CraftingHandler.cs +++ b/Game/Dungeon/CraftingHandler.cs @@ -392,18 +392,43 @@ public class CraftingHandler CraftingLevelAtCreation = skill.Level }; - // Calculate skill quality bonus - // Formula creates a curve where you need to significantly overlevel the recipe to get perfect rolls - // At required level: ~10% chance for max - // At 2x required level: ~40% chance - // At 4x required level: ~75% chance - // At 10x required level: ~95% chance - float levelRatio = (float)skill.Level / Math.Max(1, recipe.RequiredLevel); - float skillBonus = Math.Min(0.95f, (levelRatio - 1f) / 10f); // Caps at 95% to keep some RNG - skillBonus = Math.Max(0.05f, skillBonus); // Minimum 5% chance + // Calculate skill quality bonus using EXPONENTIAL scaling + // Every time you double the level requirement, your chance for perfect rolls increases exponentially + // + // Example: Recipe requires level 1, has 5 stats rolling 1-100 each + // - At level 1 (1x): ~0.1% chance per stat = 0.00000000001% for all 5 perfect (basically impossible) + // - At level 2 (2x): ~1% chance per stat = 0.000000001% for all 5 perfect (extremely rare) + // - At level 4 (4x): ~10% chance per stat = 0.001% for all 5 perfect (very rare) + // - At level 8 (8x): ~30% chance per stat = 0.24% for all 5 perfect (rare) + // - At level 16 (16x): ~60% chance per stat = 7.7% for all 5 perfect (uncommon) + // - At level 32 (32x): ~85% chance per stat = 44% for all 5 perfect (common) + // - At level 64 (64x): ~95% chance per stat = 77% for all 5 perfect (very common) + // + // Formula: skillBonus = 1 - (0.999^(2^doublings)) + // This creates exponential growth where each doubling significantly increases your odds - _log.LogInformation("Skill bonus: {SkillBonus:F2} (level {Level} / required {Required}, ratio {Ratio:F2})", - skillBonus, skill.Level, recipe.RequiredLevel, levelRatio); + float levelRatio = (float)skill.Level / Math.Max(1, recipe.RequiredLevel); + + // Calculate how many times we've doubled the requirement (log base 2) + double doublings = Math.Log(levelRatio, 2); + + // Exponential formula: each doubling dramatically increases quality + // Using 0.999 as base means at exactly the requirement you have ~0.1% chance + // At 2x (1 doubling) = ~1% chance + // At 4x (2 doublings) = ~10% chance + // At 8x (3 doublings) = ~30% chance + // At 16x (4 doublings) = ~60% chance + double exponentialFactor = Math.Pow(2, doublings); + float skillBonus = (float)(1.0 - Math.Pow(0.999, exponentialFactor)); + + // Cap at 99% to keep some RNG element even at extreme overleveling + skillBonus = Math.Min(0.99f, skillBonus); + + // Ensure minimum of 0.1% chance even at minimum level + skillBonus = Math.Max(0.001f, skillBonus); + + _log.LogInformation("Skill bonus: {SkillBonus:F4} (level {Level} / required {Required}, ratio {Ratio:F2}x, doublings {Doublings:F2})", + skillBonus, skill.Level, recipe.RequiredLevel, levelRatio, doublings); int totalRolled = 0; int maxPossibleTotal = 0; diff --git a/Services/Admin/Pages/Players/Character.cshtml b/Services/Admin/Pages/Players/Character.cshtml index 45798ab..1ed20de 100644 --- a/Services/Admin/Pages/Players/Character.cshtml +++ b/Services/Admin/Pages/Players/Character.cshtml @@ -139,8 +139,12 @@ { @item.Quantity } + @if (item.CraftedItem != null) + { + ⚒️ + } } @@ -221,7 +225,7 @@ { var item = Model.EquippedItems.FirstOrDefault(i => i.EquipSlot == slot.Item1);
-
+
@if (item?.ItemDefinition != null && !string.IsNullOrEmpty(item.ItemDefinition.SpritePath)) { @@ -230,17 +234,25 @@ { @slot.Item2.Substring(0, 1) } + @if (item?.CraftedItem != null) + { + ⚒️ + }

@slot.Item2

@(item?.ItemDefinition?.Name ?? "Empty") + @if (item?.CraftedItem != null) + { + (Q@(item.CraftedItem.QualityRating)%) + }

@if (item?.ItemDefinition != null) { }
diff --git a/Services/Admin/Pages/Players/_CharacterItemTooltip.cshtml b/Services/Admin/Pages/Players/_CharacterItemTooltip.cshtml new file mode 100644 index 0000000..4996641 --- /dev/null +++ b/Services/Admin/Pages/Players/_CharacterItemTooltip.cshtml @@ -0,0 +1,187 @@ +@model DataServer.Data.Entities.DungeonCharacterItem +@using DataServer.Data.Enums + +@{ + var def = Model.ItemDefinition; + if (def == null) return; + + var rarityColor = def.Rarity switch + { + ItemRarity.Uncommon => "text-green-400", + ItemRarity.Rare => "text-blue-400", + ItemRarity.Epic => "text-purple-400", + ItemRarity.Legendary => "text-orange-400", + _ => "text-gray-300" + }; + + var rarityBg = def.Rarity switch + { + ItemRarity.Uncommon => "border-green-600", + ItemRarity.Rare => "border-blue-600", + ItemRarity.Epic => "border-purple-600", + ItemRarity.Legendary => "border-orange-600", + _ => "border-gray-600" + }; + + // Calculate total stats (base + crafted) + var (totalStr, totalInt, totalWis, totalEnd, totalDex, totalHealth, totalMana) = Model.GetTotalStats(def); + var craftedItem = Model.CraftedItem; + var hasCraftedStats = craftedItem != null; + + int totalMinDamage = def.MinDamage + (craftedItem?.RolledBonusMinDamage ?? 0); + int totalMaxDamage = def.MaxDamage + (craftedItem?.RolledBonusMaxDamage ?? 0); + int totalArmor = def.Armor + (craftedItem?.RolledBonusArmor ?? 0); +} + +
+ +
+

+ @if (!string.IsNullOrEmpty(craftedItem?.CustomName)) + { + @craftedItem.CustomName + } + else + { + @def.Name + } +

+

@def.Type • @def.Rarity

+ @if (hasCraftedStats) + { +

⚒️ Crafted (Quality: @craftedItem!.QualityRating%)

+

by @craftedItem.CrafterName

+ } +
+ + @if (!string.IsNullOrEmpty(def.Description)) + { +

@def.Description

+ } + + + @if (totalMinDamage > 0 || totalMaxDamage > 0) + { +
+ @totalMinDamage - @totalMaxDamage + @def.DamageTypeKey Damage + @if (hasCraftedStats && (craftedItem!.RolledBonusMinDamage > 0 || craftedItem.RolledBonusMaxDamage > 0)) + { + +@craftedItem.RolledBonusMinDamage-@craftedItem.RolledBonusMaxDamage (crafted) + } + @if (def.AttackRange > 0) + { + Range: @def.AttackRange + } +
+ } + + + @if (totalArmor > 0) + { +
+

+ Armor: + @totalArmor + @if (hasCraftedStats && craftedItem!.RolledBonusArmor > 0) + { + (+@craftedItem.RolledBonusArmor crafted) + } +

+
+ } + + + @{ + var bonuses = new List<(string name, int baseValue, int craftedValue, int total, string color)>(); + if (totalStr != 0) bonuses.Add(("STR", def.BonusStrength, craftedItem?.RolledBonusStrength ?? 0, totalStr, "text-red-400")); + if (totalInt != 0) bonuses.Add(("INT", def.BonusIntelligence, craftedItem?.RolledBonusIntelligence ?? 0, totalInt, "text-blue-400")); + if (totalWis != 0) bonuses.Add(("WIS", def.BonusWisdom, craftedItem?.RolledBonusWisdom ?? 0, totalWis, "text-purple-400")); + if (totalEnd != 0) bonuses.Add(("END", def.BonusEndurance, craftedItem?.RolledBonusEndurance ?? 0, totalEnd, "text-green-400")); + if (totalDex != 0) bonuses.Add(("DEX", def.BonusDexterity, craftedItem?.RolledBonusDexterity ?? 0, totalDex, "text-yellow-400")); + if (totalHealth != 0) bonuses.Add(("HP", def.BonusHealth, craftedItem?.RolledBonusHealth ?? 0, totalHealth, "text-green-300")); + if (totalMana != 0) bonuses.Add(("Mana", def.BonusMana, craftedItem?.RolledBonusMana ?? 0, totalMana, "text-blue-300")); + } + @if (bonuses.Any()) + { +
+ @foreach (var bonus in bonuses) + { + var sign = bonus.total > 0 ? "+" : ""; +

+ @sign@bonus.total @bonus.name + @if (bonus.craftedValue > 0) + { + (+@bonus.craftedValue crafted) + } +

+ } +
+ } + + + @if (def.HealAmount > 0 || def.ManaRestore > 0 || def.StaminaRestore > 0) + { +
+ @if (def.HealAmount > 0) + { +

Restores @def.HealAmount HP

+ } + @if (def.ManaRestore > 0) + { +

Restores @def.ManaRestore Mana

+ } + @if (def.StaminaRestore > 0) + { +

Restores @def.StaminaRestore Stamina

+ } +
+ } + + + @{ + var reqs = new List(); + if (def.RequiredLevel > 1) reqs.Add($"Level {def.RequiredLevel}"); + if (def.RequiredStrength > 0) reqs.Add($"{def.RequiredStrength} STR"); + if (def.RequiredIntelligence > 0) reqs.Add($"{def.RequiredIntelligence} INT"); + if (def.RequiredWisdom > 0) reqs.Add($"{def.RequiredWisdom} WIS"); + if (def.RequiredDexterity > 0) reqs.Add($"{def.RequiredDexterity} DEX"); + } + @if (reqs.Any()) + { +
+ Requires: @string.Join(", ", reqs) +
+ } + + + @if (def.IsTeleportScroll) + { +

Teleport Scroll

+ } + @if (def.TeachesSpellId.HasValue) + { +

Teaches a spell

+ } + + + @if (def.Stackable && Model.Quantity > 1) + { +

Quantity: @Model.Quantity / @def.MaxStack

+ } + + + @if (def.EquipSlot.HasValue) + { +

Slot: @def.EquipSlot

+ } + + +

+ Item ID: @Model.Id + @if (hasCraftedStats) + { + Craft ID: @craftedItem!.Id + } +

+