Bundles in-flight work on the campaign/missions system (CampaignDef, MissionDef, TerrainPatch, TransformerDef, MissionChecker, CampaignLoader, FlavorBanner, transformer rules), plan files, and matching tests. Baseline commit so the upcoming automation testing harness lands on a clean tree.
108 lines
3.9 KiB
C#
108 lines
3.9 KiB
C#
using Chessistics.Engine.Events;
|
|
using Chessistics.Engine.Model;
|
|
using Chessistics.Tests.Helpers;
|
|
using Xunit;
|
|
|
|
namespace Chessistics.Tests.Simulation;
|
|
|
|
public class FullLevelTests
|
|
{
|
|
[Fact]
|
|
public void Level1_PremierConvoi_MissionComplete()
|
|
{
|
|
var level = new BoardBuilder(4, 4)
|
|
.WithProduction(0, 0, "Scierie", CargoType.Wood)
|
|
.WithDemand(3, 0, "Depot Royal", CargoType.Wood, 3, 30)
|
|
.WithStock(PieceKind.Rook, 3)
|
|
.Build();
|
|
var sim = SimHelper.FromLevel(level);
|
|
|
|
sim.Place(PieceKind.Rook, (1, 0), (2, 0));
|
|
|
|
var allEvents = sim.StepN(30);
|
|
Assert.Contains(allEvents, e => e is MissionCompleteEvent);
|
|
}
|
|
|
|
[Fact]
|
|
public void Level2_DeuxClients_MissionComplete()
|
|
{
|
|
var level = new BoardBuilder(6, 6)
|
|
.WithProduction(0, 0, "Scierie", CargoType.Wood)
|
|
.WithDemand(5, 0, "Depot Royal", CargoType.Wood, 2, 50)
|
|
.WithDemand(5, 4, "Caserne", CargoType.Wood, 2, 50)
|
|
.WithStock(PieceKind.Rook, 6)
|
|
.WithStock(PieceKind.Bishop, 1)
|
|
.Build();
|
|
var sim = SimHelper.FromLevel(level);
|
|
|
|
// Route 1: bottom row → demand (5,0)
|
|
sim.Place(PieceKind.Rook, (1, 0), (2, 0));
|
|
sim.Place(PieceKind.Rook, (2, 0), (4, 0));
|
|
|
|
// Route 2: up then right → demand (5,4)
|
|
sim.Place(PieceKind.Rook, (0, 1), (0, 2));
|
|
sim.Place(PieceKind.Rook, (0, 2), (2, 2));
|
|
var events5 = sim.Place(PieceKind.Rook, (2, 2), (3, 2));
|
|
Assert.DoesNotContain(events5, e => e is PlacementRejectedEvent);
|
|
|
|
sim.Place(PieceKind.Bishop, (3, 2), (4, 3));
|
|
|
|
var events6 = sim.Place(PieceKind.Rook, (4, 3), (5, 3));
|
|
Assert.DoesNotContain(events6, e => e is PlacementRejectedEvent);
|
|
|
|
var allEvents = sim.StepN(60);
|
|
Assert.Contains(allEvents, e => e is MissionCompleteEvent);
|
|
}
|
|
|
|
[Fact]
|
|
public void Level3_LeCol_MissionComplete()
|
|
{
|
|
var level = new BoardBuilder(6, 6)
|
|
.WithProduction(0, 0, "Scierie", CargoType.Wood)
|
|
.WithProduction(5, 0, "Carriere", CargoType.Stone)
|
|
.WithDemand(5, 5, "Depot Royal", CargoType.Wood, 2, 60)
|
|
.WithDemand(0, 5, "Forge", CargoType.Stone, 2, 60)
|
|
.WithWall(2, 2).WithWall(2, 3).WithWall(2, 4).WithWall(3, 4).WithWall(4, 4)
|
|
.WithStock(PieceKind.Rook, 10)
|
|
.WithStock(PieceKind.Knight, 2)
|
|
.Build();
|
|
var sim = SimHelper.FromLevel(level);
|
|
|
|
// Route Wood: prod(0,0) → demand(5,5)
|
|
sim.Place(PieceKind.Rook, (0, 1), (1, 1));
|
|
sim.Place(PieceKind.Knight, (1, 1), (3, 2));
|
|
sim.Place(PieceKind.Rook, (3, 2), (4, 2));
|
|
sim.Place(PieceKind.Rook, (4, 2), (5, 2));
|
|
sim.Place(PieceKind.Rook, (5, 2), (5, 3));
|
|
sim.Place(PieceKind.Rook, (5, 3), (5, 4));
|
|
|
|
// Route Stone: prod(5,0) → demand(0,5)
|
|
sim.Place(PieceKind.Rook, (4, 0), (3, 0));
|
|
sim.Place(PieceKind.Rook, (3, 0), (2, 0));
|
|
sim.Place(PieceKind.Knight, (2, 0), (1, 2));
|
|
sim.Place(PieceKind.Rook, (1, 2), (1, 3));
|
|
sim.Place(PieceKind.Rook, (1, 3), (1, 4));
|
|
sim.Place(PieceKind.Rook, (1, 4), (0, 4));
|
|
|
|
var allEvents = sim.StepN(80);
|
|
Assert.Contains(allEvents, e => e is MissionCompleteEvent);
|
|
}
|
|
|
|
[Fact]
|
|
public void Level1_InsufficientPieces_NoMissionComplete()
|
|
{
|
|
var level = new BoardBuilder(4, 4)
|
|
.WithProduction(0, 0, "Scierie", CargoType.Wood)
|
|
.WithDemand(3, 3, "Depot Royal", CargoType.Wood, 3, 5)
|
|
.WithStock(PieceKind.Rook, 1)
|
|
.Build();
|
|
var sim = SimHelper.FromLevel(level);
|
|
|
|
sim.Place(PieceKind.Rook, (1, 1), (2, 1));
|
|
|
|
var allEvents = sim.StepN(8);
|
|
|
|
// No deadline concept anymore — just no mission complete
|
|
Assert.DoesNotContain(allEvents, e => e is MissionCompleteEvent);
|
|
}
|
|
}
|