Beispiel #1
0
    private void playerTurn(Position position)
    {
        if (moveCell.isMove)
        {
            interfaceBoard.HintOff();
            moveCell.isMove = false;
            if (!(moveCell.position.x == position.x && moveCell.position.y == position.y))
            {
                moveCell.newPosition = position;

                string name  = "";
                string color = "";
                board.AreFigure(moveCell.position, ref name, ref color);

                if (board.Move(moveCell.position, moveCell.newPosition))
                {
                    interfaceBoard.Move(moveCell.position, moveCell.newPosition);
                    //
                    string newName = "";
                    board.AreFigure(moveCell.newPosition, ref newName, ref color);
                    if (name != newName && name == "Pawn")
                    {
                        interfaceBoard.PawnToQueen(moveCell.newPosition, newName);
                    }
                    //
                    changeCourse();
                    checkFinishAndMat();
                    if (isGame)
                    {
                        AITurn();
                        changeCourse();
                        checkFinishAndMat();
                    }
                }
            }
        }
        else
        {
            string name        = "";
            string colorFigure = "";
            if (board.AreFigure(position, ref name, ref colorFigure))
            {
                if (color == colorFigure)
                {
                    List <Position> list = board.ListCoordinatesMoves(position);
                    if (list.Count != 0)
                    {
                        moveCell.position = position;
                        moveCell.isMove   = true;
                        interfaceBoard.HintOn(list);
                    }
                }
            }
        }
        checkFinishAndMat();
    }