Implemented Jeweled Torque

This commit is contained in:
Evan Kranzler 2019-01-30 22:58:29 -05:00
parent 47d88e94ff
commit 67d999e5b0
2 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,71 @@
package mage.cards.j;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SpellCastAllTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterSpell;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class JeweledTorque extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a spell of the chosen color");
static {
filter.add(JeweledTorquePredicate.instance);
}
public JeweledTorque(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
// As Jeweled Torque enters the battlefield, choose a color.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Benefit)));
// Whenever a player casts a spell of the chosen color, you may pay {2}. If you do, you gain 2 life.
this.addAbility(new SpellCastAllTriggeredAbility(
new DoIfCostPaid(
new GainLifeEffect(2),
new GenericManaCost(2)
), filter, false
));
}
private JeweledTorque(final JeweledTorque card) {
super(card);
}
@Override
public JeweledTorque copy() {
return new JeweledTorque(this);
}
}
enum JeweledTorquePredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<MageObject>> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
Permanent permanent = game.getPermanent(input.getSourceId());
if (permanent == null) {
return false;
}
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
return color != null && input.getObject().getColor(game).shares(color);
}
}

View file

@ -175,6 +175,7 @@ public final class MercadianMasques extends ExpansionSet {
cards.add(new SetCardInfo("Island", 337, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Island", 338, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Ivory Mask", 24, Rarity.RARE, mage.cards.i.IvoryMask.class));
cards.add(new SetCardInfo("Jeweled Torque", 301, Rarity.UNCOMMON, mage.cards.j.JeweledTorque.class));
cards.add(new SetCardInfo("Jhovall Queen", 25, Rarity.RARE, mage.cards.j.JhovallQueen.class));
cards.add(new SetCardInfo("Jhovall Rider", 26, Rarity.UNCOMMON, mage.cards.j.JhovallRider.class));
cards.add(new SetCardInfo("Karn's Touch", 86, Rarity.RARE, mage.cards.k.KarnsTouch.class));