From fd55feee17ba5adef003356992c6b640fbebcb85 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 10 Jul 2016 10:09:06 +0200 Subject: [PATCH] [EMN] Added the missing multicolor cards. --- .../eldritchmoon/CampaignOfVengeance.java | 103 +++++++ .../mage/sets/eldritchmoon/SpellQueller.java | 174 ++++++++++++ .../eldritchmoon/TamiyoFieldResearcher.java | 265 ++++++++++++++++++ 3 files changed, 542 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/eldritchmoon/CampaignOfVengeance.java create mode 100644 Mage.Sets/src/mage/sets/eldritchmoon/SpellQueller.java create mode 100644 Mage.Sets/src/mage/sets/eldritchmoon/TamiyoFieldResearcher.java diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/CampaignOfVengeance.java b/Mage.Sets/src/mage/sets/eldritchmoon/CampaignOfVengeance.java new file mode 100644 index 00000000000..bb4043c9bfe --- /dev/null +++ b/Mage.Sets/src/mage/sets/eldritchmoon/CampaignOfVengeance.java @@ -0,0 +1,103 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.eldritchmoon; + +import java.util.UUID; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.effects.common.LoseLifeTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author LevelX2 + */ +public class CampaignOfVengeance extends CardImpl { + + public CampaignOfVengeance(UUID ownerId) { + super(ownerId, 182, "Campaign of Vengeance", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{B}"); + this.expansionSetCode = "EMN"; + + // Whenever a creature you control attacks, defending player loses 1 life and you gain 1 life. + this.addAbility(new CampaignOfVengeanceTriggeredAbility()); + } + + public CampaignOfVengeance(final CampaignOfVengeance card) { + super(card); + } + + @Override + public CampaignOfVengeance copy() { + return new CampaignOfVengeance(this); + } +} + +class CampaignOfVengeanceTriggeredAbility extends TriggeredAbilityImpl { + + public CampaignOfVengeanceTriggeredAbility() { + super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(1)); + this.addEffect(new GainLifeEffect(1)); + } + + public CampaignOfVengeanceTriggeredAbility(final CampaignOfVengeanceTriggeredAbility ability) { + super(ability); + } + + @Override + public CampaignOfVengeanceTriggeredAbility copy() { + return new CampaignOfVengeanceTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ATTACKER_DECLARED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent source = game.getPermanent(event.getSourceId()); + if (source != null && source.getControllerId().equals(controllerId)) { + UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(event.getSourceId(), game); + this.getEffects().get(0).setTargetPointer(new FixedTarget(defendingPlayerId)); + return true; + } + return false; + } + + @Override + public String getRule() { + return "Whenever a creature you control attacks, defending player loses 1 life and you gain 1 life."; + } +} diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/SpellQueller.java b/Mage.Sets/src/mage/sets/eldritchmoon/SpellQueller.java new file mode 100644 index 00000000000..3e40d16c2d3 --- /dev/null +++ b/Mage.Sets/src/mage/sets/eldritchmoon/SpellQueller.java @@ -0,0 +1,174 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.eldritchmoon; + +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.LeavesBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ReturnFromExileForSourceEffect; +import mage.abilities.keyword.FlashAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.filter.Filter; +import mage.filter.FilterSpell; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.ExileZone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.players.Player; +import mage.target.TargetSpell; +import mage.util.CardUtil; +import org.apache.log4j.Logger; + +/** + * + * @author LevelX2 + */ +public class SpellQueller extends CardImpl { + + private final static FilterSpell filter = new FilterSpell("spell with converted mana cost 4 or less"); + + static { + filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, 5)); + } + + public SpellQueller(UUID ownerId) { + super(ownerId, 189, "Spell Queller", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{W}{U}"); + this.expansionSetCode = "EMN"; + this.subtype.add("Spirit"); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + // Flash + this.addAbility(FlashAbility.getInstance()); + // Flying + this.addAbility(FlyingAbility.getInstance()); + // When Spell Queller enters the battlefied, exile target spell with converted mana cost 4 or less. + Ability ability1 = new EntersBattlefieldTriggeredAbility(new SpellQuellerEntersEffect(), false); + ability1.addTarget(new TargetSpell(filter)); + this.addAbility(ability1); + + // When Spell Queller leaves the battlefield, the exiled card's owner may cast that card without paying its mana cost. + Ability ability2 = new LeavesBattlefieldTriggeredAbility(new SpellQuellerLeavesEffect(), false); + this.addAbility(ability2); + } + + public SpellQueller(final SpellQueller card) { + super(card); + } + + @Override + public SpellQueller copy() { + return new SpellQueller(this); + } +} + +class SpellQuellerEntersEffect extends OneShotEffect { + + public SpellQuellerEntersEffect() { + super(Outcome.Benefit); + this.staticText = "exile target spell with converted mana cost 4 or less"; + } + + public SpellQuellerEntersEffect(final SpellQuellerEntersEffect effect) { + super(effect); + } + + @Override + public SpellQuellerEntersEffect copy() { + return new SpellQuellerEntersEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { + Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source)); + if (spell != null) { + UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()); + return controller.moveCardsToExile(spell, source, game, true, exileId, sourceObject.getIdName()); + } + return true; + } + return false; + } +} + +class SpellQuellerLeavesEffect extends OneShotEffect { + + public SpellQuellerLeavesEffect() { + super(Outcome.Benefit); + this.staticText = "the exiled card's owner may cast that card without paying its mana cost"; + } + + public SpellQuellerLeavesEffect(final SpellQuellerLeavesEffect effect) { + super(effect); + } + + @Override + public SpellQuellerLeavesEffect copy() { + return new SpellQuellerLeavesEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { + Permanent permanentLeftBattlefield = (Permanent) getValue("permanentLeftBattlefield"); + if (permanentLeftBattlefield == null) { + Logger.getLogger(ReturnFromExileForSourceEffect.class).error("Permanent not found: " + sourceObject.getName()); + return false; + } + ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), permanentLeftBattlefield.getZoneChangeCounter(game))); + if (exile != null) { // null is valid if source left battlefield before enters the battlefield effect resolved + Card card = exile.getCards(game).iterator().next(); + if (card != null) { + Player cardOwner = game.getPlayer(card.getOwnerId()); + if (cardOwner != null) { + if (cardOwner.chooseUse(Outcome.PlayForFree, "Cast " + card.getLogName() + " without paying cost?", source, game)) { + cardOwner.cast(card.getSpellAbility(), game, true); + } + } + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/TamiyoFieldResearcher.java b/Mage.Sets/src/mage/sets/eldritchmoon/TamiyoFieldResearcher.java new file mode 100644 index 00000000000..2e8464303c2 --- /dev/null +++ b/Mage.Sets/src/mage/sets/eldritchmoon/TamiyoFieldResearcher.java @@ -0,0 +1,265 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.eldritchmoon; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import mage.MageObject; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.CompoundCondition; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.SourceIsSpellCondition; +import mage.abilities.costs.AlternativeCostSourceAbility; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.GetEmblemEffect; +import mage.abilities.effects.common.TapTargetEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.SplitCardHalf; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.SubLayer; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.common.FilterNonlandCard; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.Game; +import mage.game.command.Emblem; +import mage.game.events.DamagedEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author LevelX2 + */ +public class TamiyoFieldResearcher extends CardImpl { + + private final static FilterPermanent filter = new FilterPermanent("nonland permanent"); + + static { + filter.add(Predicates.not(new CardTypePredicate(CardType.LAND))); + } + + public TamiyoFieldResearcher(UUID ownerId) { + super(ownerId, 190, "Tamiyo, Field Researcher", Rarity.MYTHIC, new CardType[]{CardType.PLANESWALKER}, "{1}{G}{W}{U}"); + this.expansionSetCode = "EMN"; + this.subtype.add("Tamiyo"); + + this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(4)); + + // +1: Choose up to two target creatures. Until your next turn, whenever either of those creatures deals combat damage, you draw a card. + Ability ability = new LoyaltyAbility(new TamiyoFieldResearcherEffect1(), 1); + ability.addTarget(new TargetCreaturePermanent(0, 2, new FilterCreaturePermanent("creatures"), false)); + this.addAbility(ability); + + // -2: Tap up to two target nonland permanents. They don't untap during their controller's next untap step. + ability = new LoyaltyAbility(new TapTargetEffect(), -2); + ability.addTarget(new TargetPermanent(0, 2, filter, false)); + ability.addEffect(new DontUntapInControllersNextUntapStepTargetEffect("They")); + this.addAbility(ability); + + // -7: Draw three cards. You get an emblem with "You may cast nonland cards from your hand without paying their mana costs." + ability = new LoyaltyAbility(new DrawCardSourceControllerEffect(3), -7); + ability.addEffect(new GetEmblemEffect(new TamiyoFieldResearcherEmblem())); + this.addAbility(ability); + } + + public TamiyoFieldResearcher(final TamiyoFieldResearcher card) { + super(card); + } + + @Override + public TamiyoFieldResearcher copy() { + return new TamiyoFieldResearcher(this); + } +} + +class TamiyoFieldResearcherEffect1 extends OneShotEffect { + + public TamiyoFieldResearcherEffect1() { + super(Outcome.PreventDamage); + this.staticText = "Choose up to two target creatures. Until your next turn, whenever either of those creatures deals combat damage, you draw a card"; + } + + public TamiyoFieldResearcherEffect1(final TamiyoFieldResearcherEffect1 effect) { + super(effect); + } + + @Override + public TamiyoFieldResearcherEffect1 copy() { + return new TamiyoFieldResearcherEffect1(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + ArrayList creatures = new ArrayList<>(); + for (UUID uuid : getTargetPointer().getTargets(game, source)) { + creatures.add(new MageObjectReference(uuid, game)); + } + if (!creatures.isEmpty()) { + DelayedTriggeredAbility delayedAbility = new TamiyoFieldResearcherDelayedTriggeredAbility(creatures); + game.addDelayedTriggeredAbility(delayedAbility, source); + } + return true; + } + return false; + } +} + +class TamiyoFieldResearcherDelayedTriggeredAbility extends DelayedTriggeredAbility { + + private List creatures; + + public TamiyoFieldResearcherDelayedTriggeredAbility(List creatures) { + super(new DrawCardSourceControllerEffect(1), Duration.UntilYourNextTurn); + this.creatures = creatures; + } + + public TamiyoFieldResearcherDelayedTriggeredAbility(final TamiyoFieldResearcherDelayedTriggeredAbility ability) { + super(ability); + this.creatures = ability.creatures; + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event instanceof DamagedEvent; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (((DamagedEvent) event).isCombatDamage()) { + Permanent damageSource = game.getPermanent(event.getSourceId()); + if (damageSource != null) { + return creatures.contains(new MageObjectReference(damageSource, game)); + } + } + return false; + } + + @Override + public TamiyoFieldResearcherDelayedTriggeredAbility copy() { + return new TamiyoFieldResearcherDelayedTriggeredAbility(this); + } + + @Override + public String getRule() { + return "Until your next turn, whenever either of those creatures deals combat damage, you draw a card."; + } +} + +class TamiyoFieldResearcherEmblem extends Emblem { + // You may cast nonland cards from your hand without paying their mana costs. + + public TamiyoFieldResearcherEmblem() { + + this.setName("EMBLEM: Tamiyo, Field Researcher"); + + this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new TamiyoFieldResearcherCastingEffect())); + } +} + +class TamiyoFieldResearcherCastingEffect extends ContinuousEffectImpl { + + public TamiyoFieldResearcherCastingEffect() { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + staticText = "You may cast nonland cards from your hand without paying their mana costs"; + } + + public TamiyoFieldResearcherCastingEffect(final TamiyoFieldResearcherCastingEffect effect) { + super(effect); + } + + @Override + public TamiyoFieldResearcherCastingEffect copy() { + return new TamiyoFieldResearcherCastingEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + controller.getAlternativeSourceCosts().add(new AlternativeCostSourceAbility( + null, new CompoundCondition(SourceIsSpellCondition.getInstance(), new IsBeingCastFromHandCondition()), null, new FilterNonlandCard(), true)); + return true; + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.RulesEffects; + } +} + +class IsBeingCastFromHandCondition implements Condition { + + @Override + public boolean apply(Game game, Ability source) { + MageObject object = game.getObject(source.getSourceId()); + if (object instanceof SplitCardHalf) { + UUID splitCardId = ((Card) object).getMainCard().getId(); + object = game.getObject(splitCardId); + } + if (object instanceof Spell) { // needed to check if it can be cast by alternate cost + Spell spell = (Spell) object; + return spell.getFromZone() == Zone.HAND; + } + if (object instanceof Card) { // needed for the check what's playable + Card card = (Card) object; + return game.getPlayer(card.getOwnerId()).getHand().get(card.getId(), game) != null; + } + return false; + } + +}