Chessistics/chessistics-tests/Loading/Campaign01Tests.cs
Samuel Bouchet e3eb10570b Extend campaign_01 to 9 missions with a finale cathedral
Renames mission 7 from "Le Couronnement" to "Le Comptoir" (it only sets
up the tools→gold chain — the coronation is now the final mission) and
adds:

  - Mission 8 "L'Expansion Finale" (12×10): a Forge Est (wood→tools) and
    an Armurerie Est (stone→arms) on new rightmost columns, plus walls
    that force pieces to route around them. An Entrepôt Est demand on
    (11,9) gives the mission its own goal without depending on the old
    demands.
  - Mission 9 "Le Couronnement" (12×12): the Cathédrale occupies row 11
    as three adjacent demands — outils, armes, and or — so the player
    must keep all three transformation chains running simultaneously to
    complete the campaign.

Existing file tests updated for the new count and rename; new
Campaign01Tests asserts structure and non-regressive terrain across all
nine missions.
2026-04-17 22:34:11 +02:00

81 lines
2.7 KiB
C#

using System.IO;
using Chessistics.Engine.Loading;
using Chessistics.Engine.Model;
using Xunit;
namespace Chessistics.Tests.Loading;
public class Campaign01Tests
{
private static CampaignDef LoadRealCampaign()
{
var repoRoot = Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..");
var path = Path.GetFullPath(Path.Combine(repoRoot, "Data", "campaigns", "campaign_01.json"));
return CampaignLoader.Load(File.ReadAllText(path));
}
[Fact]
public void Campaign_HasExpectedStructure()
{
var c = LoadRealCampaign();
Assert.Equal(9, c.Missions.Count);
Assert.Equal(4, c.InitialWidth);
Assert.Equal(4, c.InitialHeight);
}
[Fact]
public void Mission8_AddsTwoTransformersAndExpandsTo12x10()
{
var c = LoadRealCampaign();
var m8 = c.Missions[7];
Assert.Equal("L'Expansion Finale", m8.Name);
Assert.Equal(12, m8.TerrainPatch.NewWidth);
Assert.Equal(10, m8.TerrainPatch.NewHeight);
var transformers = m8.TerrainPatch.Cells.Where(p => p.Type == CellType.Transformer).ToList();
Assert.Equal(2, transformers.Count);
Assert.Contains(transformers, t => t.Transformer!.Name == "Forge Est");
Assert.Contains(transformers, t => t.Transformer!.Name == "Armurerie Est");
}
[Fact]
public void Mission9_CathedralDemandsAllThreeCargoTypes()
{
var c = LoadRealCampaign();
var m9 = c.Missions[8];
Assert.Equal("Le Couronnement", m9.Name);
Assert.Equal(12, m9.TerrainPatch.NewWidth);
Assert.Equal(12, m9.TerrainPatch.NewHeight);
var demands = m9.TerrainPatch.Cells.Where(p => p.Type == CellType.Demand).ToList();
Assert.Equal(3, demands.Count);
var types = demands.Select(d => d.Demand!.Cargo).ToHashSet();
Assert.Contains(CargoType.Tools, types);
Assert.Contains(CargoType.Arms, types);
Assert.Contains(CargoType.Gold, types);
}
[Fact]
public void Mission7_RenamedToComptoir()
{
var c = LoadRealCampaign();
var m7 = c.Missions[6];
Assert.Equal("Le Comptoir", m7.Name);
}
[Fact]
public void AllTerrainPatchesAreNonRegressive()
{
// Subsequent missions must only grow the board, never shrink it.
var c = LoadRealCampaign();
int w = c.InitialWidth, h = c.InitialHeight;
for (int i = 0; i < c.Missions.Count; i++)
{
var tp = c.Missions[i].TerrainPatch;
Assert.True(tp.NewWidth >= w, $"Mission {i}: width shrunk from {w} to {tp.NewWidth}");
Assert.True(tp.NewHeight >= h, $"Mission {i}: height shrunk from {h} to {tp.NewHeight}");
w = tp.NewWidth;
h = tp.NewHeight;
}
}
}