2026-04-10 14:58:03 +02:00
|
|
|
namespace Chessistics.Engine.Model;
|
|
|
|
|
|
|
|
|
|
public class PieceState
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; }
|
|
|
|
|
public PieceKind Kind { get; }
|
2026-04-10 21:44:12 +02:00
|
|
|
public int Level { get; }
|
2026-04-16 21:22:49 +02:00
|
|
|
public Coords StartCell { get; private set; }
|
|
|
|
|
public Coords EndCell { get; private set; }
|
2026-04-10 14:58:03 +02:00
|
|
|
public Coords CurrentCell { get; set; }
|
|
|
|
|
public CargoType? Cargo { get; set; }
|
2026-04-10 15:35:37 +02:00
|
|
|
public CargoType? CargoFilter { get; set; }
|
2026-04-10 14:58:03 +02:00
|
|
|
public int SocialStatus { get; }
|
|
|
|
|
public int PlacementOrder { get; }
|
|
|
|
|
|
2026-04-10 21:44:12 +02:00
|
|
|
public PieceState(int id, PieceKind kind, Coords startCell, Coords endCell, int placementOrder, int level = 1)
|
2026-04-10 14:58:03 +02:00
|
|
|
{
|
|
|
|
|
Id = id;
|
|
|
|
|
Kind = kind;
|
2026-04-10 21:44:12 +02:00
|
|
|
Level = level;
|
2026-04-10 14:58:03 +02:00
|
|
|
StartCell = startCell;
|
|
|
|
|
EndCell = endCell;
|
|
|
|
|
CurrentCell = startCell;
|
|
|
|
|
Cargo = null;
|
|
|
|
|
SocialStatus = PieceRules.GetSocialStatus(kind);
|
|
|
|
|
PlacementOrder = placementOrder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the cell this piece will move to next.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Coords TargetCell => CurrentCell == StartCell ? EndCell : StartCell;
|
2026-04-16 21:22:49 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Relocate this piece (drag & drop).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void SetPosition(Coords newStart, Coords newEnd)
|
|
|
|
|
{
|
|
|
|
|
StartCell = newStart;
|
|
|
|
|
EndCell = newEnd;
|
|
|
|
|
CurrentCell = newStart;
|
|
|
|
|
}
|
Add QuickSave/QuickLoad with full state restore and visual rebuild
BoardState.CaptureSave/RestoreFromSave deep-copy every mutable field
(grid, pieces, demands, transformers, buffers, stock, campaign progress)
into a WorldSave slot. GameSim.QuickSave/QuickLoad expose slotted saves
and emit StateSavedEvent / StateRestoredEvent — the latter carries a
fresh BoardSnapshot so the presentation can rebuild board, pieces,
trajectories, objectives, stock, camera, and control bar in one pass.
F5/F9 trigger it in Main; harness gains quick_save/quick_load commands so
UI tests can checkpoint a scenario and resume without replaying from
scratch. Seven xUnit tests cover the roundtrip (including independence
from post-save mutations, campaign state, and multi-slot isolation).
2026-04-17 22:10:06 +02:00
|
|
|
|
|
|
|
|
public PieceState Clone()
|
|
|
|
|
{
|
|
|
|
|
var clone = new PieceState(Id, Kind, StartCell, EndCell, PlacementOrder, Level)
|
|
|
|
|
{
|
|
|
|
|
CurrentCell = CurrentCell,
|
|
|
|
|
Cargo = Cargo,
|
|
|
|
|
CargoFilter = CargoFilter
|
|
|
|
|
};
|
|
|
|
|
return clone;
|
|
|
|
|
}
|
2026-04-10 14:58:03 +02:00
|
|
|
}
|