Beispiel #1
0
 /// <summary>
 /// Создать ферзя
 /// </summary>
 /// <param name="color"></param>
 public Queen(ColorFigur color) : base(TypeFigur.queen, color)
 {
     if (color == ColorFigur.none)
     {
         Color = ColorFigur.white;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Создать ладью
 /// </summary>
 /// <param name="color"></param>
 public Rock(ColorFigur color) : base(TypeFigur.rock, color)
 {
     if (color == ColorFigur.none)
     {
         Color = ColorFigur.white;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Создать слона
 /// </summary>
 /// <param name="color"></param>
 public Bishop(ColorFigur color) : base(TypeFigur.bishop, color)
 {
     if (color == ColorFigur.none)
     {
         Color = ColorFigur.white;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Создать короля
 /// </summary>
 /// <param name="color"></param>
 public King(ColorFigur color) : base(TypeFigur.king, color)
 {
     if (color == ColorFigur.none)
     {
         Color = ColorFigur.white;
     }
 }
Beispiel #5
0
 /// <summary>
 /// Создать коня
 /// </summary>
 /// <param name="color"></param>
 public Knight(ColorFigur color) : base(TypeFigur.knight, color)
 {
     if (color == ColorFigur.none)
     {
         Color = ColorFigur.white;
     }
 }
Beispiel #6
0
 /// <summary>
 /// Создать пешку
 /// </summary>
 /// <param name="color"></param>
 public Peen(ColorFigur color) : base(TypeFigur.peen, color)
 {
     if (color == ColorFigur.none)
     {
         Color = ColorFigur.white;
     }
     IsEnPassant = false;
 }
Beispiel #7
0
 /// <summary>
 /// Конструктор фигуры с указанием ее типа и цвета
 /// </summary>
 /// <param name="type"></param>
 /// <param name="color"></param>
 public Figure(TypeFigur type, ColorFigur color)
 {
     Color = color;
     Type  = type;
 }
Beispiel #8
0
 /// <summary>
 /// Атакована ли данная клетка
 /// </summary>
 public static void CheckAttack(ref Position pos, int x, int y, ColorFigur color)
 {
     if (color == ColorFigur.none)
     {
         CheckAttack(ref pos, x, y, ColorFigur.white);
         CheckAttack(ref pos, x, y, ColorFigur.black);
     }
     if (color == ColorFigur.white)
     {
         //атака пешкой
         if (x > 0)
         {
             if (y > 0)
             {
                 if (pos.Board[x - 1, y - 1].Figure.Type == TypeFigur.peen && pos.Board[x - 1, y - 1].Figure.Color == ColorFigur.white)
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
             if (y < 7)
             {
                 if (pos.Board[x - 1, y + 1].Figure.Type == TypeFigur.peen && pos.Board[x - 1, y + 1].Figure.Color == ColorFigur.white)
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
         }
         //конем
         #region
         if (x + 1 < 8)
         {
             if (x + 2 < 8)
             {
                 if (y + 1 < 8)
                 {
                     if (pos.Board[x + 2, y + 1].Figure.Type == TypeFigur.knight && pos.Board[x + 2, y + 1].Figure.Color == ColorFigur.white)
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                 }
                 if (y - 1 >= 0)
                 {
                     if (pos.Board[x + 2, y - 1].Figure.Type == TypeFigur.knight && pos.Board[x + 2, y - 1].Figure.Color == ColorFigur.white)
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                 }
             }
             if (y + 2 < 8)
             {
                 if (pos.Board[x + 1, y + 2].Figure.Type == TypeFigur.knight && pos.Board[x + 1, y + 2].Figure.Color == ColorFigur.white)
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
             if (y - 2 >= 0)
             {
                 if (pos.Board[x + 1, y - 2].Figure.Type == TypeFigur.knight && pos.Board[x + 1, y - 2].Figure.Color == ColorFigur.white)
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
         }
         if (x - 1 >= 0)
         {
             if (x - 2 >= 0)
             {
                 if (y + 1 < 8)
                 {
                     if (pos.Board[x - 2, y + 1].Figure.Type == TypeFigur.knight && pos.Board[x - 2, y + 1].Figure.Color == ColorFigur.white)
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                 }
                 if (y - 1 >= 0)
                 {
                     if (pos.Board[x - 2, y - 1].Figure.Type == TypeFigur.knight && pos.Board[x - 2, y - 1].Figure.Color == ColorFigur.white)
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                 }
             }
             if (y + 2 < 8)
             {
                 if (pos.Board[x - 1, y + 2].Figure.Type == TypeFigur.knight && pos.Board[x - 1, y + 2].Figure.Color == ColorFigur.white)
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
             if (y - 2 >= 0)
             {
                 if (pos.Board[x - 1, y - 2].Figure.Type == TypeFigur.knight && pos.Board[x - 1, y - 2].Figure.Color == ColorFigur.white)
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
         }
         #endregion
         //слон, ладья, ферзь, король
         #region
         for (int i = 1; x + i < 8; i++)
         {
             if (pos.Board[x + i, y] != new Square(new NotFigur()))
             {
                 if (i == 1)
                 {
                     if (pos.Board[x + i, y] == new Square(new King(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x + i, y] == new Square(new Queen(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x + i, y] == new Square(new Rock(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                 }
                 if ((pos.Board[x + i, y] != new Square(new Queen(ColorFigur.white))) && (pos.Board[x + i, y] != new Square(new Rock(ColorFigur.white))))
                 {
                     break;
                 }
                 else
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
         }
         for (int i = 1; x - i >= 0; i++)
         {
             if (pos.Board[x - i, y] != new Square(new NotFigur()))
             {
                 if (i == 1)
                 {
                     if (pos.Board[x - i, y] == new Square(new King(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x - i, y] == new Square(new Queen(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x - i, y] == new Square(new Rock(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                 }
                 if ((pos.Board[x - i, y] != new Square(new Queen(ColorFigur.white))) && (pos.Board[x - i, y] != new Square(new Rock(ColorFigur.white))))
                 {
                     break;
                 }
                 else
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
         }
         for (int i = 1; y + i < 8; i++)
         {
             if (pos.Board[x, y + i] != new Square(new NotFigur()))
             {
                 if (i == 1)
                 {
                     if (pos.Board[x, y + i] == new Square(new King(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x, y + i] == new Square(new Queen(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x, y + i] == new Square(new Rock(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                 }
                 if ((pos.Board[x, y + i] != new Square(new Queen(ColorFigur.white))) && (pos.Board[x, y + i] != new Square(new Rock(ColorFigur.white))))
                 {
                     break;
                 }
                 else
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
         }
         for (int i = 1; y - i >= 0; i++)
         {
             if (pos.Board[x, y - i] != new Square(new NotFigur()))
             {
                 if (i == 1)
                 {
                     if (pos.Board[x, y - i] == new Square(new King(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x, y - i] == new Square(new Queen(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x, y - i] == new Square(new Rock(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                 }
                 if ((pos.Board[x, y - i] != new Square(new Queen(ColorFigur.white))) && (pos.Board[x, y - i] != new Square(new Rock(ColorFigur.white))))
                 {
                     break;
                 }
                 else
                 {
                     pos.Board[x, y].IsAttackWhite = true;
                     return;
                 }
             }
         }
         #endregion
         bool b1 = false;
         bool b2 = false;
         bool b3 = false;
         bool b4 = false;
         for (int i = 1; ((x + i < 8) && (y + i < 8)) || ((x + i < 8) && (y - i >= 0)) || ((x - i >= 0) && (y + i < 8)) || ((x - i >= 0) && (y - i >= 0)); i++)
         {
             if (!b1 && (x + i < 8) && (y + i < 8))
             {
                 if (pos.Board[x + i, y + i] != new Square(new NotFigur()))
                 {
                     if (i == 1)
                     {
                         if (pos.Board[x + i, y + i] == new Square(new King(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         if (pos.Board[x + i, y + i] == new Square(new Queen(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         if (pos.Board[x + i, y + i] == new Square(new Bishop(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         b1 = true;
                     }
                     if (pos.Board[x + i, y + i] == new Square(new Queen(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x + i, y + i] == new Square(new Bishop(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     b1 = true;
                 }
             }
             if (!b2 && (x + i < 8) && (y - i >= 0))
             {
                 if (pos.Board[x + i, y - i] != new Square(new NotFigur()))
                 {
                     if (i == 1)
                     {
                         if (pos.Board[x + i, y - i] == new Square(new King(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         if (pos.Board[x + i, y - i] == new Square(new Queen(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         if (pos.Board[x + i, y - i] == new Square(new Bishop(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         b2 = true;
                     }
                     if (pos.Board[x + i, y - i] == new Square(new Queen(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x + i, y - i] == new Square(new Bishop(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     b2 = true;
                 }
             }
             if (!b3 && (x - i >= 0) && (y + i < 8))
             {
                 if (pos.Board[x - i, y + i] != new Square(new NotFigur()))
                 {
                     if (i == 1)
                     {
                         if (pos.Board[x - i, y + i] == new Square(new King(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         if (pos.Board[x - i, y + i] == new Square(new Queen(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         if (pos.Board[x - i, y + i] == new Square(new Bishop(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         b3 = true;
                     }
                     if (pos.Board[x - i, y + i] == new Square(new Queen(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x - i, y + i] == new Square(new Bishop(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     b3 = true;
                 }
             }
             if (!b4 && (x - i >= 0) && (y - i >= 0))
             {
                 if (pos.Board[x - i, y - i] != new Square(new NotFigur()))
                 {
                     if (i == 1)
                     {
                         if (pos.Board[x - i, y - i] == new Square(new King(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         if (pos.Board[x - i, y - i] == new Square(new Queen(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         if (pos.Board[x - i, y - i] == new Square(new Bishop(ColorFigur.white)))
                         {
                             pos.Board[x, y].IsAttackWhite = true;
                             return;
                         }
                         b4 = true;
                     }
                     if (pos.Board[x - i, y - i] == new Square(new Queen(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     if (pos.Board[x - i, y - i] == new Square(new Bishop(ColorFigur.white)))
                     {
                         pos.Board[x, y].IsAttackWhite = true;
                         return;
                     }
                     b4 = true;
                 }
             }
             if (b1 && b2 && b3 && b4)
             {
                 break;
             }
         }
     }
     else
     {
         //эквивалентно белым
         if (x < 7)
         {
             if (y > 0)
             {
                 if (pos.Board[x + 1, y - 1] == new Square(new Peen(ColorFigur.black)))
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
             if (y < 7)
             {
                 if (pos.Board[x + 1, y + 1] == new Square(new Peen(ColorFigur.black)))
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
         }
         //конем
         #region
         if (x + 1 < 8)
         {
             if (x + 2 < 8)
             {
                 if (y + 1 < 8)
                 {
                     if (pos.Board[x + 2, y + 1] == new Square(new Knight(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                 }
                 if (y - 1 >= 0)
                 {
                     if (pos.Board[x + 2, y - 1] == new Square(new Knight(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                 }
             }
             if (y + 2 < 8)
             {
                 if (pos.Board[x + 1, y + 2] == new Square(new Knight(ColorFigur.black)))
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
             if (y - 2 >= 0)
             {
                 if (pos.Board[x + 1, y - 2] == new Square(new Knight(ColorFigur.black)))
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
         }
         if (x - 1 >= 0)
         {
             if (x - 2 >= 0)
             {
                 if (y + 1 < 8)
                 {
                     if (pos.Board[x - 2, y + 1] == new Square(new Knight(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                 }
                 if (y - 1 >= 0)
                 {
                     if (pos.Board[x - 2, y - 1] == new Square(new Knight(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                 }
             }
             if (y + 2 < 8)
             {
                 if (pos.Board[x - 1, y + 2] == new Square(new Knight(ColorFigur.black)))
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
             if (y - 2 >= 0)
             {
                 if (pos.Board[x - 1, y - 2] == new Square(new Knight(ColorFigur.black)))
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
         }
         #endregion
         //слон, ладья, ферзь, король
         #region
         for (int i = 1; x + i < 8; i++)
         {
             if (pos.Board[x + i, y] != new Square(new NotFigur()))
             {
                 if (i == 1)
                 {
                     if (pos.Board[x + i, y] == new Square(new King(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x + i, y] == new Square(new Queen(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x + i, y] == new Square(new Rock(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                 }
                 if ((pos.Board[x + i, y] != new Square(new Queen(ColorFigur.black))) && (pos.Board[x + i, y] != new Square(new Rock(ColorFigur.black))))
                 {
                     break;
                 }
                 else
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
         }
         for (int i = 1; x - i >= 0; i++)
         {
             if (pos.Board[x - i, y] != new Square(new NotFigur()))
             {
                 if (i == 1)
                 {
                     if (pos.Board[x - i, y] == new Square(new King(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x - i, y] == new Square(new Queen(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x - i, y] == new Square(new Rock(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                 }
                 if ((pos.Board[x - i, y] != new Square(new Queen(ColorFigur.black))) && (pos.Board[x - i, y] != new Square(new Rock(ColorFigur.black))))
                 {
                     break;
                 }
                 else
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
         }
         for (int i = 1; y + i < 8; i++)
         {
             if (pos.Board[x, y + i] != new Square(new NotFigur()))
             {
                 if (i == 1)
                 {
                     if (pos.Board[x, y + i] == new Square(new King(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x, y + i] == new Square(new Queen(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x, y + i] == new Square(new Rock(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                 }
                 if ((pos.Board[x, y + i] != new Square(new Queen(ColorFigur.black))) && (pos.Board[x, y + i] != new Square(new Rock(ColorFigur.black))))
                 {
                     break;
                 }
                 else
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
         }
         for (int i = 1; y - i >= 0; i++)
         {
             if (pos.Board[x, y - i] != new Square(new NotFigur()))
             {
                 if (i == 1)
                 {
                     if (pos.Board[x, y - i] == new Square(new King(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x, y - i] == new Square(new Queen(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x, y - i] == new Square(new Rock(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                 }
                 if ((pos.Board[x, y - i] != new Square(new Queen(ColorFigur.black))) && (pos.Board[x, y - i] != new Square(new Rock(ColorFigur.black))))
                 {
                     break;
                 }
                 else
                 {
                     pos.Board[x, y].IsAttackBlack = true;
                     return;
                 }
             }
         }
         #endregion
         bool b1 = false;
         bool b2 = false;
         bool b3 = false;
         bool b4 = false;
         for (int i = 1; ((x + i < 8) && (y + i < 8)) || ((x + i < 8) && (y - i >= 0)) || ((x - i >= 0) && (y + i < 8)) || ((x - i >= 0) && (y - i >= 0)); i++)
         {
             if (!b1 && (x + i < 8) && (y + i < 8))
             {
                 if (pos.Board[x + i, y + i] != new Square(new NotFigur()))
                 {
                     if (i == 1)
                     {
                         if (pos.Board[x + i, y + i] == new Square(new King(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         if (pos.Board[x + i, y + i] == new Square(new Queen(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         if (pos.Board[x + i, y + i] == new Square(new Bishop(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         b1 = true;
                     }
                     if (pos.Board[x + i, y + i] == new Square(new Queen(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x + i, y + i] == new Square(new Bishop(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     b1 = true;
                 }
             }
             if (!b2 && (x + i < 8) && (y - i >= 0))
             {
                 if (pos.Board[x + i, y - i] != new Square(new NotFigur()))
                 {
                     if (i == 1)
                     {
                         if (pos.Board[x + i, y - i] == new Square(new King(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         if (pos.Board[x + i, y - i] == new Square(new Queen(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         if (pos.Board[x + i, y - i] == new Square(new Bishop(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         b2 = true;
                     }
                     if (pos.Board[x + i, y - i] == new Square(new Queen(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x + i, y - i] == new Square(new Bishop(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     b2 = true;
                 }
             }
             if (!b3 && (x - i >= 0) && (y + i < 8))
             {
                 if (pos.Board[x - i, y + i] != new Square(new NotFigur()))
                 {
                     if (i == 1)
                     {
                         if (pos.Board[x - i, y + i] == new Square(new King(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         if (pos.Board[x - i, y + i] == new Square(new Queen(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         if (pos.Board[x - i, y + i] == new Square(new Bishop(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         b3 = true;
                     }
                     if (pos.Board[x - i, y + i] == new Square(new Queen(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x - i, y + i] == new Square(new Bishop(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     b3 = true;
                 }
             }
             if (!b4 && (x - i >= 0) && (y - i >= 0))
             {
                 if (pos.Board[x - i, y - i] != new Square(new NotFigur()))
                 {
                     if (i == 1)
                     {
                         if (pos.Board[x - i, y - i] == new Square(new King(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         if (pos.Board[x - i, y - i] == new Square(new Queen(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         if (pos.Board[x - i, y - i] == new Square(new Bishop(ColorFigur.black)))
                         {
                             pos.Board[x, y].IsAttackBlack = true;
                             return;
                         }
                         b4 = true;
                     }
                     if (pos.Board[x - i, y - i] == new Square(new Queen(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     if (pos.Board[x - i, y - i] == new Square(new Bishop(ColorFigur.black)))
                     {
                         pos.Board[x, y].IsAttackBlack = true;
                         return;
                     }
                     b4 = true;
                 }
             }
             if (b1 && b2 && b3 && b4)
             {
                 break;
             }
         }
     }
 }