From 1ba5dbda973118c1e59fad2b830a413c5042691c Mon Sep 17 00:00:00 2001 From: LoneFox Date: Mon, 3 Aug 2015 16:06:25 +0300 Subject: [PATCH] Implement cards: Dralnu's Pet, Malicious Advice, and Mask of Intolerance --- .../sets/apocalypse/MaskOfIntolerance.java | 82 +++++++++++ .../src/mage/sets/planeshift/DralnusPet.java | 132 ++++++++++++++++++ .../mage/sets/planeshift/MaliciousAdvice.java | 91 ++++++++++++ .../dynamicvalue/common/DomainValue.java | 12 +- 4 files changed, 316 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/sets/apocalypse/MaskOfIntolerance.java create mode 100644 Mage.Sets/src/mage/sets/planeshift/DralnusPet.java create mode 100644 Mage.Sets/src/mage/sets/planeshift/MaliciousAdvice.java diff --git a/Mage.Sets/src/mage/sets/apocalypse/MaskOfIntolerance.java b/Mage.Sets/src/mage/sets/apocalypse/MaskOfIntolerance.java new file mode 100644 index 00000000000..5a5cebcb196 --- /dev/null +++ b/Mage.Sets/src/mage/sets/apocalypse/MaskOfIntolerance.java @@ -0,0 +1,82 @@ +/* + * 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.apocalypse; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbility; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.condition.IntCompareCondition; +import mage.abilities.decorator.ConditionalTriggeredAbility; +import mage.abilities.dynamicvalue.common.DomainValue; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.game.Game; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author LoneFox + */ +public class MaskOfIntolerance extends CardImpl { + + public MaskOfIntolerance(UUID ownerId) { + super(ownerId, 138, "Mask of Intolerance", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{2}"); + this.expansionSetCode = "APC"; + + // At the beginning of each player's upkeep, if there are four or more basic land types among lands that player controls, Mask of Intolerance deals 3 damage to him or her. + TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3), TargetController.ANY, false); + this.addAbility(new ConditionalTriggeredAbility(ability, new MaskOfIntoleranceCondition(), + "At the beginning of each player's upkeep, if there are four or more basic land types among lands that player controls, Mask of Intolerance deals 3 damage to him or her.")); + } + + public MaskOfIntolerance(final MaskOfIntolerance card) { + super(card); + } + + @Override + public MaskOfIntolerance copy() { + return new MaskOfIntolerance(this); + } +} + +class MaskOfIntoleranceCondition extends IntCompareCondition { + + public MaskOfIntoleranceCondition() { + super(ComparisonType.GreaterThan, 3); + } + + @Override + protected int getInputValue(Game game, Ability source) { + return new DomainValue(1, game.getActivePlayerId()).calculate(game, source, null); + } +} diff --git a/Mage.Sets/src/mage/sets/planeshift/DralnusPet.java b/Mage.Sets/src/mage/sets/planeshift/DralnusPet.java new file mode 100644 index 00000000000..11e62798662 --- /dev/null +++ b/Mage.Sets/src/mage/sets/planeshift/DralnusPet.java @@ -0,0 +1,132 @@ +/* + * 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.planeshift; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.condition.common.KickedCondition; +import mage.abilities.costs.Cost; +import mage.abilities.costs.Costs; +import mage.abilities.costs.CostsImpl; +import mage.abilities.costs.common.DiscardCardCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.EntersBattlefieldEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.KickerAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.counters.CounterType; +import mage.filter.common.FilterCreatureCard; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author LoneFox + * @author LevelX + */ +public class DralnusPet extends CardImpl { + + public DralnusPet(UUID ownerId) { + super(ownerId, 23, "Dralnu's Pet", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{U}{U}"); + this.expansionSetCode = "PLS"; + this.subtype.add("Shapeshifter"); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Kicker-{2}{B}, Discard a creature card. + Costs kickerCosts = new CostsImpl<>(); + kickerCosts.add(new ManaCostsImpl<>("{2}{B}")); + kickerCosts.add(new DiscardCardCost(new FilterCreatureCard())); + this.addAbility(new KickerAbility(kickerCosts)); + // If Dralnu's Pet was kicked, it enters the battlefield with flying and with X +1/+1 counters on it, where X is the discarded card's converted mana cost. + Ability ability = new EntersBattlefieldAbility(new DralnusPetEffect(), KickedCondition.getInstance(), true, + "If {this} was kicked, it enters the battlefield with flying and with X +1/+1 counters on it, where X is the discarded card's converted mana cost", ""); + ability.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.WhileOnBattlefield)); + this.addAbility(ability); + } + + public DralnusPet(final DralnusPet card) { + super(card); + } + + @Override + public DralnusPet copy() { + return new DralnusPet(this); + } +} + +class DralnusPetEffect extends OneShotEffect { + + public DralnusPetEffect() { + super(Outcome.BoostCreature); + this.staticText = "and with X +1/+1 counters on it, where X is the discarded card's converted mana cost"; + } + + public DralnusPetEffect(final DralnusPetEffect effect) { + super(effect); + } + + @Override + public DralnusPetEffect copy() { + return new DralnusPetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(source.getSourceId()); + if (controller != null && permanent != null) { + Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); + if (obj != null && obj instanceof SpellAbility) { + int cmc = 0; + for (Cost cost : ((SpellAbility) obj).getCosts()) { + if (cost instanceof DiscardCardCost && ((DiscardCardCost) cost).getCards().size() > 0) { + cmc = ((DiscardCardCost) cost).getCards().get(0).getManaCost().convertedManaCost(); + } + if (cmc > 0) { + return new AddCountersSourceEffect(CounterType.P1P1.createInstance(cmc), true).apply(game, source); + } + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/planeshift/MaliciousAdvice.java b/Mage.Sets/src/mage/sets/planeshift/MaliciousAdvice.java new file mode 100644 index 00000000000..9633c1f4193 --- /dev/null +++ b/Mage.Sets/src/mage/sets/planeshift/MaliciousAdvice.java @@ -0,0 +1,91 @@ +/* + * 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.planeshift; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.LoseLifeSourceControllerEffect; +import mage.abilities.effects.common.TapTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.Game; +import mage.target.TargetPermanent; + +/** + * + * @author LoneFox + */ +public class MaliciousAdvice extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent("artifacts, creatures, and/or lands"); + + static { + filter.add(Predicates.or( + new CardTypePredicate(CardType.ARTIFACT), + new CardTypePredicate(CardType.CREATURE), + new CardTypePredicate(CardType.LAND))); + } + + public MaliciousAdvice(UUID ownerId) { + super(ownerId, 114, "Malicious Advice", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{X}{U}{B}"); + this.expansionSetCode = "PLS"; + + // Tap X target artifacts, creatures, and/or lands. You lose X life. + Effect effect = new TapTargetEffect(); + effect.setText("Tap X target artifacts, creatures, and/or lands"); + this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(new ManacostVariableValue())); + // Correct number of targets will be set in adjustTargets + // I'm not sure if/why this needs to be here, but other such cards do have it... + this.getSpellAbility().addTarget(new TargetPermanent(filter)); + } + + @Override + public void adjustTargets(Ability ability, Game game) { + if(ability instanceof SpellAbility) { + ability.getTargets().clear(); + ability.addTarget(new TargetPermanent(ability.getManaCostsToPay().getX(), filter)); + } + } + + public MaliciousAdvice(final MaliciousAdvice card) { + super(card); + } + + @Override + public MaliciousAdvice copy() { + return new MaliciousAdvice(this); + } +} diff --git a/Mage/src/mage/abilities/dynamicvalue/common/DomainValue.java b/Mage/src/mage/abilities/dynamicvalue/common/DomainValue.java index ca8f4f68cc9..9d021891669 100644 --- a/Mage/src/mage/abilities/dynamicvalue/common/DomainValue.java +++ b/Mage/src/mage/abilities/dynamicvalue/common/DomainValue.java @@ -15,6 +15,7 @@ public class DomainValue implements DynamicValue { private Integer amount; private boolean countTargetPlayer; + private UUID player; public DomainValue() { this(1); @@ -33,9 +34,15 @@ public class DomainValue implements DynamicValue { this.countTargetPlayer = countTargetPlayer; } + public DomainValue(Integer amount, UUID player) { + this(amount, false); + this.player = player; + } + public DomainValue(final DomainValue dynamicValue) { this.amount = dynamicValue.amount; this.countTargetPlayer = dynamicValue.countTargetPlayer; + this.player = dynamicValue.player; } @Override @@ -46,7 +53,10 @@ public class DomainValue implements DynamicValue { int haveSwamps = 0; int haveForests = 0; UUID targetPlayer; - if (countTargetPlayer) { + if(player != null) { + targetPlayer = player; + } + else if(countTargetPlayer) { targetPlayer = sourceAbility.getTargets().getFirstTarget(); } else { targetPlayer = sourceAbility.getControllerId();