static void Main(string[] args) { var checkDetectionService = AppContainer.GetService <ICheckDetectionService>(); var engineProvider = AppContainer.GetService <IBoardEngineProvider <ChessPieceEntity> >(); var entityFactory = AppContainer.GetService <IBoardEntityFactory <ChessPieceEntity> >(); var game = new ChessGame(engineProvider, entityFactory, checkDetectionService); var lastResult = ""; while (game.InProgress) { Console.Clear(); Console.WriteLine("Chess console Spikes host"); var board = new StringBoardBuilder().BuildSimpleTestBoard(game.Board); var lines = board.Split('\n'); WriteLinesAt(1, 2, lines); Console.CursorTop = 2; Console.CursorLeft = lines.Max(b => b.Length) + 1; Console.WriteLine("MENU GOES HERE"); Console.CursorTop = lines.Length + 3; Console.CursorLeft = 0; if (string.IsNullOrEmpty(lastResult)) { Console.WriteLine("OTHER INFORMATION OUTPUT GOES HERE"); } else { Console.WriteLine($"!!! ERROR"); Console.WriteLine($"!!! {lastResult}"); Console.WriteLine($"!!!"); } Console.CursorTop = lines.Length + 1; Console.CursorLeft = 0; Console.Write($"Enter move for player {game.CurrentPlayer} : "); var input = Console.ReadLine(); if (input == "quit") { if (Quit()) { return; } } else if (!string.IsNullOrEmpty(input)) { lastResult = game.Move(input); } } }
public static StandardAlgebraicNotation Parse(string notation) { var sanBuilder = AppContainer.GetService <ISanBuilder>(); var an = sanBuilder.BuildFrom(notation); if (an.CastleMove == CastleSide.None && an.ToNotation() != notation) { throw new Exception($"Notation parse mismatch: {notation} != {an.ToNotation()}"); } return(an); }
protected T GetService <T>() { return(AppContainer.GetService <T>()); }