147 lines
4.5 KiB
C#
147 lines
4.5 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Server.Data.Entities;
|
|
|
|
/// <summary>
|
|
/// A crafted item with randomly rolled stats
|
|
/// This extends the base item definition with crafted bonuses
|
|
/// </summary>
|
|
[Table("dungeon_crafted_items")]
|
|
public class DungeonCraftedItem
|
|
{
|
|
[Key]
|
|
public ulong Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// The base item definition this was crafted from
|
|
/// </summary>
|
|
[Required]
|
|
public int BaseItemDefinitionId { get; set; }
|
|
|
|
/// <summary>
|
|
/// The character who crafted this item
|
|
/// </summary>
|
|
public ulong? CrafterId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Name of the crafter (stored separately in case character is deleted)
|
|
/// </summary>
|
|
[MaxLength(32)]
|
|
public string? CrafterName { get; set; }
|
|
|
|
/// <summary>
|
|
/// The recipe used to craft this
|
|
/// </summary>
|
|
public int? RecipeId { get; set; }
|
|
|
|
/// <summary>
|
|
/// When this item was crafted
|
|
/// </summary>
|
|
public DateTime CraftedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
/// <summary>
|
|
/// Crafting skill level when this was made
|
|
/// </summary>
|
|
public int CraftingLevelAtCreation { get; set; } = 1;
|
|
|
|
// Rolled stat bonuses (added to base item stats)
|
|
public int RolledBonusStrength { get; set; } = 0;
|
|
public int RolledBonusIntelligence { get; set; } = 0;
|
|
public int RolledBonusWisdom { get; set; } = 0;
|
|
public int RolledBonusEndurance { get; set; } = 0;
|
|
public int RolledBonusDexterity { get; set; } = 0;
|
|
public int RolledBonusHealth { get; set; } = 0;
|
|
public int RolledBonusMana { get; set; } = 0;
|
|
public int RolledBonusArmor { get; set; } = 0;
|
|
public int RolledBonusMagicResist { get; set; } = 0;
|
|
public int RolledBonusMinDamage { get; set; } = 0;
|
|
public int RolledBonusMaxDamage { get; set; } = 0;
|
|
public int RolledBonusHealAmount { get; set; } = 0;
|
|
public int RolledBonusManaRestore { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Quality rating based on how good the rolls were (0-100)
|
|
/// </summary>
|
|
public int QualityRating { get; set; } = 50;
|
|
|
|
/// <summary>
|
|
/// Custom name given by crafter (optional)
|
|
/// </summary>
|
|
[MaxLength(64)]
|
|
public string? CustomName { get; set; }
|
|
|
|
/// <summary>
|
|
/// JSON storing the individual rolls for display
|
|
/// e.g., [{"stat": "BonusStrength", "value": 5}, {"stat": "MinDamage", "value": 3}]
|
|
/// </summary>
|
|
[MaxLength(1024)]
|
|
public string? RollHistoryJson { get; set; }
|
|
|
|
// Navigation
|
|
public virtual DungeonItemDefinition? BaseItemDefinition { get; set; }
|
|
public virtual DungeonCharacter? Crafter { get; set; }
|
|
public virtual DungeonCraftingRecipe? Recipe { get; set; }
|
|
|
|
/// <summary>
|
|
/// Get the display name (custom name or base item name with quality prefix)
|
|
/// </summary>
|
|
[NotMapped]
|
|
public string DisplayName
|
|
{
|
|
get
|
|
{
|
|
if (!string.IsNullOrEmpty(CustomName)) return CustomName;
|
|
|
|
string prefix = QualityRating switch
|
|
{
|
|
>= 95 => "Masterwork ",
|
|
>= 85 => "Exceptional ",
|
|
>= 70 => "Fine ",
|
|
>= 50 => "",
|
|
>= 30 => "Crude ",
|
|
_ => "Poor "
|
|
};
|
|
|
|
return prefix + (BaseItemDefinition?.Name ?? "Item");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get total bonus value for sorting/comparison
|
|
/// </summary>
|
|
[NotMapped]
|
|
public int TotalBonusValue =>
|
|
RolledBonusStrength + RolledBonusIntelligence + RolledBonusWisdom +
|
|
RolledBonusEndurance + RolledBonusDexterity + RolledBonusHealth +
|
|
RolledBonusMana + RolledBonusArmor + RolledBonusMagicResist +
|
|
RolledBonusMinDamage + RolledBonusMaxDamage + RolledBonusHealAmount +
|
|
RolledBonusManaRestore;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Maps a DungeonCharacterItem to a DungeonCraftedItem if it was crafted
|
|
/// </summary>
|
|
[Table("dungeon_character_item_crafted_link")]
|
|
public class DungeonCharacterItemCraftedLink
|
|
{
|
|
[Key]
|
|
public ulong Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// The character's inventory item
|
|
/// </summary>
|
|
[Required]
|
|
public ulong CharacterItemId { get; set; }
|
|
|
|
/// <summary>
|
|
/// The crafted item data
|
|
/// </summary>
|
|
[Required]
|
|
public ulong CraftedItemId { get; set; }
|
|
|
|
// Navigation
|
|
public virtual DungeonCharacterItem? CharacterItem { get; set; }
|
|
public virtual DungeonCraftedItem? CraftedItem { get; set; }
|
|
}
|