aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/src/Godosa.Core/Runs/DigestLine.cs
blob: bc4519b58b87d07a0370a9a006f6eee77fecd6b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
using System.Globalization;

namespace Godosa.Core.Runs;

/// <summary>The shared digest stdout line: <c>digest &lt;frame&gt; &lt;game seconds 0.###&gt; &lt;16 hex&gt;</c>.</summary>
public static class DigestLine
{
    public static string Format(long frame, double gameSeconds, ulong hash) =>
        string.Create(CultureInfo.InvariantCulture, $"digest {frame} {gameSeconds:0.###} {hash:x16}");

    /// <summary>Every <paramref name="every"/> frames (frame 0 and every ≤ 0 never).</summary>
    public static bool Due(long frame, int every) => every > 0 && frame > 0 && frame % every == 0;
}