feat(battle-node): TurnStartHandler emits {spin:0} to opponent in PvP
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using SVSim.BattleNode.Protocol;
|
using SVSim.BattleNode.Protocol;
|
||||||
|
using SVSim.BattleNode.Protocol.Bodies;
|
||||||
|
|
||||||
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
|
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
|
||||||
|
|
||||||
@@ -6,10 +7,18 @@ internal sealed class TurnStartHandler : IFrameHandler
|
|||||||
{
|
{
|
||||||
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
|
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
|
||||||
{
|
{
|
||||||
// Forward the opponent's turn-open to the other side. Union of the two legacy arms:
|
// PvP: the active player's TurnStart{orderList} is dropped; the opponent receives {spin}
|
||||||
// BothAfterReady (PvP / scripted real player) OR a scripted-bot emission (test stub path).
|
// (spin=0 for the deterministic-turn slice) and self-generates its turn-open.
|
||||||
if (ctx.BothAfterReady() || ctx.IsScriptedBot(ctx.From))
|
if (ctx.Type == BattleType.Pvp && ctx.BothAfterReady())
|
||||||
|
{
|
||||||
|
var frame = ctx.Env with { Body = new OpponentTurnStartBody(Spin: 0) };
|
||||||
|
return new[] { new DispatchRoute(ctx.Other, frame, false) };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scripted-bot emission (test stub path): the bot already emits the {spin} shape — forward.
|
||||||
|
if (ctx.IsScriptedBot(ctx.From))
|
||||||
return new[] { new DispatchRoute(ctx.Other, ctx.Env, false) };
|
return new[] { new DispatchRoute(ctx.Other, ctx.Env, false) };
|
||||||
|
|
||||||
return Array.Empty<DispatchRoute>();
|
return Array.Empty<DispatchRoute>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ public class BattleSessionDispatchTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Pvp_TurnStart_from_A_in_BothAfterReady_forwards_to_B()
|
public void Pvp_TurnStart_from_A_emits_spin0_to_B()
|
||||||
{
|
{
|
||||||
var (s, a, b) = NewPvpSession();
|
var (s, a, b) = NewPvpSession();
|
||||||
DriveToAfterReady(s, a);
|
DriveToAfterReady(s, a);
|
||||||
@@ -395,6 +395,8 @@ public class BattleSessionDispatchTests
|
|||||||
Assert.That(routes.Count, Is.EqualTo(1));
|
Assert.That(routes.Count, Is.EqualTo(1));
|
||||||
Assert.That(routes[0].Target, Is.SameAs(b));
|
Assert.That(routes[0].Target, Is.SameAs(b));
|
||||||
Assert.That(routes[0].Frame.Uri, Is.EqualTo(NetworkBattleUri.TurnStart));
|
Assert.That(routes[0].Frame.Uri, Is.EqualTo(NetworkBattleUri.TurnStart));
|
||||||
|
var body = (SVSim.BattleNode.Protocol.Bodies.OpponentTurnStartBody)routes[0].Frame.Body;
|
||||||
|
Assert.That(body.Spin, Is.EqualTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
Reference in New Issue
Block a user