Search in sources :

Example 1 with FilterPermanentOrPlayer

use of mage.filter.common.FilterPermanentOrPlayer in project mage by magefree.

the class PreventAllDamageToAllEffect method createFilter.

private static FilterPermanentOrPlayer createFilter(FilterPermanent filterPermanent, FilterPlayer filterPlayer) {
    String mes1 = filterPermanent != null ? filterPermanent.getMessage() : "";
    String mes2 = filterPlayer != null ? filterPlayer.getMessage() : "";
    String message;
    if (!mes1.isEmpty() && !mes2.isEmpty()) {
        message = mes1 + " and " + mes2;
    } else {
        message = mes1 + mes2;
    }
    FilterPermanent filter1 = filterPermanent;
    if (filter1 == null) {
        filter1 = new FilterPermanent();
        // disable filter
        filter1.add(new PermanentIdPredicate(UUID.randomUUID()));
    }
    FilterPlayer filter2 = filterPlayer;
    if (filter2 == null) {
        filter2 = new FilterPlayer();
        // disable filter
        filter2.add(new PlayerIdPredicate(UUID.randomUUID()));
    }
    return new FilterPermanentOrPlayer(message, filter1, filter2);
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) FilterPermanentOrPlayer(mage.filter.common.FilterPermanentOrPlayer) FilterPermanent(mage.filter.FilterPermanent) FilterPlayer(mage.filter.FilterPlayer) PlayerIdPredicate(mage.filter.predicate.other.PlayerIdPredicate)

Aggregations

FilterPermanent (mage.filter.FilterPermanent)1 FilterPlayer (mage.filter.FilterPlayer)1 FilterPermanentOrPlayer (mage.filter.common.FilterPermanentOrPlayer)1 PlayerIdPredicate (mage.filter.predicate.other.PlayerIdPredicate)1 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)1