From 0c33698541e52b6275bfdf8a6dd33ab94448a989 Mon Sep 17 00:00:00 2001 From: Colin Halseth Date: Sun, 23 May 2021 20:24:57 -0700 Subject: [PATCH] Fixed export of characters to be their appropriate type --- .../Shared/CharacterEditorPopoutTab.razor | 11 +++++++++-- TrekSharp/src/Character.cs | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/TrekSharp.AdventureTools/Shared/CharacterEditorPopoutTab.razor b/TrekSharp.AdventureTools/Shared/CharacterEditorPopoutTab.razor index 8d63df2..4f6c880 100644 --- a/TrekSharp.AdventureTools/Shared/CharacterEditorPopoutTab.razor +++ b/TrekSharp.AdventureTools/Shared/CharacterEditorPopoutTab.razor @@ -50,8 +50,15 @@ public async Task Export() { if (HasCharacter) { - var character = this.Character; - await this.DownloadJson($"{character.Name}.character", character); + if (this.Character is PlayerCharacter pc) { + await this.DownloadJson($"{pc.Name}.character", pc); + } else if (this.Character is SupportCharacter sc) { + await this.DownloadJson($"{sc.Name}.character", sc); + } else if (this.Character is NpcCharacter npc) { + await this.DownloadJson($"{npc.Name}.character", npc); + } else { + await this.DownloadJson($"{Character.Name}.character", Character); + } } } diff --git a/TrekSharp/src/Character.cs b/TrekSharp/src/Character.cs index b096eec..cab77cc 100644 --- a/TrekSharp/src/Character.cs +++ b/TrekSharp/src/Character.cs @@ -85,7 +85,7 @@ public int Determination { set => _det = (value < 0 ? 0 : value); } - public override int BonusStress => Talents.Select(talent => talent?.StressModifier ?? 0).Sum(); + public override int BonusStress => Talents == null ? 0 : Talents.Select(talent => talent?.StressModifier ?? 0).Sum(); }