40 lines
1.6 KiB
C#
40 lines
1.6 KiB
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, ×5, ×10.</summary>
|
||
public static ReadOnlySpan<double> Multipliers => [0.5d, 1d, 2d, 5d, 10d];
|
||
|
||
/// <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];
|
||
|
||
/// <summary>
|
||
/// Calendar impulses between heavy-system ticks. ×5 and ×10 stride so walking and needs keep
|
||
/// one game minute per heavy step instead of twenty tiny ones per second.
|
||
/// </summary>
|
||
public static int HeavySystemsStride(int speedIndex) => speedIndex switch
|
||
{
|
||
3 => 4,
|
||
4 => 2,
|
||
_ => 1,
|
||
};
|
||
|
||
/// <summary>
|
||
/// Game minutes passed into presence, needs and learning on a heavy tick. High speeds use a
|
||
/// fixed one-minute quantum; lower speeds pass the impulse's own advance.
|
||
/// </summary>
|
||
public static double HeavyGameMinutes(int speedIndex, double impulseMinutes) =>
|
||
speedIndex is 3 or 4 ? 1d : impulseMinutes;
|
||
}
|