refactor(battle-node): unify IMatchingBridge.RegisterBattle signature

Single RegisterBattle(p1, p2?, type) with contract validation throws on
invalid combinations (Pvp requires both; Bot requires p2==null; Scripted
accepts either). PendingBattle carries Type + P1 + nullable P2. Handler
+ controller adapt; v1.2 behaviour preserved because Scripted is the
only type used today (Phase 2 adds Pvp, Phase 3 adds Bot).
This commit is contained in:
gamer147
2026-06-01 20:00:52 -04:00
parent acd0997cfb
commit d665f88067
8 changed files with 111 additions and 37 deletions

View File

@@ -1,12 +1,25 @@
using SVSim.BattleNode.Sessions;
namespace SVSim.BattleNode.Bridge;
public interface IMatchingBridge
{
/// <summary>
/// Mint a battle id, register a pending session for the given viewer with their per-battle
/// MatchContext snapshot, and return the URL the client should open a socket to.
/// Mint a battle id, register a pending session, return the URL the client should
/// open a socket to.
/// </summary>
PendingMatch RegisterPendingBattle(long viewerId, MatchContext context);
/// <remarks>
/// Contract rules (enforced; throws <see cref="ArgumentException"/>):
/// <list type="bullet">
/// <item><c>Pvp</c>: <paramref name="p2"/> required. Both viewers expected to
/// connect WS within 60s.</item>
/// <item><c>Bot</c>: <paramref name="p2"/> must be null. One viewer expected;
/// opponent runs in client.</item>
/// <item><c>Scripted</c>: <paramref name="p2"/> currently null; future
/// server-driven bot config rides on <paramref name="p2"/>.</item>
/// </list>
/// </remarks>
PendingMatch RegisterBattle(BattlePlayer p1, BattlePlayer? p2, BattleType type);
}
public sealed record PendingMatch(string BattleId, string NodeServerUrl);