示例#1
0
        private static bool TestKingChecks(Dictionary <int, Dictionary <int, ChessPiece> > scenario)
        {
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (scenario[i][j]?.ToString() == GameState.PlayerTurn.ToString() + "King")
                    {
                        PieceColor enemy = GameState.PlayerTurn == PieceColor.Black ? enemy = PieceColor.White : enemy = PieceColor.Black;

                        if (HelperMaths.EnemyPawnCheck(i, j, scenario, enemy) || HelperMaths.HorizontalThreatCheck(i, j, scenario, enemy) ||
                            HelperMaths.DiagonalThreatCheck(i, j, scenario, enemy) || HelperMaths.VerticalThreatCheck(i, j, scenario, enemy) ||
                            HelperMaths.HorseThreatCheck(i, j, scenario, enemy))
                        {
                            return(true);
                        }
                        return(false);
                    }
                }
            }
            return(false);
        }