mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
extracted duplicate AttachmentAttachedToCardTypePredicate
This commit is contained in:
parent
8b90f87af6
commit
e44b2fd673
3 changed files with 33 additions and 52 deletions
|
|
@ -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