public EchecThreat PieceEchec(Case [,] board, Simulation sim, ChessMan Target, bool OneShotSimulation = false) { sim.Simulate(); EchecThreat threat = new EchecThreat(sim.targetCase.currPiece); foreach (ChessMan chess in m_sCase.Pieces) { if (sim.deletedBackup != null && sim.deletedBackup == chess) { continue; } if (chess.color != Target.color) { List <Case> moves = chess.GetPossibleMovement(board, false); foreach (Case c in moves) { //here it means if we have a possible movement case non null with the target on it if (c.currPiece != null && c.currPiece == Target) { threat.Add(chess); } } } } threat.SortThreats(); if (OneShotSimulation) { sim.Delete(); } return(threat.threater.Count > 0 ? threat : null); }
public EchecThreat PieceEchec(Case [,] board, ChessMan Target, ChessMan deleted = null) { if (Target == null) { return(null); } EchecThreat threat = new EchecThreat(Target); foreach (ChessMan chess in m_sCase.Pieces) { if (deleted != null && deleted == chess) { continue; } if (chess.color != Target.color) { List <Case> moves = chess.GetPossibleMovement(board, false); foreach (Case c in moves) { //here it means if we have a possible movement case non null with the ennemy king on it if (c.currPiece != null && c.currPiece == Target) { threat.Add(chess); } } } } threat.SortThreats(); return(threat.threater.Count > 0 ? threat : null); }