itemCanCheck method

bool itemCanCheck(
  1. ChessPos pos,
  2. int team
)

检查某个子是否能将军

Implementation

bool itemCanCheck(ChessPos pos, int team) {
  ChessPos? kPos = fen.find(team == 0 ? 'k' : 'K');
  if (kPos == null) return true;
  List<String> points = movePoints(pos, kPos);
  return points.any((point) {
    ChessFen newFen = fen.copy();
    newFen.move(pos.toCode() + point);
    return ChessRule(newFen).isCheck(team == 0 ? 1 : 0);
  });
}