From d8f9c4b329e42e471feea48ddf32895331b83f56 Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 7 Aug 2018 15:39:01 -0500 Subject: [PATCH] - Added requested cards Damping Engine and Keeper of the Mind. --- Mage.Sets/src/mage/cards/d/DampingEngine.java | 215 ++++++++++++++++++ .../src/mage/cards/k/KeeperOfTheMind.java | 128 +++++++++++ Mage.Sets/src/mage/sets/Exodus.java | 3 +- Mage.Sets/src/mage/sets/UrzasLegacy.java | 1 + 4 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/d/DampingEngine.java create mode 100644 Mage.Sets/src/mage/cards/k/KeeperOfTheMind.java diff --git a/Mage.Sets/src/mage/cards/d/DampingEngine.java b/Mage.Sets/src/mage/cards/d/DampingEngine.java new file mode 100644 index 0000000000..2884c643d0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DampingEngine.java @@ -0,0 +1,215 @@ +/* + * 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.cards.d; + +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.SpecialAction; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetControlledPermanent; + +/** + * + * @author jeffwadsworth + */ +public class DampingEngine extends CardImpl { + + public DampingEngine(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); + + // A player who controls more permanents than each other player can't play lands or cast artifact, creature, or enchantment spells. That player may sacrifice a permanent for that player to ignore this effect until end of turn. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DampingEngineEffect())); + this.addAbility(new DampingEngineSpecialAction()); + + } + + public DampingEngine(final DampingEngine card) { + super(card); + } + + @Override + public DampingEngine copy() { + return new DampingEngine(this); + } +} + +class DampingEngineEffect extends ContinuousRuleModifyingEffectImpl { + + public DampingEngineEffect() { + super(Duration.WhileOnBattlefield, Outcome.AIDontUseIt); + staticText = "A player who controls more permanents than each other player can't play lands or cast artifact, creature, or enchantment spells" + + "That player may sacrifice a permanent for that player to ignore this effect until end of turn.

"; + } + + public DampingEngineEffect(final DampingEngineEffect effect) { + super(effect); + } + + @Override + public DampingEngineEffect copy() { + return new DampingEngineEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public String getInfoMessage(Ability source, GameEvent event, Game game) { + MageObject mageObject = game.getObject(source.getSourceId()); + if (mageObject != null) { + return "You can't play the land or cast the spell (" + mageObject.getName() + " in play)."; + } + return null; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.PLAY_LAND + || event.getType() == GameEvent.EventType.CAST_SPELL; + + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + Player player = game.getPlayer(event.getPlayerId()); + Permanent dampingEngine = game.getPermanent(source.getSourceId()); + final Card card = game.getCard(event.getSourceId()); + if (player != null + || card != null) { + // check type of spell + if (card.isCreature() + || card.isArtifact() + || card.isEnchantment() + || card.isLand()) { + // check to see if the player has more permanents + if (new ControlsMorePermanentsThanEachOtherPlayer(player).apply(game, source)) { + // check to see if the player choose to ignore the effect + if (game.getState().getValue("ignoreEffect") != null + && dampingEngine != null + && game.getState().getValue("ignoreEffect").equals + (dampingEngine.getId() + "ignoreEffect" + game.getState().getPriorityPlayerId() + game.getState().getTurnNum())) { + return false; + } + return true; + } + } + } + return false; + } +} + +class DampingEngineSpecialAction extends SpecialAction { + + public DampingEngineSpecialAction() { + super(Zone.BATTLEFIELD); + this.addCost(new SacrificeTargetCost(new TargetControlledPermanent(), true)); + this.addEffect(new DampingEngineIgnoreEffect()); + this.setMayActivate(TargetController.ANY); + } + + public DampingEngineSpecialAction(final DampingEngineSpecialAction ability) { + super(ability); + } + + @Override + public DampingEngineSpecialAction copy() { + return new DampingEngineSpecialAction(this); + } +} + +class DampingEngineIgnoreEffect extends OneShotEffect { + + public DampingEngineIgnoreEffect() { + super(Outcome.AIDontUseIt); + this.staticText = "That player may sacrifice a permanent for that player to ignore this effect until end of turn"; + } + + public DampingEngineIgnoreEffect(final DampingEngineIgnoreEffect effect) { + super(effect); + } + + @Override + public DampingEngineIgnoreEffect copy() { + return new DampingEngineIgnoreEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getSourceId()); + String key = permanent.getId() + "ignoreEffect" + game.getState().getPriorityPlayerId() + game.getState().getTurnNum(); + if (key != null) { + game.getState().setValue("ignoreEffect", key); + } + return true; + } +} + +class ControlsMorePermanentsThanEachOtherPlayer implements Condition { + + Player player; + + public ControlsMorePermanentsThanEachOtherPlayer(Player player) { + this.player = player; + } + + @Override + public boolean apply(Game game, Ability source) { + int numPermanents = game.getBattlefield().countAll(new FilterPermanent(), player.getId(), game); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + if (numPermanents > game.getBattlefield().countAll(new FilterPermanent(), playerId, game)) { + return true; + } + } + return false; + } + + @Override + public String toString() { + return "a player controls less permanents than you"; + } +} diff --git a/Mage.Sets/src/mage/cards/k/KeeperOfTheMind.java b/Mage.Sets/src/mage/cards/k/KeeperOfTheMind.java new file mode 100644 index 0000000000..087fe044f6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KeeperOfTheMind.java @@ -0,0 +1,128 @@ +/* + * 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.cards.k; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.FilterOpponent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetPlayer; +import mage.target.common.TargetOpponent; + +/** + * + * @author jeffwadsworth + */ +public class KeeperOfTheMind extends CardImpl { + + public final UUID originalId; + private static final FilterOpponent filter = new FilterOpponent(); + + static { + filter.add(new KeeperOfTheMindPredicate()); + } + + + public KeeperOfTheMind(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{U}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + // {U}, {tap}: Choose target opponent who had at least two more cards in hand than you did as you activated this ability. Draw a card. + Effect effect = new DrawCardSourceControllerEffect(1); + effect.setText("Choose target opponent who had at least two more cards in hand than you did as you activated this ability. Draw a card."); + Ability ability = new SimpleActivatedAbility(effect, new ManaCostsImpl("{U}")); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); + originalId = ability.getOriginalId(); + + } + + @Override + public void adjustTargets(Ability ability, Game game) { + if (ability.getOriginalId().equals(originalId)) { + Player activePlayer = game.getPlayer(game.getActivePlayerId()); + if (activePlayer != null) { + ability.getTargets().clear(); + TargetPlayer target = new TargetPlayer(1, 1, false, filter); + target.setTargetController(activePlayer.getId()); + ability.getTargets().add(target); + } + } + } + + public KeeperOfTheMind(final KeeperOfTheMind card) { + super(card); + this.originalId = card.originalId; + } + + @Override + public KeeperOfTheMind copy() { + return new KeeperOfTheMind(this); + } +} + +class KeeperOfTheMindPredicate implements ObjectSourcePlayerPredicate> { + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + Player targetPlayer = input.getObject(); + Player firstPlayer = game.getPlayer(game.getActivePlayerId()); + if (targetPlayer == null + || firstPlayer == null + || !firstPlayer.hasOpponent(targetPlayer.getId(), game)) { + return false; + } + int countHandTargetPlayer = targetPlayer.getHand().size(); + int countHandFirstPlayer = firstPlayer.getHand().size(); + + return countHandTargetPlayer - 2 >= countHandFirstPlayer; + } + + @Override + public String toString() { + return "opponent who had at least two more cards in hand than you did as you activated this ability"; + } +} diff --git a/Mage.Sets/src/mage/sets/Exodus.java b/Mage.Sets/src/mage/sets/Exodus.java index c80118de2c..d1091318d4 100644 --- a/Mage.Sets/src/mage/sets/Exodus.java +++ b/Mage.Sets/src/mage/sets/Exodus.java @@ -70,7 +70,8 @@ public final class Exodus extends ExpansionSet { cards.add(new SetCardInfo("Jackalope Herd", 111, Rarity.COMMON, mage.cards.j.JackalopeHerd.class)); cards.add(new SetCardInfo("Keeper of the Beasts", 112, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheBeasts.class)); cards.add(new SetCardInfo("Keeper of the Dead", 65, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheDead.class)); - cards.add(new SetCardInfo("Keeper of the Light", 8, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheLight.class)); + cards.add(new SetCardInfo("Keeper of the Light", 8, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheLight.class)); + cards.add(new SetCardInfo("Keeper of the Mind", 36, Rarity.UNCOMMON, mage.cards.k.KeeperOfTheMind.class)); cards.add(new SetCardInfo("Killer Whale", 37, Rarity.UNCOMMON, mage.cards.k.KillerWhale.class)); cards.add(new SetCardInfo("Kor Chant", 9, Rarity.COMMON, mage.cards.k.KorChant.class)); cards.add(new SetCardInfo("Mage il-Vec", 86, Rarity.COMMON, mage.cards.m.MageIlVec.class)); diff --git a/Mage.Sets/src/mage/sets/UrzasLegacy.java b/Mage.Sets/src/mage/sets/UrzasLegacy.java index f365c69045..eaa00b8c3c 100644 --- a/Mage.Sets/src/mage/sets/UrzasLegacy.java +++ b/Mage.Sets/src/mage/sets/UrzasLegacy.java @@ -46,6 +46,7 @@ public final class UrzasLegacy extends ExpansionSet { cards.add(new SetCardInfo("Cloud of Faeries", 29, Rarity.COMMON, mage.cards.c.CloudOfFaeries.class)); cards.add(new SetCardInfo("Crawlspace", 123, Rarity.RARE, mage.cards.c.Crawlspace.class)); cards.add(new SetCardInfo("Crop Rotation", 98, Rarity.COMMON, mage.cards.c.CropRotation.class)); + cards.add(new SetCardInfo("Damping Engine", 124, Rarity.RARE, mage.cards.d.DampingEngine.class)); cards.add(new SetCardInfo("Darkwatch Elves", 99, Rarity.UNCOMMON, mage.cards.d.DarkwatchElves.class)); cards.add(new SetCardInfo("Defender of Chaos", 75, Rarity.COMMON, mage.cards.d.DefenderOfChaos.class)); cards.add(new SetCardInfo("Defender of Law", 5, Rarity.COMMON, mage.cards.d.DefenderOfLaw.class));