isTrapped method
is trapped 是否困毙
Implementation
bool isTrapped(int team) {
List<ChessItem> pieces = fen.getAll();
return !pieces.any((item) {
if (item.team == team) {
List<String> points = movePoints(item.position);
return points.any((point) {
ChessRule rule = ChessRule(fen.copy());
rule.fen.move(item.position.toCode() + point);
if (rule.isKingMeet(team)) {
return false;
}
if (rule.isCheck(team)) {
return false;
}
return true;
});
}
return false;
});
}