22 lines
893 B
C#
22 lines
893 B
C#
namespace HSchool.Simulation;
|
||
|
||
/// <summary>
|
||
/// The speed buttons the player can pick, as an index on the wire. The table is duplicated in
|
||
/// <c>src/HSchool.Client/src/net/protocol.ts</c> — indexes, not multipliers, travel over the socket.
|
||
/// </summary>
|
||
public static class ClockSpeed
|
||
{
|
||
/// <summary>×½, ×1, ×2, ×3, ×4.</summary>
|
||
public static ReadOnlySpan<double> Multipliers => [0.5d, 1d, 2d, 3d, 4d];
|
||
|
||
/// <summary>Index of ×1, the speed a school starts at.</summary>
|
||
public const int DefaultIndex = 1;
|
||
|
||
public static int Count => Multipliers.Length;
|
||
|
||
public static bool IsValid(int index) => index >= 0 && index < Multipliers.Length;
|
||
|
||
/// <summary>Multiplier for a validated index; out-of-range values fall back to ×1.</summary>
|
||
public static double MultiplierAt(int index) => IsValid(index) ? Multipliers[index] : Multipliers[DefaultIndex];
|
||
}
|