Black box sim engine (commands in, events out) with 3 piece types (Rook, Bishop, Knight), cargo transfer system with social status priority, collision detection, and victory/defeat conditions. 57 tests covering rules, simulation, loading, and solvability. Godot 4 presentation layer scaffolding.
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using Chessistics.Engine.Model;
|
|
using Chessistics.Engine.Rules;
|
|
using Xunit;
|
|
|
|
namespace Chessistics.Tests.Rules;
|
|
|
|
public class CollisionDetectorTests
|
|
{
|
|
[Fact]
|
|
public void NoCollision_PiecesOnDifferentCells()
|
|
{
|
|
var pieces = new List<PieceState>
|
|
{
|
|
new(1, PieceKind.Rook, new Coords(0, 0), new Coords(1, 0), 0) { CurrentCell = new Coords(0, 0) },
|
|
new(2, PieceKind.Rook, new Coords(2, 0), new Coords(3, 0), 1) { CurrentCell = new Coords(2, 0) }
|
|
};
|
|
|
|
var collisions = CollisionDetector.DetectCollisions(pieces);
|
|
Assert.Empty(collisions);
|
|
}
|
|
|
|
[Fact]
|
|
public void Collision_TwoPiecesSameCell()
|
|
{
|
|
var cell = new Coords(1, 0);
|
|
var pieces = new List<PieceState>
|
|
{
|
|
new(1, PieceKind.Rook, new Coords(0, 0), cell, 0) { CurrentCell = cell },
|
|
new(2, PieceKind.Rook, new Coords(2, 0), cell, 1) { CurrentCell = cell }
|
|
};
|
|
|
|
var collisions = CollisionDetector.DetectCollisions(pieces);
|
|
Assert.Single(collisions);
|
|
Assert.Equal((1, 2, cell), collisions[0]);
|
|
}
|
|
|
|
[Fact]
|
|
public void Collision_ThreePiecesSameCell()
|
|
{
|
|
var cell = new Coords(1, 0);
|
|
var pieces = new List<PieceState>
|
|
{
|
|
new(1, PieceKind.Rook, new Coords(0, 0), cell, 0) { CurrentCell = cell },
|
|
new(2, PieceKind.Rook, new Coords(2, 0), cell, 1) { CurrentCell = cell },
|
|
new(3, PieceKind.Rook, new Coords(3, 0), cell, 2) { CurrentCell = cell }
|
|
};
|
|
|
|
var collisions = CollisionDetector.DetectCollisions(pieces);
|
|
// 3 pairs: (1,2), (1,3), (2,3)
|
|
Assert.Equal(3, collisions.Count);
|
|
}
|
|
}
|