Resistance System

This commit is contained in:
dingo
2025-12-26 10:40:09 -05:00
parent 2d847c91dd
commit fd056692df
16 changed files with 2862 additions and 8 deletions
+23
View File
@@ -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>();