PartyDamage/CombatData.cs

44 lines
1.1 KiB
C#
Raw Permalink Normal View History

2024-07-24 21:12:55 +00:00
namespace PartyDamage;
public class CombatData {
2024-07-24 22:04:52 +00:00
public Encounter Encounter { get; }
public Dictionary<string, Combatant> Combatants { get; } = [];
2024-07-25 06:07:07 +00:00
public bool IsActive { get; }
2024-07-24 22:04:52 +00:00
public CombatData(RawCombatData raw) {
foreach (var (key, value) in raw.Combatants) {
this.Combatants[key] = new Combatant {
Name = value.Name,
EncDps = TryFloat(value.EncDps),
2024-07-27 23:48:29 +00:00
JobAbbr = value.Job,
2024-07-24 22:04:52 +00:00
};
}
this.Encounter = new Encounter {
Title = raw.Encounter.Title,
EncDps = TryFloat(raw.Encounter.EncDps),
};
2024-07-25 06:07:07 +00:00
this.IsActive = raw.IsActive;
2024-07-24 22:04:52 +00:00
}
private static float TryFloat(string input, float def = float.NaN) {
if (!float.TryParse(input, out var result)) {
result = def;
}
return result;
}
2024-07-24 21:12:55 +00:00
}
public class Encounter {
2024-07-24 22:04:52 +00:00
public string Title { get; init; }
public float EncDps { get; init; }
2024-07-24 21:12:55 +00:00
}
public class Combatant {
2024-07-24 22:04:52 +00:00
public string Name { get; init; }
2024-07-27 23:48:29 +00:00
public string JobAbbr { get; init; }
2024-07-24 22:04:52 +00:00
public float EncDps { get; init; }
2024-07-25 06:07:07 +00:00
}