private static List <Move> GetIndividualKingBeats(Cell king, CellState[,] boardArray, Team teamPlaying, List <Move> beats)
        {
            var clonedBeats   = Clone.CloneJson(beats);
            var possibleGoTos = new List <Cell>();

            // top right
            for (var count = 1; king.X + count <= 7 && king.Y - count >= 0; count++)
            {
                if ((boardArray[king.X + count, king.Y - count] == CellState.BlackKing && teamPlaying == Team.White) ||
                    (boardArray[king.X + count, king.Y - count] == CellState.BlackPiece && teamPlaying == Team.White) ||
                    (boardArray[king.X + count, king.Y - count] == CellState.WhiteKing && teamPlaying == Team.Black) ||
                    (boardArray[king.X + count, king.Y - count] == CellState.WhitePiece && teamPlaying == Team.Black))
                {
                    count++;
                    for (; king.X + count <= 7 && king.Y - count >= 0; count++)
                    {
                        if (boardArray[king.X + count, king.Y - count] != CellState.Empty)
                        {
                            break;
                        }
                        if (boardArray[king.X + count, king.Y - count] == CellState.Empty)
                        {
                            possibleGoTos.Add(new Cell
                            {
                                X = king.X + count,
                                Y = king.Y - count,
                            });
                        }
                    }

                    break;
                }
                else if (boardArray[king.X + count, king.Y - count] != CellState.Empty)
                {
                    break;
                }
            }
            // top left
            for (var count = 1; king.X - count >= 0 && king.Y - count >= 0; count++)
            {
                if ((boardArray[king.X - count, king.Y - count] == CellState.BlackKing && teamPlaying == Team.White) ||
                    (boardArray[king.X - count, king.Y - count] == CellState.BlackPiece && teamPlaying == Team.White) ||
                    (boardArray[king.X - count, king.Y - count] == CellState.WhiteKing && teamPlaying == Team.Black) ||
                    (boardArray[king.X - count, king.Y - count] == CellState.WhitePiece && teamPlaying == Team.Black))
                {
                    count++;
                    for (; king.X - count >= 0 && king.Y - count >= 0; count++)
                    {
                        if (boardArray[king.X - count, king.Y - count] != CellState.Empty)
                        {
                            break;
                        }
                        if (boardArray[king.X - count, king.Y - count] == CellState.Empty)
                        {
                            possibleGoTos.Add(new Cell
                            {
                                X = king.X - count,
                                Y = king.Y - count,
                            });
                        }
                    }

                    break;
                }
                else if (boardArray[king.X - count, king.Y - count] != CellState.Empty)
                {
                    break;
                }
            }
            // bottom left
            for (var count = 1; king.X - count >= 0 && king.Y + count <= 7; count++)
            {
                if ((boardArray[king.X - count, king.Y + count] == CellState.BlackKing && teamPlaying == Team.White) ||
                    (boardArray[king.X - count, king.Y + count] == CellState.BlackPiece && teamPlaying == Team.White) ||
                    (boardArray[king.X - count, king.Y + count] == CellState.WhiteKing && teamPlaying == Team.Black) ||
                    (boardArray[king.X - count, king.Y + count] == CellState.WhitePiece && teamPlaying == Team.Black))
                {
                    count++;
                    for (; king.X - count >= 0 && king.Y + count <= 7; count++)
                    {
                        if (boardArray[king.X - count, king.Y + count] != CellState.Empty)
                        {
                            break;
                        }
                        if (boardArray[king.X - count, king.Y + count] == CellState.Empty)
                        {
                            possibleGoTos.Add(new Cell
                            {
                                X = king.X - count,
                                Y = king.Y + count,
                            });
                        }
                    }

                    break;
                }
                else if (boardArray[king.X - count, king.Y + count] != CellState.Empty)
                {
                    break;
                }
            }
            // bottom right
            for (var count = 1; king.X + count <= 7 && king.Y + count <= 7; count++)
            {
                if ((boardArray[king.X + count, king.Y + count] == CellState.BlackKing && teamPlaying == Team.White) ||
                    (boardArray[king.X + count, king.Y + count] == CellState.BlackPiece && teamPlaying == Team.White) ||
                    (boardArray[king.X + count, king.Y + count] == CellState.WhiteKing && teamPlaying == Team.Black) ||
                    (boardArray[king.X + count, king.Y + count] == CellState.WhitePiece && teamPlaying == Team.Black))
                {
                    count++;
                    for (; king.X + count <= 7 && king.Y + count <= 7; count++)
                    {
                        if (boardArray[king.X + count, king.Y + count] != CellState.Empty)
                        {
                            break;
                        }
                        if (boardArray[king.X + count, king.Y + count] == CellState.Empty)
                        {
                            possibleGoTos.Add(new Cell
                            {
                                X = king.X + count,
                                Y = king.Y + count,
                            });
                        }
                    }

                    break;
                }
                else if (boardArray[king.X + count, king.Y + count] != CellState.Empty)
                {
                    break;
                }
            }

            if (possibleGoTos.Count == 0)
            {
                return(new List <Move>());
            }

            List <List <Move> > possibleBeats = new List <List <Move> >();

            possibleGoTos.ForEach((possibleGoTo) =>
            {
                var move = new Move
                {
                    StartingPoint = king,
                    EndingPoint   = possibleGoTo,
                };

                var newBoardArray = BoardExtensions.UpdateFromMoves(boardArray, new List <Move>()
                {
                    move
                });

                var beatsList = new List <Move>();
                beatsList.Add(move);
                var newBeats = GetIndividualKingBeats(possibleGoTo, newBoardArray, teamPlaying, beatsList);
                if (newBeats.Count > 1)
                {
                    beatsList = newBeats;
                }
                possibleBeats.Add(beatsList);
            });

            if (possibleBeats.Count > 0)
            {
                clonedBeats.AddRange(possibleBeats.OrderByDescending(x => x.Count()).First());
            }
            return(clonedBeats);
        }
        public List <List <Move> > GetPossibleBeats(CellState[,] boardArray, Team teamPlaying)
        {
            var possibleBeats = new List <List <Move> >();

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (boardArray[i, j] == CellState.WhitePiece && teamPlaying == Team.White)
                    {
                        if (i - 2 >= 0 && j - 2 >= 0 &&
                            (boardArray[i - 1, j - 1] == CellState.BlackPiece || boardArray[i - 1, j - 1] == CellState.BlackKing) &&
                            boardArray[i - 2, j - 2] == CellState.Empty)
                        {
                            var beats = new List <Move>
                            {
                                new Move
                                {
                                    StartingPoint = new Cell {
                                        X = i, Y = j
                                    },
                                    EndingPoint = new Cell {
                                        X = i - 2, Y = j - 2
                                    }
                                }
                            };
                            appendSubsequentBeats(Clone.CloneJson(boardArray), teamPlaying, beats);
                            possibleBeats.Add(beats);
                        }
                        if (i + 2 <= 7 && j - 2 >= 0 &&
                            (boardArray[i + 1, j - 1] == CellState.BlackPiece || boardArray[i + 1, j - 1] == CellState.BlackKing) &&
                            boardArray[i + 2, j - 2] == CellState.Empty)
                        {
                            var beats = new List <Move>
                            {
                                new Move {
                                    StartingPoint = new Cell {
                                        X = i, Y = j
                                    },
                                    EndingPoint = new Cell {
                                        X = i + 2, Y = j - 2
                                    }
                                }
                            };
                            appendSubsequentBeats(Clone.CloneJson(boardArray), teamPlaying, beats);
                            possibleBeats.Add(beats);
                        }

                        if (i - 2 >= 0 && j + 2 <= 7 &&
                            (boardArray[i - 1, j + 1] == CellState.BlackPiece || boardArray[i - 1, j + 1] == CellState.BlackKing) &&
                            boardArray[i - 2, j + 2] == CellState.Empty)
                        {
                            var beats = new List <Move>
                            {
                                new Move {
                                    StartingPoint = new Cell {
                                        X = i, Y = j
                                    },
                                    EndingPoint = new Cell {
                                        X = i - 2, Y = j + 2
                                    }
                                }
                            };
                            appendSubsequentBeats(Clone.CloneJson(boardArray), teamPlaying, beats);
                            possibleBeats.Add(beats);
                        }

                        if (i + 2 <= 7 && j + 2 <= 7 &&
                            (boardArray[i + 1, j + 1] == CellState.BlackPiece || boardArray[i + 1, j + 1] == CellState.BlackKing) &&
                            boardArray[i + 2, j + 2] == CellState.Empty)
                        {
                            var beats = new List <Move>
                            {
                                new Move {
                                    StartingPoint = new Cell {
                                        X = i, Y = j
                                    },
                                    EndingPoint = new Cell {
                                        X = i + 2, Y = j + 2
                                    }
                                }
                            };
                            appendSubsequentBeats(Clone.CloneJson(boardArray), teamPlaying, beats);
                            possibleBeats.Add(beats);
                        }
                    }
                    else if (boardArray[i, j] == CellState.BlackPiece && teamPlaying == Team.Black)
                    {
                        if (i + 2 <= 7 && j + 2 <= 7 &&
                            (boardArray[i + 1, j + 1] == CellState.WhitePiece || boardArray[i + 1, j + 1] == CellState.WhiteKing) &&
                            boardArray[i + 2, j + 2] == CellState.Empty)
                        {
                            var beats = new List <Move>
                            {
                                new Move
                                {
                                    StartingPoint = new Cell {
                                        X = i, Y = j
                                    },
                                    EndingPoint = new Cell {
                                        X = i + 2, Y = j + 2
                                    }
                                }
                            };

                            appendSubsequentBeats(Clone.CloneJson(boardArray), teamPlaying, beats);
                            possibleBeats.Add(beats);
                        }
                        if (i - 2 >= 0 && j + 2 <= 7 &&
                            (boardArray[i - 1, j + 1] == CellState.WhitePiece || boardArray[i - 1, j + 1] == CellState.WhiteKing) &&
                            boardArray[i - 2, j + 2] == CellState.Empty)
                        {
                            var beats = new List <Move>
                            {
                                new Move
                                {
                                    StartingPoint = new Cell {
                                        X = i, Y = j
                                    },
                                    EndingPoint = new Cell {
                                        X = i - 2, Y = j + 2
                                    }
                                }
                            };

                            appendSubsequentBeats(Clone.CloneJson(boardArray), teamPlaying, beats);
                            possibleBeats.Add(beats);
                        }
                        if (i + 2 <= 7 && j - 2 >= 0 &&
                            (boardArray[i + 1, j - 1] == CellState.WhitePiece || boardArray[i + 1, j - 1] == CellState.WhiteKing) &&
                            boardArray[i + 2, j - 2] == CellState.Empty)
                        {
                            var beats = new List <Move>
                            {
                                new Move
                                {
                                    StartingPoint = new Cell {
                                        X = i, Y = j
                                    },
                                    EndingPoint = new Cell {
                                        X = i + 2, Y = j - 2
                                    }
                                }
                            };

                            appendSubsequentBeats(Clone.CloneJson(boardArray), teamPlaying, beats);
                            possibleBeats.Add(beats);
                        }
                        if (i - 2 >= 0 && j - 2 >= 0 &&
                            (boardArray[i - 1, j - 1] == CellState.WhitePiece || boardArray[i - 1, j - 1] == CellState.WhiteKing) &&
                            boardArray[i - 2, j - 2] == CellState.Empty)
                        {
                            var beats = new List <Move>
                            {
                                new Move
                                {
                                    StartingPoint = new Cell {
                                        X = i, Y = j
                                    },
                                    EndingPoint = new Cell {
                                        X = i - 2, Y = j - 2
                                    }
                                }
                            };

                            appendSubsequentBeats(Clone.CloneJson(boardArray), teamPlaying, beats);
                            possibleBeats.Add(beats);
                        }
                    }
                }
            }

            possibleBeats.AddRange(PossibleKingsBeats.GetPossibleKingsBeats(boardArray, teamPlaying));

            return(possibleBeats.FindAll((possibleBeat) => possibleBeat.Count > 0));
        }