61 lines
2.1 KiB
C#
61 lines
2.1 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using DataServer.Data.Enums;
|
|
|
|
namespace DataServer.Data.Entities;
|
|
/// <summary>
|
|
/// Actual item instance owned by a character (inventory or equipped)
|
|
/// </summary>
|
|
[Table("dungeon_character_items")]
|
|
public class DungeonCharacterItem
|
|
{
|
|
[Key]
|
|
public ulong Id { get; set; }
|
|
|
|
public ulong CharacterId { get; set; }
|
|
public int ItemDefinitionId { get; set; }
|
|
|
|
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; }
|
|
|
|
public DateTime AcquiredAt { get; set; } = DateTime.UtcNow;
|
|
|
|
// Navigation
|
|
public virtual DungeonCharacter? Character { get; set; }
|
|
|
|
[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);
|
|
}
|
|
}
|