namespace Chessistics.Engine.Model; public class PieceState { public int Id { get; } public PieceKind Kind { get; } public int Level { get; } public Coords StartCell { get; private set; } public Coords EndCell { get; private set; } public Coords CurrentCell { get; set; } public CargoType? Cargo { get; set; } public CargoType? CargoFilter { get; set; } public int SocialStatus { get; } public int PlacementOrder { get; } public PieceState(int id, PieceKind kind, Coords startCell, Coords endCell, int placementOrder, int level = 1) { Id = id; Kind = kind; Level = level; StartCell = startCell; EndCell = endCell; CurrentCell = startCell; Cargo = null; SocialStatus = PieceRules.GetSocialStatus(kind); PlacementOrder = placementOrder; } /// /// Returns the cell this piece will move to next. /// public Coords TargetCell => CurrentCell == StartCell ? EndCell : StartCell; /// /// Relocate this piece (drag & drop). /// public void SetPosition(Coords newStart, Coords newEnd) { StartCell = newStart; EndCell = newEnd; CurrentCell = newStart; } public PieceState Clone() { var clone = new PieceState(Id, Kind, StartCell, EndCell, PlacementOrder, Level) { CurrentCell = CurrentCell, Cargo = Cargo, CargoFilter = CargoFilter }; return clone; } }