[ONC] Implement Glimmer Lens

This commit is contained in:
PurpleCrowbar 2023-02-12 14:36:59 +00:00
parent a5d53cdb5d
commit 2a40a08ae2
2 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,84 @@
package mage.cards.g;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.ForMirrodinAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import java.util.Objects;
import java.util.UUID;
/**
* @author PurpleCrowbar
*/
public final class GlimmerLens extends CardImpl {
public GlimmerLens(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{W}");
this.subtype.add(SubType.EQUIPMENT);
// For Mirrodin!
this.addAbility(new ForMirrodinAbility());
// Whenever equipped creature and at least one other creature attack, draw a card.
this.addAbility(new GlimmerLensTriggeredAbility());
// Equip {1}{W}
this.addAbility(new EquipAbility(Outcome.BoostCreature, new ManaCostsImpl<>("{1}{W}")));
}
private GlimmerLens(final GlimmerLens card) {
super(card);
}
@Override
public GlimmerLens copy() {
return new GlimmerLens(this);
}
}
class GlimmerLensTriggeredAbility extends TriggeredAbilityImpl {
GlimmerLensTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1));
setTriggerPhrase("Whenever equipped creature and at least one other creature attack, ");
}
private GlimmerLensTriggeredAbility(final GlimmerLensTriggeredAbility ability) {
super(ability);
}
@Override
public GlimmerLensTriggeredAbility copy() {
return new GlimmerLensTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent attachment = getSourcePermanentOrLKI(game);
UUID equippedCreature = attachment.getAttachedTo();
return game.getCombat().getAttackers().contains(equippedCreature)
&& game
.getCombat()
.getAttackers()
.stream()
.filter(uuid -> !equippedCreature.equals(uuid))
.map(game::getPermanent)
.anyMatch(Objects::nonNull);
}
}

View file

@ -62,6 +62,8 @@ public final class PhyrexiaAllWillBeOneCommander extends ExpansionSet {
cards.add(new SetCardInfo("Furycalm Snarl", 155, Rarity.RARE, mage.cards.f.FurycalmSnarl.class));
cards.add(new SetCardInfo("Generous Gift", 70, Rarity.UNCOMMON, mage.cards.g.GenerousGift.class));
cards.add(new SetCardInfo("Ghostly Prison", 71, Rarity.UNCOMMON, mage.cards.g.GhostlyPrison.class));
cards.add(new SetCardInfo("Glimmer Lens", 6, Rarity.RARE, mage.cards.g.GlimmerLens.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Glimmer Lens", 44, Rarity.RARE, mage.cards.g.GlimmerLens.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Glistening Sphere", 20, Rarity.RARE, mage.cards.g.GlisteningSphere.class));
cards.add(new SetCardInfo("Goldnight Commander", 72, Rarity.UNCOMMON, mage.cards.g.GoldnightCommander.class));
cards.add(new SetCardInfo("Golgari Signet", 131, Rarity.UNCOMMON, mage.cards.g.GolgariSignet.class));