Resistance System
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json;
|
||||
using DataServer.Data.Enums;
|
||||
|
||||
namespace DataServer.Data.Entities;
|
||||
@@ -80,5 +81,27 @@ public class DungeonItemDefinition
|
||||
// Legacy field - kept for backwards compatibility
|
||||
public int SpriteId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// JSON block for resistance bonuses when equipped
|
||||
/// Example: {"fire": 0.15, "ice": 0.10}
|
||||
/// Values are percentage (0.15 = 15% resistance)
|
||||
/// </summary>
|
||||
[MaxLength(1024)]
|
||||
public string ResistancesJson { get; set; } = "{}";
|
||||
|
||||
/// <summary>
|
||||
/// Helper to get/set resistances dictionary
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public Dictionary<string, float> Resistances
|
||||
{
|
||||
get
|
||||
{
|
||||
try { return JsonSerializer.Deserialize<Dictionary<string, float>>(ResistancesJson) ?? new(); }
|
||||
catch { return new(); }
|
||||
}
|
||||
set { ResistancesJson = JsonSerializer.Serialize(value); }
|
||||
}
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user