[FUT] reworked Daybreak Coronet

This commit is contained in:
Evan Kranzler 2022-02-24 17:26:22 -05:00
parent 3cbfe4d623
commit 48d139393d
2 changed files with 47 additions and 49 deletions

View file

@ -1,12 +1,7 @@
package mage.cards.d; package mage.cards.d;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect; import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
@ -17,44 +12,54 @@ import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicate; import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
/** /**
*
* @author jeffwadsworth * @author jeffwadsworth
*/ */
public final class DaybreakCoronet extends CardImpl { public final class DaybreakCoronet extends CardImpl {
private static final FilterPermanent filter
= new FilterCreaturePermanent("creature with another Aura attached to it");
static {
filter.add(AuraAttachedPredicate.instance);
}
public DaybreakCoronet(UUID ownerId, CardSetInfo setInfo) { public DaybreakCoronet(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}{W}");
this.subtype.add(SubType.AURA); this.subtype.add(SubType.AURA);
// Enchant creature with another Aura attached to it // Enchant creature with another Aura attached to it
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with another Aura attached to it."); TargetPermanent auraTarget = new TargetPermanent(filter);
filter.add(new AuraAttachedPredicate(this.getId()));
TargetPermanent auraTarget = new TargetCreaturePermanent(filter);
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
this.addAbility(ability);
// Enchanted creature gets +3/+3 and has first strike, vigilance, and lifelink. // Enchanted creature gets +3/+3 and has first strike, vigilance, and lifelink.
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(3, 3, Duration.WhileOnBattlefield)); Ability ability = new SimpleStaticAbility(new BoostEnchantedEffect(
Effect effect = new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.AURA); 3, 3, Duration.WhileOnBattlefield
effect.setText("and has first strike"); ));
ability.addEffect(effect); ability.addEffect(new GainAbilityAttachedEffect(
effect = new GainAbilityAttachedEffect(VigilanceAbility.getInstance(), AttachmentType.AURA); FirstStrikeAbility.getInstance(), AttachmentType.AURA
effect.setText(", vigilance"); ).setText("and has first strike"));
ability.addEffect(effect); ability.addEffect(new GainAbilityAttachedEffect(
effect = new GainAbilityAttachedEffect(LifelinkAbility.getInstance(), AttachmentType.AURA); VigilanceAbility.getInstance(), AttachmentType.AURA
effect.setText(", and lifelink"); ).setText(", vigilance"));
ability.addEffect(effect); ability.addEffect(new GainAbilityAttachedEffect(
LifelinkAbility.getInstance(), AttachmentType.AURA
).setText(", and lifelink"));
this.addAbility(ability); this.addAbility(ability);
} }
@ -68,28 +73,21 @@ public final class DaybreakCoronet extends CardImpl {
} }
} }
class AuraAttachedPredicate implements Predicate<Permanent> { enum AuraAttachedPredicate implements ObjectSourcePlayerPredicate<Permanent> {
instance;
private final UUID ownId;
public AuraAttachedPredicate(UUID ownId) {
this.ownId = ownId;
}
@Override @Override
public boolean apply(Permanent input, Game game) { public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
List<UUID> attachments = new LinkedList(); List<UUID> attachments = new LinkedList<>();
attachments.addAll(input.getAttachments()); attachments.addAll(input.getObject().getAttachments());
for (UUID uuid : attachments) { return input
if (!uuid.equals(ownId)) { .getObject()
Permanent attachment = game.getPermanent(uuid); .getAttachments()
if (attachment != null .stream()
&& attachment.hasSubtype(SubType.AURA, game)) { .filter(uuid -> !uuid.equals(input.getSourceId()))
return true; .map(game::getPermanent)
} .filter(Objects::nonNull)
} .anyMatch(permanent -> permanent.hasSubtype(SubType.AURA, game));
}
return false;
} }
@Override @Override

View file

@ -2386,8 +2386,8 @@ public abstract class GameImpl implements Game {
} }
} else { } else {
Filter auraFilter = spellAbility.getTargets().get(0).getFilter(); Filter auraFilter = spellAbility.getTargets().get(0).getFilter();
if (auraFilter instanceof FilterControlledPermanent) { if (auraFilter instanceof FilterPermanent) {
if (!((FilterControlledPermanent) auraFilter).match(attachedTo, perm.getId(), perm.getControllerId(), this) if (!((FilterPermanent) auraFilter).match(attachedTo, perm.getId(), perm.getControllerId(), this)
|| attachedTo.cantBeAttachedBy(perm, null, this, true)) { || attachedTo.cantBeAttachedBy(perm, null, this, true)) {
if (movePermanentToGraveyardWithInfo(perm)) { if (movePermanentToGraveyardWithInfo(perm)) {
somethingHappened = true; somethingHappened = true;