2026-04-10 14:58:03 +02:00
|
|
|
using Chessistics.Engine.Model;
|
|
|
|
|
|
|
|
|
|
namespace Chessistics.Tests.Helpers;
|
|
|
|
|
|
|
|
|
|
public class BoardBuilder
|
|
|
|
|
{
|
|
|
|
|
private readonly int _width;
|
|
|
|
|
private readonly int _height;
|
|
|
|
|
private readonly List<ProductionDef> _productions = [];
|
|
|
|
|
private readonly List<DemandDef> _demands = [];
|
|
|
|
|
private readonly List<Coords> _walls = [];
|
|
|
|
|
private readonly List<PieceStock> _stock = [];
|
|
|
|
|
|
|
|
|
|
public BoardBuilder(int width, int height)
|
|
|
|
|
{
|
|
|
|
|
_width = width;
|
|
|
|
|
_height = height;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 21:44:12 +02:00
|
|
|
public BoardBuilder WithProduction(int col, int row, string name, CargoType cargo, int amount = 1)
|
2026-04-10 14:58:03 +02:00
|
|
|
{
|
2026-04-10 21:44:12 +02:00
|
|
|
_productions.Add(new ProductionDef(new Coords(col, row), name, cargo, amount));
|
2026-04-10 14:58:03 +02:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BoardBuilder WithDemand(int col, int row, string name, CargoType cargo, int amount, int deadline)
|
|
|
|
|
{
|
|
|
|
|
_demands.Add(new DemandDef(new Coords(col, row), name, cargo, amount, deadline));
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BoardBuilder WithWall(int col, int row)
|
|
|
|
|
{
|
|
|
|
|
_walls.Add(new Coords(col, row));
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BoardBuilder WithStock(PieceKind kind, int count)
|
|
|
|
|
{
|
|
|
|
|
_stock.Add(new PieceStock(kind, count));
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LevelDef Build() => new()
|
|
|
|
|
{
|
|
|
|
|
Id = 0,
|
|
|
|
|
Name = "Test Level",
|
|
|
|
|
Description = "Test",
|
|
|
|
|
Width = _width,
|
|
|
|
|
Height = _height,
|
|
|
|
|
Productions = _productions,
|
|
|
|
|
Demands = _demands,
|
|
|
|
|
Walls = _walls,
|
|
|
|
|
Stock = _stock
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public BoardState BuildState() => BoardState.FromLevel(Build());
|
|
|
|
|
}
|