mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
extracted duplicate AttachmentAttachedToCardTypePredicate
This commit is contained in:
parent
8b90f87af6
commit
e44b2fd673
3 changed files with 33 additions and 52 deletions
|
|
@ -40,8 +40,8 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.common.FilterEnchantmentPermanent;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.AttachmentAttachedToCardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||
import mage.game.Game;
|
||||
|
|
@ -85,31 +85,6 @@ public class CrownOfTheAges extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class AttachmentAttachedToCardTypePredicate implements Predicate<Permanent> {
|
||||
|
||||
private final CardType cardType;
|
||||
|
||||
public AttachmentAttachedToCardTypePredicate(CardType cardType) {
|
||||
this.cardType = cardType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
if (input.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(input.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getCardType().contains(cardType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AttachmentAttachedToCardType(" + cardType + ')';
|
||||
}
|
||||
}
|
||||
|
||||
class CrownOfTheAgesEffect extends OneShotEffect {
|
||||
|
||||
public CrownOfTheAgesEffect() {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.SuperType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterEnchantmentPermanent;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.mageobject.AttachmentAttachedToCardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -113,31 +113,6 @@ class AutumnTailKitsuneSage extends Token {
|
|||
}
|
||||
}
|
||||
|
||||
class AttachmentAttachedToCardTypePredicate implements Predicate<Permanent> {
|
||||
|
||||
private final CardType cardType;
|
||||
|
||||
public AttachmentAttachedToCardTypePredicate(CardType cardType) {
|
||||
this.cardType = cardType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
if (input.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(input.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getCardType().contains(cardType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AttachmentAttachedToCardType(" + cardType + ')';
|
||||
}
|
||||
}
|
||||
|
||||
class AutumnTailEffect extends OneShotEffect {
|
||||
|
||||
public AutumnTailEffect() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package mage.filter.predicate.mageobject;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
public class AttachmentAttachedToCardTypePredicate implements Predicate<Permanent> {
|
||||
|
||||
private final CardType cardType;
|
||||
|
||||
public AttachmentAttachedToCardTypePredicate(CardType cardType) {
|
||||
this.cardType = cardType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
if (input.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(input.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getCardType().contains(cardType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AttachmentAttachedToCardType(" + cardType + ')';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue