private void MoveFigure(Position oldPos, Position newPos) { //changing play window cursor playWindow.Cursor = Cursors.WaitCursor; //rock change implementation if (newPos.Equals(matrix.GetKing(runColor)) && !matrix.FigureAt(matrix.GetKing(runColor)).IsMoved) { int dx = oldPos.X - newPos.X; dx = (dx > 0) ? (1) : (-1); Position kingPos = new Position(newPos.X + dx * 2, newPos.Y); Position rockPos = new Position(newPos.X + dx, newPos.Y); matrix.MoveFigure(newPos, kingPos); matrix.FigureAt(kingPos).IncreaseSteps(); playWindow.matrix.MoveImage(newPos, kingPos); matrix.MoveFigure(oldPos, rockPos); matrix.FigureAt(rockPos).IncreaseSteps(); playWindow.matrix.MoveImage(oldPos, rockPos); //print message in system log console playWindow.PrintToConsole("System: ", System.Drawing.Color.Red); playWindow.PrintToConsoleLn("King-rock change", System.Drawing.Color.Green); } else { //simple figure move //print message in system log console if (runColor == FigureColor.WHITE) { playWindow.PrintToConsole("System: ", System.Drawing.Color.Red); playWindow.PrintToConsoleLn("Player1 moved " + matrix.FigureAt(oldPos).ToString() + " from " + (char)('A' + oldPos.X) + Convert.ToString(8 - oldPos.Y) + " to " + (char)('A' + newPos.X) + Convert.ToString(8 - newPos.Y), System.Drawing.Color.FromArgb(64, 128, 255)); } else { playWindow.PrintToConsole("System: ", System.Drawing.Color.Red); playWindow.PrintToConsoleLn("Player2 moved " + matrix.FigureAt(oldPos).ToString() + " from " + (char)('A' + oldPos.X) + Convert.ToString(8 - oldPos.Y) + " to " + (char)('A' + newPos.X) + Convert.ToString(8 - newPos.Y), System.Drawing.Color.FromArgb(128, 64, 255)); } Figure figure = matrix.FigureAt(oldPos); matrix.MoveFigure(oldPos, newPos); playWindow.matrix.MoveImage(oldPos, newPos); figure.IncreaseSteps(); //checking pawn move gap if (figure is Pawn) { ((Pawn)figure).TwoStepState = (Math.Abs(oldPos.Y - newPos.Y) == 2); //Проверка на замену пешки другой фигурой if ((runColor == FigureColor.WHITE && newPos.Y == 0) || (runColor == FigureColor.BLACK && newPos.Y == 7)) { if ((network.type == NetWorkType.SERVER && runColor == FigureColor.WHITE) || (network.type == NetWorkType.CLIENT && runColor == FigureColor.BLACK)) { FigureChoiceWindow w = new FigureChoiceWindow(playWindow.GetPosOnScreen(newPos), runColor); w.ShowDialog(playWindow); matrix.SetFigure(w.Result, newPos); playWindow.matrix.SetImage(w.Result.image, newPos); playWindow.ReDraw(true); } } else { GetInPass(oldPos, newPos); ((Pawn)matrix.FigureAt(newPos)).NeighborsFigures[1] = matrix.FigureAt(newPos.X + 1, newPos.Y); ((Pawn)matrix.FigureAt(newPos)).NeighborsFigures[0] = matrix.FigureAt(newPos.X - 1, newPos.Y); } } } //changing color changing runColor = (runColor == FigureColor.WHITE) ? (FigureColor.BLACK) : (FigureColor.WHITE); CheckForMate(); playWindow.matrix.ResetAllAttribures(); playWindow.Cursor = Cursors.Default; playWindow.ReDraw(); }