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.
31 lines
707 B
C#
31 lines
707 B
C#
using Chessistics.Engine.Commands;
|
|
using Chessistics.Engine.Events;
|
|
using Chessistics.Engine.Model;
|
|
|
|
namespace Chessistics.Engine.Simulation;
|
|
|
|
public class GameSim
|
|
{
|
|
private readonly BoardState _state;
|
|
|
|
public GameSim(LevelDef level)
|
|
{
|
|
_state = BoardState.FromLevel(level);
|
|
}
|
|
|
|
public IReadOnlyList<IWorldEvent> ProcessCommand(IWorldCommand command)
|
|
{
|
|
var changeList = new List<IWorldEvent>();
|
|
try
|
|
{
|
|
command.Apply(_state, changeList);
|
|
}
|
|
catch (CommandRejectedException ex)
|
|
{
|
|
return [ex.RejectionEvent];
|
|
}
|
|
return changeList;
|
|
}
|
|
|
|
public BoardSnapshot GetSnapshot() => new(_state);
|
|
}
|