Skip to content

Commit

Permalink
PCI、ラップタイムをスクリプトから取得可能に
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Dec 15, 2022
1 parent c92909e commit 7e22972
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions KmyKeiba/Models/Script/ScriptRace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ public class ScriptRace
[JsonPropertyName("cornerRanking4")]
public string CornerRanking4 => this._race.Corner4Result;

[JsonPropertyName("lapTimes")]
public string LapTimes => JsonSerializer.Serialize(this._race.LapTimes, ScriptManager.JsonOptions);

[JsonPropertyName("topHorses")]
public ScriptRaceHorse[]? TopHorses =>
this._topHorses != null ? this._topHorses.Select(h => new ScriptRaceHorse(string.Empty, h, false)).ToArray() :
Expand Down
25 changes: 24 additions & 1 deletion KmyKeiba/Models/Script/ScriptRaceHorse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using KmyKeiba.Data.Db;
using CefSharp.DevTools.Network;
using KmyKeiba.Data.Db;
using KmyKeiba.Models.Analysis;
using KmyKeiba.Models.Data;
using Microsoft.ClearScript;
Expand Down Expand Up @@ -114,13 +115,19 @@ public class ScriptRaceHorse
[JsonPropertyName("ua3hTimeDeviationValue")]
public double UntilA3HTimeDeviationValue => this.IsTargetRace ? default : this._analyzer?.UntilA3HResultTimeDeviationValue ?? default;

[JsonPropertyName("pci")]
public double Pci => this._analyzer?.Pci ?? default;

[JsonPropertyName("race")]
public ScriptRace? Race => this.IsTargetRace ? null : this._isRaceGettable ?
new ScriptRace(this._analyzer!.Race, this._analyzer.CurrentRace?.TopHorses.ToArray()) : null;

[JsonPropertyName("history")]
public ScriptHistory? History => this._analyzer?.History != null ? new ScriptHistory(this._targetRaceKey, this._analyzer.History) : ScriptHistory.Default;

[JsonPropertyName("extraData")]
public ScriptExtraData? ExtraData => this._analyzer?.ExtraData != null ? new ScriptExtraData(this._analyzer.ExtraData) : null;

public ScriptRaceHorse(string targetRaceKey, RaceHorseAnalyzer horse, bool isRaceGettable = true)
{
this._targetRaceKey = targetRaceKey;
Expand Down Expand Up @@ -309,5 +316,21 @@ public ScriptHistory(string targetRaceKey, RaceHorseAnalyzer.HistoryData history

public static ScriptHistory Default { get; } = new ScriptHistory(string.Empty, new RaceHorseAnalyzer.HistoryData(new RaceData(), new RaceHorseData(), Enumerable.Empty<RaceHorseAnalyzer>(), null));
}

public class ScriptExtraData
{
private readonly RaceHorseExtraData _data;

[JsonPropertyName("rpci")]
public double Rpci => this._data.Rpci;

[JsonPropertyName("pci3")]
public double Pci3 => this._data.Pci3;

public ScriptExtraData(RaceHorseExtraData extra)
{
this._data = extra;
}
}
}
}

0 comments on commit 7e22972

Please sign in to comment.