public static boolean gainLifeDoTriggerAI(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();

        // If the Target is gaining life, target self.
        // if the Target is modifying how much life is gained, this needs to be handled better
        Target tgt = sa.getTarget();
        if (tgt != null) {
            tgt.resetTargets();
            if (tgt.canOnlyTgtOpponent())
                tgt.addTarget(AllZone.getHumanPlayer());
            else
                tgt.addTarget(AllZone.getComputerPlayer());
        }

        Card source = sa.getSourceCard();
        String amountStr = params.get("LifeAmount");
        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));
        }

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

        return true;
    }