Files
2026-01-17 15:39:00 -05:00

114 lines
4.7 KiB
C#

namespace DataServer.Data.Entities;
/// <summary>
/// Derived stats calculator - used at runtime
/// </summary>
public static class DungeonCharacterStats
{
private const float BaseSpeed = 100f;
private const float DexSpeedModifier = 0.5f; // Reduced from 2f
private const float MaxSpeed = 500f;
public static int GetMaxHealth(DungeonCharacter c) => 50 + (c.Endurance * 10);
public static int GetMaxMana(DungeonCharacter c) => 20 + (c.Wisdom * 8);
public static int GetMaxStamina(DungeonCharacter c) => 50 + (c.Endurance * 5);
public static float GetXpBonus(DungeonCharacter c) => 1.0f + (c.Wisdom * 0.02f);
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)
//{
// 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
{
Strength = c.Strength,
Intelligence = c.Intelligence,
Wisdom = c.Wisdom,
Endurance = c.Endurance,
Dexterity = c.Dexterity
};
if (equippedItems != null)
{
foreach (var charItem in equippedItems)
{
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);
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;
}
}