revert(battle-node): remove real-spin logic (CountHiddenDraws + per-frame spin)

Two-sided capture (data_dumps/captures/battle_test/rng, 2026-06-04) showed the
receiver already reproduces uList-relayed deck fetches (Hoverboard) and turn
draws on its own shared stream, so the emitted spin=1 double-cranked and desynced
the clients by 1. Residual spin is ~0 for the current card pool. Reverts 63cb324
and 617714e; back to the prior correct spin:0 behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-04 16:07:08 -04:00
parent 617714ebea
commit 75f3d8ea5b
5 changed files with 4 additions and 217 deletions

View File

@@ -285,97 +285,6 @@ public class BattleSessionDispatchTests
Assert.That(pb.UList[0].Skill, Is.EqualTo("37|36|0"));
}
[Test]
public void Pvp_PlayActions_emits_spin_for_a_hidden_fetch()
{
var (s, a, b) = NewPvpSession();
DriveToAfterReady(s, a);
DriveToAfterReady(s, b);
// Played card 3 (hand->field) PLUS a hidden deck->hand fetch of a non-played token idx 31.
var body = new Dictionary<string, object?>
{
["playIdx"] = 3L,
["type"] = 30L,
["orderList"] = new List<object?>
{
new Dictionary<string, object?>
{
["move"] = new Dictionary<string, object?>
{
["idx"] = new List<object?> { 3L }, ["isSelf"] = 1L, ["from"] = 10L, ["to"] = 20L,
}
},
new Dictionary<string, object?>
{
["move"] = new Dictionary<string, object?>
{
["idx"] = new List<object?> { 31L }, ["isSelf"] = 1L, ["from"] = 0L, ["to"] = 10L,
}
},
},
};
var routes = s.ComputeFrames(a, EnvWith(NetworkBattleUri.PlayActions, body));
var pb = (PlayActionsBroadcastBody)routes[0].Frame.Body;
Assert.That(pb.Spin, Is.EqualTo(1));
}
[Test]
public void Pvp_PlayActions_emits_null_spin_for_a_vanilla_play()
{
var (s, a, b) = NewPvpSession();
DriveToAfterReady(s, a);
DriveToAfterReady(s, b);
var body = MoveOrderList(idx: 3, from: 10, to: 20); // played card only, no fetch
body["playIdx"] = 3L;
body["type"] = 30L;
var routes = s.ComputeFrames(a, EnvWith(NetworkBattleUri.PlayActions, body));
var pb = (PlayActionsBroadcastBody)routes[0].Frame.Body;
Assert.That(pb.Spin, Is.Null, "spin omitted (client assumes 0) when there are no hidden draws.");
}
[Test]
public void Pvp_PlayActions_emits_null_spin_for_a_revealed_uList_fetch()
{
// A fetch whose identity is revealed via the uList (cardId present) is NOT counted — the
// receiver knows it, so its stream doesn't need a crank.
var (s, a, b) = NewPvpSession();
DriveToAfterReady(s, a);
DriveToAfterReady(s, b);
var body = new Dictionary<string, object?>
{
["playIdx"] = 3L,
["type"] = 30L,
["orderList"] = new List<object?>
{
new Dictionary<string, object?>
{
["move"] = new Dictionary<string, object?>
{
["idx"] = new List<object?> { 31L }, ["isSelf"] = 1L, ["from"] = 0L, ["to"] = 10L,
}
},
},
["uList"] = new List<object?>
{
new Dictionary<string, object?>
{
["idxList"] = new List<object?> { 31L },
["from"] = 0L, ["to"] = 10L, ["isSelf"] = 1L, ["skill"] = "37|36|0",
["cardId"] = 100_011_010L, // revealed identity
},
},
};
var routes = s.ComputeFrames(a, EnvWith(NetworkBattleUri.PlayActions, body));
var pb = (PlayActionsBroadcastBody)routes[0].Frame.Body;
Assert.That(pb.Spin, Is.Null);
}
[Test]
public void Pvp_PlayActions_without_uList_leaves_it_null()
{

View File

@@ -20,78 +20,6 @@ public class KnownListBuilderTests
}
};
// A move op dict allowing extra keys (e.g. "rand") for CountHiddenDraws fixtures.
private static Dictionary<string, object?> MoveOp(long[] idxs, int from, int to,
IDictionary<string, object?>? extra = null)
{
var move = new Dictionary<string, object?>
{
["idx"] = idxs.Select(i => (object?)i).ToList(),
["isSelf"] = 1L, ["from"] = (long)from, ["to"] = (long)to,
};
if (extra is not null) foreach (var kv in extra) move[kv.Key] = kv.Value;
return new Dictionary<string, object?> { ["move"] = move };
}
private static readonly IReadOnlySet<int> NoneRevealed = new HashSet<int>();
[Test]
public void CountHiddenDraws_counts_a_hidden_deck_to_hand_fetch()
{
// Hoverboard-shaped: move(0->10) for a non-played, unrevealed token idx.
var orderList = new List<object?> { MoveOp(new[] { 31L }, from: 0, to: 10) };
Assert.That(KnownListBuilder.CountHiddenDraws(orderList, playIdx: 3, NoneRevealed), Is.EqualTo(1));
}
[Test]
public void CountHiddenDraws_ignores_the_played_cards_own_move()
{
// The played card moving hand(10)->field(20) is not a draw.
var orderList = new List<object?> { MoveOp(new[] { 3L }, from: 10, to: 20) };
Assert.That(KnownListBuilder.CountHiddenDraws(orderList, playIdx: 3, NoneRevealed), Is.EqualTo(0));
}
[Test]
public void CountHiddenDraws_ignores_a_visible_destroy()
{
// A visible field(20)->cemetery(30) destroy is reproduced by the receiver → 0.
var orderList = new List<object?> { MoveOp(new[] { 8L }, from: 20, to: 30) };
Assert.That(KnownListBuilder.CountHiddenDraws(orderList, playIdx: 3, NoneRevealed), Is.EqualTo(0));
}
[Test]
public void CountHiddenDraws_ignores_a_revealed_fetch()
{
// The fetched idx's identity was revealed to the opponent (in `revealed`) → 0.
var orderList = new List<object?> { MoveOp(new[] { 31L }, from: 0, to: 10) };
var revealed = new HashSet<int> { 31 };
Assert.That(KnownListBuilder.CountHiddenDraws(orderList, playIdx: 3, revealed), Is.EqualTo(0));
}
[Test]
public void CountHiddenDraws_ignores_a_lot_based_random()
{
// A move op carrying a `rand` array is reproduced (re-rolled) by the receiver → 0.
var rand = new Dictionary<string, object?> { ["rand"] = new List<object?> { 0.5d } };
var orderList = new List<object?> { MoveOp(new[] { 31L }, from: 0, to: 10, extra: rand) };
Assert.That(KnownListBuilder.CountHiddenDraws(orderList, playIdx: 3, NoneRevealed), Is.EqualTo(0));
}
[Test]
public void CountHiddenDraws_counts_each_hidden_card_in_a_multi_fetch()
{
var orderList = new List<object?> { MoveOp(new[] { 31L, 32L }, from: 0, to: 10) };
Assert.That(KnownListBuilder.CountHiddenDraws(orderList, playIdx: 3, NoneRevealed), Is.EqualTo(2));
}
[Test]
public void CountHiddenDraws_returns_zero_for_a_vanilla_play()
{
var orderList = new List<object?> { MoveOp(new[] { 3L }, from: 10, to: 20) };
Assert.That(KnownListBuilder.CountHiddenDraws(orderList, playIdx: 3, NoneRevealed), Is.EqualTo(0));
Assert.That(KnownListBuilder.CountHiddenDraws(null, playIdx: 3, NoneRevealed), Is.EqualTo(0));
}
[Test]
public void ExtractMoveTo_returns_to_for_matching_idx()
{