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.Commands;
|
|
using Chessistics.Engine.Events;
|
|
using Chessistics.Engine.Model;
|
|
using Chessistics.Engine.Simulation;
|
|
|
|
namespace Chessistics.Tests.Helpers;
|
|
|
|
public class SimHelper
|
|
{
|
|
public GameSim Sim { get; }
|
|
|
|
private SimHelper(GameSim sim) => Sim = sim;
|
|
|
|
public static SimHelper FromLevel(LevelDef level) => new(new GameSim(level));
|
|
|
|
public IReadOnlyList<IWorldEvent> Place(PieceKind kind, Coords start, Coords end)
|
|
=> Sim.ProcessCommand(new PlacePieceCommand(kind, start, end));
|
|
|
|
public IReadOnlyList<IWorldEvent> Place(PieceKind kind, (int col, int row) start, (int col, int row) end)
|
|
=> Place(kind, new Coords(start.col, start.row), new Coords(end.col, end.row));
|
|
|
|
public IReadOnlyList<IWorldEvent> Remove(int pieceId)
|
|
=> Sim.ProcessCommand(new RemovePieceCommand(pieceId));
|
|
|
|
public IReadOnlyList<IWorldEvent> Start()
|
|
=> Sim.ProcessCommand(new StartSimulationCommand());
|
|
|
|
public IReadOnlyList<IWorldEvent> Step()
|
|
=> Sim.ProcessCommand(new StepSimulationCommand());
|
|
|
|
public IReadOnlyList<IWorldEvent> Pause()
|
|
=> Sim.ProcessCommand(new PauseSimulationCommand());
|
|
|
|
public IReadOnlyList<IWorldEvent> Resume()
|
|
=> Sim.ProcessCommand(new ResumeSimulationCommand());
|
|
|
|
public IReadOnlyList<IWorldEvent> Stop()
|
|
=> Sim.ProcessCommand(new StopSimulationCommand());
|
|
|
|
public IReadOnlyList<IWorldEvent> Reset()
|
|
=> Sim.ProcessCommand(new ResetLevelCommand());
|
|
|
|
public List<IWorldEvent> StepN(int n)
|
|
{
|
|
var allEvents = new List<IWorldEvent>();
|
|
for (int i = 0; i < n; i++)
|
|
allEvents.AddRange(Step());
|
|
return allEvents;
|
|
}
|
|
|
|
public BoardSnapshot Snapshot => Sim.GetSnapshot();
|
|
}
|