public static bool needAttack(Draught d, List <Draught> list) { List <Position> listPos = d.getAttackMoves(); foreach (Draught dr in list) { foreach (Position p in listPos) { if (dr != d && dr.isBlack() != d.isBlack() && dr.isMyPosition(p) && canAttack(d, p, list)) { return(true); } } } return(false); }
private int attack(Draught d, List <Draught> list) { List <Position> pos = d.getAttackMoves(); foreach (Position p in pos) { if (Arbiter.canAttack(d, p, list)) { Position to = new Position(); to.x = p.x - d.getPosition().x > 0 ? p.x + 1 : p.x - 1; to.y = p.y - d.getPosition().y > 0 ? p.y + 1 : p.y - 1; List <Draught> newList = copyList(list); newList.Remove(Arbiter.findDraught(p, newList)); Arbiter.findDraught(d.getPosition(), newList).moveTo(to); return(POINTS_FOR_EAT + (Arbiter.findDraught(to, newList).isKing() != d.isKing()?POINTS_FOR_KING:0) + attack(Arbiter.findDraught(to, newList), newList)); } } return(checkDraught(d.getPosition(), list)); }