namespace SVSim.EmulatedEntrypoint.Matching;
///
/// Per-mode pairing policy. TK2 is PvP-only; rotation/unlimited rank battles
/// can fall back to an AI battle after a configurable threshold. Future modes
/// add rows in DI registration.
///
public enum PolicyKind
{
/// Pair PvP; if no partner arrives, keep waiting indefinitely (modulo stale eviction).
PvpOnly,
/// Pair PvP if a partner arrives within the threshold; otherwise fall back to a Bot battle.
PvpFirstThenAiFallback,
}
public sealed record ModePolicy(string Mode, PolicyKind Kind);
///
/// DI singleton. Holds the per-mode policy lookup. Unknown modes default to
/// (safest — never accidentally fall through to AI
/// for a mode whose policy hasn't been wired).
///
public sealed class ModePolicyRegistry
{
private readonly Dictionary _byMode;
public ModePolicyRegistry(IEnumerable policies)
{
// Last-wins on duplicate keys — documented in tests.
_byMode = new Dictionary();
foreach (var p in policies) _byMode[p.Mode] = p;
}
public ModePolicy For(string mode) =>
_byMode.TryGetValue(mode, out var p) ? p : new ModePolicy(mode, PolicyKind.PvpOnly);
}