From 520f7373e625e412ad443f28ecf28e87bfb7887a Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Mon, 19 Feb 2024 11:27:21 +0100 Subject: [PATCH] Include Predicted Level after next Voyage in submarine stats --- Influx/Influx.csproj | 2 +- Influx/Influx/InfluxStatisticsClient.cs | 1 + Influx/SubmarineTracker/Submarine.cs | 15 ++++++++++++++- Influx/SubmarineTracker/SubmarineStats.cs | 1 + Influx/SubmarineTracker/SubmarineTrackerIpc.cs | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Influx/Influx.csproj b/Influx/Influx.csproj index 927e2c0..ed871df 100644 --- a/Influx/Influx.csproj +++ b/Influx/Influx.csproj @@ -1,7 +1,7 @@ net7.0-windows - 0.3 + 0.4 11.0 enable true diff --git a/Influx/Influx/InfluxStatisticsClient.cs b/Influx/Influx/InfluxStatisticsClient.cs index a4f2b36..51c34ac 100644 --- a/Influx/Influx/InfluxStatisticsClient.cs +++ b/Influx/Influx/InfluxStatisticsClient.cs @@ -217,6 +217,7 @@ internal sealed class InfluxStatisticsClient : IDisposable .Tag("part_bridge", sub.Bridge) .Tag("build", sub.Build) .Field("level", sub.Level) + .Field("predicted_level", sub.PredictedLevel) .Timestamp(date, WritePrecision.S)); } } diff --git a/Influx/SubmarineTracker/Submarine.cs b/Influx/SubmarineTracker/Submarine.cs index fcc5304..fcf7aeb 100644 --- a/Influx/SubmarineTracker/Submarine.cs +++ b/Influx/SubmarineTracker/Submarine.cs @@ -1,4 +1,6 @@ -namespace Influx.SubmarineTracker; +using System; + +namespace Influx.SubmarineTracker; public sealed class Submarine { @@ -7,9 +9,20 @@ public sealed class Submarine Name = (string)@delegate.GetType().GetProperty("Name")!.GetValue(@delegate)!; Level = (ushort)@delegate.GetType().GetProperty("Rank")!.GetValue(@delegate)!; Build = new Build(@delegate.GetType().GetProperty("Build")!.GetValue(@delegate)!); + + try + { + (uint predictedLevel, double _) = ((uint, double))@delegate.GetType().GetMethod("PredictExpGrowth")!.Invoke(@delegate, Array.Empty())!; + PredictedLevel = (ushort)predictedLevel; + } + catch (Exception) + { + PredictedLevel = Level; + } } public string Name { get; } public ushort Level { get; } + public ushort PredictedLevel { get; } public Build Build { get; } } diff --git a/Influx/SubmarineTracker/SubmarineStats.cs b/Influx/SubmarineTracker/SubmarineStats.cs index 04e28c0..145c351 100644 --- a/Influx/SubmarineTracker/SubmarineStats.cs +++ b/Influx/SubmarineTracker/SubmarineStats.cs @@ -5,6 +5,7 @@ public sealed class SubmarineStats public required string Name { get; init; } public required int Id { get; init; } public required ushort Level { get; init; } + public required ushort PredictedLevel { get; init; } public required string Hull { get; init; } public required string Stern { get; init; } diff --git a/Influx/SubmarineTracker/SubmarineTrackerIpc.cs b/Influx/SubmarineTracker/SubmarineTrackerIpc.cs index 1de62c3..dc66c55 100644 --- a/Influx/SubmarineTracker/SubmarineTrackerIpc.cs +++ b/Influx/SubmarineTracker/SubmarineTrackerIpc.cs @@ -46,6 +46,7 @@ internal sealed class SubmarineTrackerIpc Id = x.Subs.IndexOf(y), Name = y.Name, Level = y.Level, + PredictedLevel = y.PredictedLevel, Hull = y.Build.HullIdentifier, Stern = y.Build.SternIdentifier, Bow = y.Build.BowIdentifier,