Resistance System
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace DataServer.Data.Entities;
|
||||
|
||||
@@ -70,6 +71,28 @@ public class DungeonCharacter
|
||||
// Soft delete
|
||||
public bool IsDeleted { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// JSON block for innate resistances/weaknesses (from skills, buffs, etc.)
|
||||
/// Example: {"fire": 0.1, "poison": -0.2}
|
||||
/// Stacks with gear resistances
|
||||
/// </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); }
|
||||
}
|
||||
|
||||
// Navigation
|
||||
public virtual Account? Account { get; set; }
|
||||
public virtual ICollection<DungeonCharacterItem> Inventory { get; set; } = new List<DungeonCharacterItem>();
|
||||
|
||||
Reference in New Issue
Block a user