From 69593851aa1be08408e3f1ffa4ed01daebb7ecad Mon Sep 17 00:00:00 2001 From: Ben Parsons <9parsonsb@gmail.com> Date: Sat, 25 May 2024 23:46:21 +1000 Subject: [PATCH] Nullability Updates & Add missing file --- Botanist/Botanist.cs | 2 +- .../Files/Journal/Startup/Commander.cs | 2 +- .../Files/Journal/Startup/LoadGame.cs | 22 +++++++-------- .../Files/Journal/Startup/Statistics.cs | 2 +- Pulsar/WebApp/src/types/api/LoadGame.ts | 27 +++++++++++++++++++ 5 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 Pulsar/WebApp/src/types/api/LoadGame.ts diff --git a/Botanist/Botanist.cs b/Botanist/Botanist.cs index 72750e3..9955f04 100644 --- a/Botanist/Botanist.cs +++ b/Botanist/Botanist.cs @@ -102,7 +102,7 @@ public class Botanist : IObservatoryWorker switch (journal) { case LoadGame loadGame: - OdysseyLoaded = loadGame.Odyssey; + OdysseyLoaded = loadGame.Odyssey ?? false; break; case SAASignalsFound signalsFound: { diff --git a/ObservatoryFramework/Files/Journal/Startup/Commander.cs b/ObservatoryFramework/Files/Journal/Startup/Commander.cs index f19654b..a3cf1b5 100644 --- a/ObservatoryFramework/Files/Journal/Startup/Commander.cs +++ b/ObservatoryFramework/Files/Journal/Startup/Commander.cs @@ -5,5 +5,5 @@ public class Commander : JournalBase public override string Event => "Commander"; public string Name { get; init; } - public string FID { get; init; } + public string? FID { get; init; } } \ No newline at end of file diff --git a/ObservatoryFramework/Files/Journal/Startup/LoadGame.cs b/ObservatoryFramework/Files/Journal/Startup/LoadGame.cs index d42480d..44a4339 100644 --- a/ObservatoryFramework/Files/Journal/Startup/LoadGame.cs +++ b/ObservatoryFramework/Files/Journal/Startup/LoadGame.cs @@ -6,26 +6,26 @@ public class LoadGame : JournalBase { public override string Event => "LoadGame"; public string Commander { get; init; } - public string FID { get; init; } - public bool Horizons { get; init; } - public bool Odyssey { get; init; } - public string Ship { get; init; } - public string Ship_Localised { get; init; } + public string? FID { get; init; } + public bool? Horizons { get; init; } + public bool? Odyssey { get; init; } + public string? Ship { get; init; } + public string? Ship_Localised { get; init; } public ulong ShipID { get; init; } public bool StartLanded { get; init; } public bool StartDead { get; init; } - public string GameMode { get; init; } + public string? GameMode { get; init; } public string? Group { get; init; } public long Credits { get; init; } public long Loan { get; init; } - public string ShipName { get; init; } - public string ShipIdent { get; init; } + public string? ShipName { get; init; } + public string? ShipIdent { get; init; } public double FuelLevel { get; init; } public double FuelCapacity { get; init; } [JsonPropertyName("language")] - public string Language { get; init; } + public string? Language { get; init; } [JsonPropertyName("gameversion")] - public string GameVersion { get; init; } + public string? GameVersion { get; init; } [JsonPropertyName("build")] - public string Build { get; init; } + public string? Build { get; init; } } \ No newline at end of file diff --git a/ObservatoryFramework/Files/Journal/Startup/Statistics.cs b/ObservatoryFramework/Files/Journal/Startup/Statistics.cs index 9f1a2c4..0c5f75f 100644 --- a/ObservatoryFramework/Files/Journal/Startup/Statistics.cs +++ b/ObservatoryFramework/Files/Journal/Startup/Statistics.cs @@ -27,5 +27,5 @@ public class Statistics : JournalBase public CQC? CQC { get; init; } [JsonPropertyName("FLEETCARRIER")] public ParameterTypes.FleetCarrier? FleetCarrier { get; init; } - public Exobiology Exobiology { get; init; } + public Exobiology? Exobiology { get; init; } } \ No newline at end of file diff --git a/Pulsar/WebApp/src/types/api/LoadGame.ts b/Pulsar/WebApp/src/types/api/LoadGame.ts new file mode 100644 index 0000000..37347f5 --- /dev/null +++ b/Pulsar/WebApp/src/types/api/LoadGame.ts @@ -0,0 +1,27 @@ +import type JournalBase from "./JournalBase"; + +export interface LoadGame extends JournalBase { + event: "LoadGame"; + commander: string; + fid: string; + horizons: boolean; + odyssey: boolean; + ship: string; + ship_Localised: string; + shipID: number; + startLanded: boolean; + startDead: boolean; + gameMode: string; + credits: number; + loan: number; + shipName: string; + shipIdent: string; + fuelLevel: number; + fuelCapacity: number; + language: string; + gameversion: string; + build: string; +} +export function IsLoadGameEvent(message: JournalBase): message is LoadGame { + return message.event === "LoadGame"; +}