mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 12:49:39 -08:00
some more refactoring
This commit is contained in:
parent
7d33b2230d
commit
c07b9680bd
18 changed files with 302 additions and 391 deletions
|
|
@ -5,11 +5,11 @@ import mage.abilities.Mode;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.SharesNamePredicate;
|
||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -36,12 +36,11 @@ public class DestroyAllNamedPermanentsEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
FilterPermanent filter = new FilterPermanent();
|
||||
if (CardUtil.haveEmptyName(targetPermanent)) {
|
||||
filter.add(new PermanentIdPredicate(targetPermanent.getId())); // if no name (face down creature) only the creature itself is selected
|
||||
} else {
|
||||
filter.add(new NamePredicate(targetPermanent.getName()));
|
||||
}
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
||||
filter.add(Predicates.or(
|
||||
new SharesNamePredicate(targetPermanent),
|
||||
new PermanentIdPredicate(targetPermanent.getId())
|
||||
));
|
||||
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||
perm.destroy(source, game, false);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import mage.cards.CardsImpl;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.filter.predicate.mageobject.SharesNamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
|
|
@ -94,9 +94,8 @@ class RippleEffect extends OneShotEffect {
|
|||
player.revealCards(sourceObject.getIdName(), cards, game);
|
||||
|
||||
// determine which card should be rippled
|
||||
String cardNameToRipple = sourceObject.getName();
|
||||
FilterCard sameNameFilter = new FilterCard("card(s) with the name: \"" + cardNameToRipple + "\" to cast without paying their mana cost");
|
||||
sameNameFilter.add(new NamePredicate(cardNameToRipple));
|
||||
FilterCard sameNameFilter = new FilterCard("card(s) to cast without paying their mana cost");
|
||||
sameNameFilter.add(new SharesNamePredicate(sourceObject));
|
||||
TargetCard target1 = new TargetCard(Zone.LIBRARY, sameNameFilter);
|
||||
target1.setRequired(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package mage.filter.predicate.mageobject;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class SharesNamePredicate implements Predicate<MageObject> {
|
||||
|
||||
private final MageObject mageObject;
|
||||
|
||||
public SharesNamePredicate(MageObject mageObject) {
|
||||
this.mageObject = mageObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(MageObject input, Game game) {
|
||||
return input.sharesName(mageObject, game);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue