public static void MakeMove(string[] move, string[,] cell) { string start = move[0]; if (!FigureMove.RecognitionFigureInCell(cell, start)) { WorkConsole.Error(); } string end = move[1]; bool isCorrect = FigureMove.CheckCorrectOfTheMove(cell, start, end); int StartHorizontalCood = start[1] - 48; int StartVerticalCoord = start[0] - 48; int EndHorizontalCood = end[1] - 48; int EndVerticalCoord = end[0] - 48; if (isCorrect) { string pickFigure = cell[StartVerticalCoord, StartHorizontalCood]; cell[StartVerticalCoord, StartHorizontalCood] = null; cell[EndVerticalCoord, EndHorizontalCood] = pickFigure; } else { WorkConsole.Error(); } }
public Chess Move(string move)//Pe2e4 Pe7e8Q { FigureMove fm = new FigureMove(move); Board nextBoard = board.Move(fm); Chess nextChess = new Chess(nextBoard); //nextChess.fen = board.fen return(nextChess); }
public Board Move(FigureMove fm) { Board next = new Board(fen); next.SetFigureAt(fm.from, Figure.none); next.SetFigureAt(fm.to, fm.promotion == Figure.none ? fm.figure : fm.promotion); if (moveColor == Color.black) { next.moveNumber++; } next.moveColor = moveColor.FlipColor(); next.GenerateFEN(); return(next); }
public static void SelectCell(int[] selectCell, string[,] cell, int[] pastSelectCell, string[] movementOfTheFigures) { bool IsTheFigureSelected = true; while (true) { ConsoleKey key = Console.ReadKey().Key; if (key == ConsoleKey.DownArrow && selectCell[1] < 7) { selectCell[1]++; } if (key == ConsoleKey.UpArrow && selectCell[1] > 0) { selectCell[1]--; } if (key == ConsoleKey.RightArrow && selectCell[0] < 7) { selectCell[0]++; } if (key == ConsoleKey.LeftArrow && selectCell[0] > 0) { selectCell[0]--; } WorkConsole.WriteChoiceCell(selectCell, cell, pastSelectCell); if (key == ConsoleKey.Enter && !IsTheFigureSelected) { movementOfTheFigures[1] = $"{selectCell[0]}{selectCell[1]}"; break; } if (key == ConsoleKey.Enter && IsTheFigureSelected && FigureMove.RecognitionFigureInCell(cell, $"{selectCell[0]}{selectCell[1]}")) { movementOfTheFigures[0] = $"{selectCell[0]}{selectCell[1]}"; IsTheFigureSelected = false; } } }
protected override bool CheckMove(string nextCoord) { FigureMove figureMove = new FigureMove(nextCoord, _currentCoord); return(figureMove.IsValidDiagonalMove() || figureMove.IsValidDirectMove()); }
protected override bool CheckMove(string nextCoord) { FigureMove figureMove = new FigureMove(nextCoord, _currentCoord); return(figureMove.Dx == 1 && figureMove.Dy == 2 || figureMove.Dx == 2 && figureMove.Dy == 1); }
public bool CanMove(FigureMove fm) { this.fm = fm; return(CanMoveFrom() && CanMoveTo() && CanFigureMove()); }