Working on fixing crafted items

This commit is contained in:
dingo
2026-01-17 15:39:00 -05:00
parent 6edd6ae6df
commit 1b0c1c64a5
3 changed files with 252 additions and 71 deletions
+29
View File
@@ -18,6 +18,8 @@ public class DungeonCharacterItem
public int Quantity { get; set; } = 1;
public int SlotIndex { get; set; } // Inventory position (0-29), or -1 if equipped
public DungeonCraftedItem? CraftedItem { get; set; }
public bool IsEquipped { get; set; } = false;
public DungeonEquipmentSlot? EquipSlot { get; set; }
@@ -28,4 +30,31 @@ public class DungeonCharacterItem
[ForeignKey(nameof(ItemDefinitionId))]
public virtual DungeonItemDefinition? ItemDefinition { get; set; }
/// <summary>
/// Gets total stats including base item definition stats + crafted bonuses
/// </summary>
public (int str, int intel, int wis, int end, int dex, int health, int mana) GetTotalStats(DungeonItemDefinition baseItem)
{
int totalStr = baseItem.BonusStrength;
int totalInt = baseItem.BonusIntelligence;
int totalWis = baseItem.BonusWisdom;
int totalEnd = baseItem.BonusEndurance;
int totalDex = baseItem.BonusDexterity;
int totalHealth = baseItem.BonusHealth;
int totalMana = baseItem.BonusMana;
if (CraftedItem != null)
{
totalStr += CraftedItem.RolledBonusStrength;
totalInt += CraftedItem.RolledBonusIntelligence;
totalWis += CraftedItem.RolledBonusWisdom;
totalEnd += CraftedItem.RolledBonusEndurance;
totalDex += CraftedItem.RolledBonusDexterity;
totalHealth += CraftedItem.RolledBonusHealth;
totalMana += CraftedItem.RolledBonusMana;
}
return (totalStr, totalInt, totalWis, totalEnd, totalDex, totalHealth, totalMana);
}
}
+66 -14
View File
@@ -16,11 +16,54 @@ public static class DungeonCharacterStats
public static float GetMoveSpeed(DungeonCharacter c) => Math.Min(MaxSpeed, BaseSpeed + (c.Dexterity * DexSpeedModifier));
public static float GetAttackSpeed(DungeonCharacter c) => 1.0f + (c.Dexterity * 0.02f);
public static float GetRegenRate(DungeonCharacter c) => 1.0f + (c.Endurance * 0.1f);
/// <summary>
/// Calculate combat stats including equipment bonuses
/// </summary>
public static DungeonCharacterCombatStats GetCombatStats(DungeonCharacter c, List<DungeonItemDefinition>? equippedItems = null)
//public static DungeonCharacterCombatStats GetCombatStats(DungeonCharacter c, List<DungeonItemDefinition>? equippedItems = null)
//{
// var stats = new DungeonCharacterCombatStats
// {
// Strength = c.Strength,
// Intelligence = c.Intelligence,
// Wisdom = c.Wisdom,
// Endurance = c.Endurance,
// Dexterity = c.Dexterity
// };
// if (equippedItems != null)
// {
// foreach (var item in equippedItems)
// {
// stats.Strength += item.BonusStrength;
// stats.Intelligence += item.BonusIntelligence;
// stats.Wisdom += item.BonusWisdom;
// stats.Endurance += item.BonusEndurance;
// stats.Dexterity += item.BonusDexterity;
// stats.BonusHealth += item.BonusHealth;
// stats.BonusMana += item.BonusMana;
// stats.Armor += item.Armor;
// }
// }
// stats.MaxHealth = 50 + (stats.Endurance * 10) + stats.BonusHealth;
// stats.MaxMana = 20 + (stats.Wisdom * 8) + stats.BonusMana;
// stats.MaxStamina = 50 + (stats.Endurance * 5);
// stats.MoveSpeed = Math.Min(MaxSpeed, BaseSpeed + (stats.Dexterity * DexSpeedModifier));
// stats.AttackSpeed = 1.0f + (stats.Dexterity * 0.02f);
// stats.RegenRate = 1.0f + (stats.Endurance * 0.1f);
// stats.PhysicalDamageMultiplier = 1.0f + (stats.Strength * 0.05f);
// stats.SpellDamageMultiplier = 1.0f + (stats.Intelligence * 0.05f);
// stats.XpBonus = 1.0f + (stats.Wisdom * 0.02f);
// return stats;
//}
/// <summary>
/// Calculate combat stats including equipment bonuses (base + crafted)
/// </summary>
public static DungeonCharacterCombatStats GetCombatStats(
DungeonCharacter c,
List<DungeonCharacterItem>? equippedItems = null)
{
var stats = new DungeonCharacterCombatStats
{
@@ -30,22 +73,31 @@ public static class DungeonCharacterStats
Endurance = c.Endurance,
Dexterity = c.Dexterity
};
if (equippedItems != null)
{
foreach (var item in equippedItems)
foreach (var charItem in equippedItems)
{
stats.Strength += item.BonusStrength;
stats.Intelligence += item.BonusIntelligence;
stats.Wisdom += item.BonusWisdom;
stats.Endurance += item.BonusEndurance;
stats.Dexterity += item.BonusDexterity;
stats.BonusHealth += item.BonusHealth;
stats.BonusMana += item.BonusMana;
stats.Armor += item.Armor;
var item = charItem.ItemDefinition;
if (item == null) continue;
// Calculate total stats (base + crafted)
var (totalStr, totalInt, totalWis, totalEnd, totalDex, totalHealth, totalMana) =
charItem.GetTotalStats(item);
stats.Strength += totalStr;
stats.Intelligence += totalInt;
stats.Wisdom += totalWis;
stats.Endurance += totalEnd;
stats.Dexterity += totalDex;
stats.BonusHealth += totalHealth;
stats.BonusMana += totalMana;
// Add armor and damage
stats.Armor += item.Armor + (charItem.CraftedItem?.RolledBonusArmor ?? 0);
}
}
stats.MaxHealth = 50 + (stats.Endurance * 10) + stats.BonusHealth;
stats.MaxMana = 20 + (stats.Wisdom * 8) + stats.BonusMana;
stats.MaxStamina = 50 + (stats.Endurance * 5);
@@ -55,7 +107,7 @@ public static class DungeonCharacterStats
stats.PhysicalDamageMultiplier = 1.0f + (stats.Strength * 0.05f);
stats.SpellDamageMultiplier = 1.0f + (stats.Intelligence * 0.05f);
stats.XpBonus = 1.0f + (stats.Wisdom * 0.02f);
return stats;
}
}