private static void rearrangeTopOfLibraryResolve(final AbilityFactory af, final SpellAbility sa) {
        HashMap<String, String> params = af.getMapParams();
        int numCards = 0;
        ArrayList<Player> tgtPlayers = new ArrayList<Player>();
        boolean shuffle = false;

        if (sa.getActivatingPlayer().isHuman()) {
            Target tgt = af.getAbTgt();
            if (tgt != null && !params.containsKey("Defined"))
                tgtPlayers = tgt.getTargetPlayers();
            else
                tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);

            numCards = AbilityFactory.calculateAmount(af.getHostCard(), params.get("NumCards"), sa);
            shuffle = params.containsKey("MayShuffle") ? true : false;

            for (Player p : tgtPlayers)
                if (tgt == null || p.canTarget(af.getHostCard()))
                    rearrangeTopOfLibrary(af.getHostCard(), p, numCards, shuffle);
        }
    }