Crafting fix

This commit is contained in:
dingo
2025-12-28 09:57:59 -05:00
parent b209b1662a
commit 0189690f9a
2 changed files with 53 additions and 0 deletions
+9
View File
@@ -378,6 +378,9 @@ public class CraftingHandler
// Handle stat rolling for equipment
if (recipe.HasStatRolls && outputItemDef != null)
{
_log.LogInformation("Crafting item {ItemName} with stat rolls. MinStr={MinStr}, MaxStr={MaxStr}",
outputItemDef.Name, outputItemDef.MinBonusStrength, outputItemDef.MaxBonusStrength);
var rng = new Random();
craftedItem = new DungeonCraftedItem
{
@@ -393,6 +396,8 @@ public class CraftingHandler
// 2x required level = 50% chance for max on each roll
// Formula: skillBonus = min(1.0, skill.Level / (recipe.RequiredLevel * 2))
float skillBonus = Math.Min(1.0f, (float)skill.Level / (recipe.RequiredLevel * 2));
_log.LogInformation("Skill bonus: {SkillBonus} (level {Level} / required {Required})",
skillBonus, skill.Level, recipe.RequiredLevel);
int totalRolled = 0;
int maxPossibleTotal = 0;
@@ -400,9 +405,13 @@ public class CraftingHandler
// Roll each stat that has a range defined on the item
rollResults = RollItemStats(outputItemDef, skillBonus, rng, out totalRolled, out maxPossibleTotal);
_log.LogInformation("Rolled {Count} stats, total={Total}, maxPossible={Max}",
rollResults.Count, totalRolled, maxPossibleTotal);
// Apply rolled stats to the crafted item
foreach (var (stat, value) in rollResults)
{
_log.LogInformation("Applying stat {Stat} = {Value}", stat, value);
ApplyStatRoll(craftedItem, stat, value);
}