public static boolean loseLifeDoTriggerAI(AbilityFactory af, SpellAbility sa, boolean mandatory) {
        if (!ComputerUtil.canPayCost(sa) && !mandatory)    // If there is a cost payment it's usually not mandatory
            return false;

        HashMap<String, String> params = af.getMapParams();

        Target tgt = sa.getTarget();
        if (tgt != null) {
            tgt.addTarget(AllZone.getHumanPlayer());
        }

        Card source = sa.getSourceCard();
        String amountStr = params.get("LifeAmount");
        int amount = 0;
        if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
            // Set PayX here to maximum value.
            int xPay = ComputerUtil.determineLeftoverMana(sa);
            source.setSVar("PayX", Integer.toString(xPay));
            amount = xPay;
        } else
            amount = AbilityFactory.calculateAmount(source, amountStr, sa);

        ArrayList<Player> tgtPlayers;
        if (tgt != null)
            tgtPlayers = tgt.getTargetPlayers();
        else
            tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa);


        if (tgtPlayers.contains(AllZone.getComputerPlayer())) {
            // For cards like Foul Imp, ETB you lose life
            if (amount + 3 > AllZone.getComputerPlayer().getLife())
                return false;
        }

        // check SubAbilities DoTrigger?
        Ability_Sub abSub = sa.getSubAbility();
        if (abSub != null) {
            return abSub.doTrigger(mandatory);
        }

        return true;
    }