From c4deaf325014715e34d226fcc54ff0594a37fbda Mon Sep 17 00:00:00 2001 From: emerald000 Date: Fri, 24 Jul 2015 03:32:31 -0400 Subject: [PATCH] Added Peer Pressure, Terraformer and Wave of Indifference. --- .../src/mage/sets/onslaught/PeerPressure.java | 132 ++++++++++++ .../sets/onslaught/WaveOfIndifference.java | 76 +++++++ .../src/mage/sets/ravnica/Terraformer.java | 190 ++++++++++++++++++ .../mage/sets/shadowmoor/ElsewhereFlask.java | 17 +- .../common/ChooseCreatureTypeEffect.java | 3 +- 5 files changed, 413 insertions(+), 5 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/onslaught/PeerPressure.java create mode 100644 Mage.Sets/src/mage/sets/onslaught/WaveOfIndifference.java create mode 100644 Mage.Sets/src/mage/sets/ravnica/Terraformer.java diff --git a/Mage.Sets/src/mage/sets/onslaught/PeerPressure.java b/Mage.Sets/src/mage/sets/onslaught/PeerPressure.java new file mode 100644 index 00000000000..af01dc3a377 --- /dev/null +++ b/Mage.Sets/src/mage/sets/onslaught/PeerPressure.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.onslaught; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.cards.CardImpl; +import mage.cards.repository.CardRepository; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author emerald000 + */ +public class PeerPressure extends CardImpl { + + public PeerPressure(UUID ownerId) { + super(ownerId, 101, "Peer Pressure", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{U}"); + this.expansionSetCode = "ONS"; + + // Choose a creature type. If you control more creatures of that type than each other player, you gain control of all creatures of that type. + this.getSpellAbility().addEffect(new PeerPressureEffect()); + } + + public PeerPressure(final PeerPressure card) { + super(card); + } + + @Override + public PeerPressure copy() { + return new PeerPressure(this); + } +} + +class PeerPressureEffect extends OneShotEffect { + + PeerPressureEffect() { + super(Outcome.GainControl); + this.staticText = "Choose a creature type. If you control more creatures of that type than each other player, you gain control of all creatures of that type"; + } + + PeerPressureEffect(final PeerPressureEffect effect) { + super(effect); + } + + @Override + public PeerPressureEffect copy() { + return new PeerPressureEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Choice choice = new ChoiceImpl(true); + choice.setMessage("Choose creature type"); + choice.setChoices(CardRepository.instance.getCreatureTypes()); + while (!controller.choose(Outcome.GainControl, choice, game)) { + if (!controller.isInGame()) { + return false; + } + } + String chosenType = choice.getChoice(); + if (!game.isSimulation()) { + game.informPlayers(controller.getLogName() + " has chosen " + chosenType); + } + UUID playerWithMost = null; + int maxControlled = 0; + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + FilterPermanent filter = new FilterCreaturePermanent(chosenType, chosenType); + filter.add(new ControllerIdPredicate(playerId)); + int controlled = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this); + if (controlled > maxControlled) { + maxControlled = controlled; + playerWithMost = playerId; + } else if (controlled == maxControlled) { + playerWithMost = null; // Do nothing in case of tie + } + } + if (playerWithMost != null && playerWithMost.equals(controller.getId())) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(chosenType, chosenType), controller.getId(), source.getSourceId(), game)) { + ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame); + effect.setTargetPointer(new FixedTarget(permanent.getId())); + game.addEffect(effect, source); + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/onslaught/WaveOfIndifference.java b/Mage.Sets/src/mage/sets/onslaught/WaveOfIndifference.java new file mode 100644 index 00000000000..6376ddddbe4 --- /dev/null +++ b/Mage.Sets/src/mage/sets/onslaught/WaveOfIndifference.java @@ -0,0 +1,76 @@ +/* + * 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.onslaught; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.combat.CantBlockTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author emerald000 + */ +public class WaveOfIndifference extends CardImpl { + + public WaveOfIndifference(UUID ownerId) { + super(ownerId, 243, "Wave of Indifference", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{X}{R}"); + this.expansionSetCode = "ONS"; + + // X target creatures can't block this turn. + Effect effect = new CantBlockTargetEffect(Duration.EndOfTurn); + effect.setText("X target creatures can't block this turn"); + this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1, new FilterCreaturePermanent(), false)); + } + + public WaveOfIndifference(final WaveOfIndifference card) { + super(card); + } + + @Override + public void adjustTargets(Ability ability, Game game) { + if (ability instanceof SpellAbility) { + ability.getTargets().clear(); + ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX())); + } + } + + @Override + public WaveOfIndifference copy() { + return new WaveOfIndifference(this); + } +} diff --git a/Mage.Sets/src/mage/sets/ravnica/Terraformer.java b/Mage.Sets/src/mage/sets/ravnica/Terraformer.java new file mode 100644 index 00000000000..13e12446010 --- /dev/null +++ b/Mage.Sets/src/mage/sets/ravnica/Terraformer.java @@ -0,0 +1,190 @@ +/* + * 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.ravnica; + +import java.util.Set; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.mana.BlackManaAbility; +import mage.abilities.mana.BlueManaAbility; +import mage.abilities.mana.GreenManaAbility; +import mage.abilities.mana.RedManaAbility; +import mage.abilities.mana.WhiteManaAbility; +import mage.cards.CardImpl; +import mage.choices.ChoiceImpl; +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.common.FilterControlledLandPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author emerald000 + */ +public class Terraformer extends CardImpl { + + public Terraformer(UUID ownerId) { + super(ownerId, 70, "Terraformer", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{U}"); + this.expansionSetCode = "RAV"; + this.subtype.add("Human"); + this.subtype.add("Wizard"); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // {1}: Choose a basic land type. Each land you control becomes that type until end of turn. + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new TerraformerEffect(), new GenericManaCost(1))); + } + + public Terraformer(final Terraformer card) { + super(card); + } + + @Override + public Terraformer copy() { + return new Terraformer(this); + } +} + +class TerraformerEffect extends OneShotEffect { + + TerraformerEffect() { + super(Outcome.Neutral); + this.staticText = "Choose a basic land type. Each land you control becomes that type until end of turn"; + } + + TerraformerEffect(final TerraformerEffect effect) { + super(effect); + } + + @Override + public TerraformerEffect copy() { + return new TerraformerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player != null) { + ChoiceImpl choices = new ChoiceImpl(true); + Set choicesSet = choices.getChoices(); + choicesSet.add("Forest"); + choicesSet.add("Plains"); + choicesSet.add("Mountain"); + choicesSet.add("Island"); + choicesSet.add("Swamp"); + if (player.choose(Outcome.Neutral, choices, game)) { + game.getState().setValue(source.getSourceId().toString() + "_Terraformer", choices.getChoice()); + } + game.addEffect(new TerraformerContinuousEffect(), source); + return true; + } + return false; + } +} + +class TerraformerContinuousEffect extends ContinuousEffectImpl { + + private static final FilterControlledPermanent filter = new FilterControlledLandPermanent(); + + TerraformerContinuousEffect() { + super(Duration.EndOfTurn, Outcome.Neutral); + } + + TerraformerContinuousEffect(final TerraformerContinuousEffect effect) { + super(effect); + } + + @Override + public TerraformerContinuousEffect copy() { + return new TerraformerContinuousEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + String choice = (String) game.getState().getValue(source.getSourceId().toString() + "_Terraformer"); + if (choice != null) { + for (Permanent land : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { + if (land != null) { + switch (layer) { + case TypeChangingEffects_4: + if (sublayer == SubLayer.NA) { + land.getSubtype().clear(); + land.getSubtype().add(choice); + } + break; + case AbilityAddingRemovingEffects_6: + if (sublayer == SubLayer.NA) { + land.getAbilities().clear(); + if (choice.equals("Forest")) { + land.addAbility(new GreenManaAbility(), id, game); + } + if (choice.equals("Plains")) { + land.addAbility(new WhiteManaAbility(), id, game); + } + if (choice.equals("Mountain")) { + land.addAbility(new RedManaAbility(), id, game); + } + if (choice.equals("Island")) { + land.addAbility(new BlueManaAbility(), id, game); + } + if (choice.equals("Swamp")) { + land.addAbility(new BlackManaAbility(), id, game); + } + } + break; + } + } + } + return true; + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; + } +} diff --git a/Mage.Sets/src/mage/sets/shadowmoor/ElsewhereFlask.java b/Mage.Sets/src/mage/sets/shadowmoor/ElsewhereFlask.java index 4210b34092a..ae8d945447e 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/ElsewhereFlask.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/ElsewhereFlask.java @@ -29,8 +29,6 @@ package mage.sets.shadowmoor; import java.util.Set; import java.util.UUID; - -import mage.constants.*; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; @@ -38,9 +36,20 @@ import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; -import mage.abilities.mana.*; +import mage.abilities.mana.BlackManaAbility; +import mage.abilities.mana.BlueManaAbility; +import mage.abilities.mana.GreenManaAbility; +import mage.abilities.mana.RedManaAbility; +import mage.abilities.mana.WhiteManaAbility; import mage.cards.CardImpl; import mage.choices.ChoiceImpl; +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.common.FilterControlledLandPermanent; import mage.filter.common.FilterControlledPermanent; import mage.game.Game; @@ -95,7 +104,7 @@ class ElsewhereFlaskEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); if (player != null) { ChoiceImpl choices = new ChoiceImpl(true); - Set choicesSet = choices.getChoices(); + Set choicesSet = choices.getChoices(); choicesSet.add("Forest"); choicesSet.add("Plains"); choicesSet.add("Mountain"); diff --git a/Mage/src/mage/abilities/effects/common/ChooseCreatureTypeEffect.java b/Mage/src/mage/abilities/effects/common/ChooseCreatureTypeEffect.java index b48288ca75e..16fe68f4b1d 100644 --- a/Mage/src/mage/abilities/effects/common/ChooseCreatureTypeEffect.java +++ b/Mage/src/mage/abilities/effects/common/ChooseCreatureTypeEffect.java @@ -67,8 +67,9 @@ public class ChooseCreatureTypeEffect extends OneShotEffect { return false; } } - if (!game.isSimulation()) + if (!game.isSimulation()) { game.informPlayers(permanent.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); + } game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice()); permanent.addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game); }