Chessistics/chessistics-engine/Model/BoardSnapshot.cs
Samuel Bouchet e6eaae43ab Initial commit: Chessistics prototype v0.3
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.
2026-04-10 14:58:03 +02:00

44 lines
1.8 KiB
C#

namespace Chessistics.Engine.Model;
public class BoardSnapshot
{
public int Width { get; }
public int Height { get; }
public CellType[,] Grid { get; }
public IReadOnlyList<ProductionSnapshot> Productions { get; }
public IReadOnlyList<DemandSnapshot> Demands { get; }
public IReadOnlyList<PieceSnapshot> Pieces { get; }
public SimPhase Phase { get; }
public int TurnNumber { get; }
public IReadOnlyDictionary<PieceKind, int> RemainingStock { get; }
public BoardSnapshot(BoardState state)
{
Width = state.Width;
Height = state.Height;
Phase = state.Phase;
TurnNumber = state.TurnNumber;
// Deep copy grid
Grid = new CellType[Width, Height];
Array.Copy(state.Grid, Grid, state.Grid.Length);
Productions = state.Productions.Values
.Select(p => new ProductionSnapshot(p.Position, p.Name, p.Cargo, p.Interval, state.ProductionBuffers[p.Position]))
.ToList();
Demands = state.Demands.Values
.Select(d => new DemandSnapshot(d.Position, d.Name, d.Cargo, d.Required, d.Deadline, d.ReceivedCount, d.IsSatisfied))
.ToList();
Pieces = state.Pieces
.Select(p => new PieceSnapshot(p.Id, p.Kind, p.StartCell, p.EndCell, p.CurrentCell, p.Cargo, p.SocialStatus))
.ToList();
RemainingStock = new Dictionary<PieceKind, int>(state.RemainingStock);
}
}
public record ProductionSnapshot(Coords Position, string Name, CargoType Cargo, int Interval, CargoType? Buffer);
public record DemandSnapshot(Coords Position, string Name, CargoType Cargo, int Required, int Deadline, int ReceivedCount, bool IsSatisfied);
public record PieceSnapshot(int Id, PieceKind Kind, Coords StartCell, Coords EndCell, Coords CurrentCell, CargoType? Cargo, int SocialStatus);