getBeEatList method

List<ChessItem> getBeEatList(
  1. ChessPos pos
)

获取被吃子的列表

Implementation

List<ChessItem> getBeEatList(ChessPos pos) {
  List<ChessItem> items = [];
  List<ChessItem> pieces = fen.getAll();
  String chr = fen[pos.y][pos.x];
  ChessItem curChess = ChessItem(chr, position: pos);
  for (var item in pieces) {
    if (item.team != curChess.team) {
      List<String> points = movePoints(item.position, pos);
      if (points.contains(pos.toCode())) {
        items.add(item);
      }
    }
  }
  items.sort(
    (a, b) => chessWeight[b.code.toLowerCase()]!
        .compareTo(chessWeight[a.code.toLowerCase()]!),
  );
  return items;
}