diff --git a/.gitignore b/.gitignore index 3e4715c960..fb2638998b 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,4 @@ Mage.Server.Plugins/Mage.Draft.8PlayerBooster/target *.iml /submitted +/Mage.Server/config/ai.please.cast.this.txt \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/conspiracy/CouncilsJudgment.java b/Mage.Sets/src/mage/sets/conspiracy/CouncilsJudgment.java new file mode 100644 index 0000000000..45baea7aa2 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conspiracy/CouncilsJudgment.java @@ -0,0 +1,52 @@ +/* + * 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.conspiracy; + +import java.util.UUID; + +/** + * + * @author emerald000 + */ +public class CouncilsJudgment extends mage.sets.vintagemasters.CouncilsJudgment { + + public CouncilsJudgment(UUID ownerId) { + super(ownerId); + this.cardNumber = 16; + this.expansionSetCode = "CNS"; + } + + public CouncilsJudgment(final CouncilsJudgment card) { + super(card); + } + + @Override + public CouncilsJudgment copy() { + return new CouncilsJudgment(this); + } +} diff --git a/Mage.Sets/src/mage/sets/fifthedition/Hydroblast.java b/Mage.Sets/src/mage/sets/fifthedition/Hydroblast.java new file mode 100644 index 0000000000..b49947e6b2 --- /dev/null +++ b/Mage.Sets/src/mage/sets/fifthedition/Hydroblast.java @@ -0,0 +1,133 @@ +/* + * 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.fifthedition; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.TargetSpell; + +/** + * + * @author emerald000 + */ +public class Hydroblast extends CardImpl { + + public Hydroblast(UUID ownerId) { + super(ownerId, 94, "Hydroblast", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{U}"); + this.expansionSetCode = "5ED"; + + this.color.setBlue(true); + + // Choose one - Counter target spell if it's red; + this.getSpellAbility().addEffect(new HydroblastCounterEffect()); + this.getSpellAbility().addTarget(new TargetSpell()); + + // or destroy target permanent if it's red. + Mode mode = new Mode(); + mode.getEffects().add(new HydroblastDestroyEffect()); + mode.getTargets().add(new TargetPermanent()); + this.getSpellAbility().addMode(mode); + } + + public Hydroblast(final Hydroblast card) { + super(card); + } + + @Override + public Hydroblast copy() { + return new Hydroblast(this); + } +} + +class HydroblastCounterEffect extends OneShotEffect { + + HydroblastCounterEffect() { + super(Outcome.Detriment); + } + + HydroblastCounterEffect(final HydroblastCounterEffect effect) { + super(effect); + } + + @Override + public HydroblastCounterEffect copy() { + return new HydroblastCounterEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + if (game.getStack().getSpell(source.getFirstTarget()).getColor().isRed()) { + game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game); + } + return true; + } + + @Override + public String getText(Mode mode) { + return "Counter target spell if it's red"; + } +} + +class HydroblastDestroyEffect extends OneShotEffect { + + HydroblastDestroyEffect() { + super(Outcome.DestroyPermanent); + } + + HydroblastDestroyEffect(final HydroblastDestroyEffect effect) { + super(effect); + } + + @Override + public HydroblastDestroyEffect copy() { + return new HydroblastDestroyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget()); + if (permanent != null && permanent.getColor().isRed()) { + permanent.destroy(source.getId(), game, false); + } + return true; + } + + @Override + public String getText(Mode mode) { + return "destroy target permanent if it's red"; + } +} diff --git a/Mage.Sets/src/mage/sets/iceage/Hydroblast.java b/Mage.Sets/src/mage/sets/iceage/Hydroblast.java new file mode 100644 index 0000000000..2d713f7fd2 --- /dev/null +++ b/Mage.Sets/src/mage/sets/iceage/Hydroblast.java @@ -0,0 +1,54 @@ +/* + * 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.iceage; + +import java.util.UUID; +import mage.constants.Rarity; + +/** + * + * @author emerald000 + */ +public class Hydroblast extends mage.sets.fifthedition.Hydroblast { + + public Hydroblast(UUID ownerId) { + super(ownerId); + this.cardNumber = 72; + this.expansionSetCode = "ICE"; + this.rarity = Rarity.COMMON; + } + + public Hydroblast(final Hydroblast card) { + super(card); + } + + @Override + public Hydroblast copy() { + return new Hydroblast(this); + } +} diff --git a/Mage.Sets/src/mage/sets/invasion/SterlingGrove.java b/Mage.Sets/src/mage/sets/invasion/SterlingGrove.java new file mode 100644 index 0000000000..04fd06aff7 --- /dev/null +++ b/Mage.Sets/src/mage/sets/invasion/SterlingGrove.java @@ -0,0 +1,90 @@ +/* + * 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.invasion; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.continious.GainAbilityControlledEffect; +import mage.abilities.effects.common.search.SearchLibraryPutOnLibraryEffect; +import mage.abilities.keyword.ShroudAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.AnotherPredicate; +import mage.target.common.TargetCardInLibrary; + +/** + * + * @author emerald000 + */ +public class SterlingGrove extends CardImpl { + + private static final FilterControlledPermanent filterPermanent = new FilterControlledPermanent("Other enchantments you control"); + private static final FilterCard filterCard = new FilterCard("enchantment card"); + static { + filterPermanent.add(new CardTypePredicate(CardType.ENCHANTMENT)); + filterPermanent.add(new AnotherPredicate()); + filterCard.add(new CardTypePredicate(CardType.ENCHANTMENT)); + } + + + public SterlingGrove(UUID ownerId) { + + super(ownerId, 278, "Sterling Grove", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{G}{W}"); + this.expansionSetCode = "INV"; + + this.color.setWhite(true); + this.color.setGreen(true); + + // Other enchantments you control have shroud. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(ShroudAbility.getInstance(), Duration.WhileOnBattlefield, filterPermanent, true))); + + // {1}, Sacrifice Sterling Grove: Search your library for an enchantment card and reveal that card. Shuffle your library, then put the card on top of it. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SearchLibraryPutOnLibraryEffect(new TargetCardInLibrary(filterCard), true, true), new GenericManaCost(1)); + ability.addCost(new SacrificeSourceCost()); + this.addAbility(ability); + } + + public SterlingGrove(final SterlingGrove card) { + super(card); + } + + @Override + public SterlingGrove copy() { + return new SterlingGrove(this); + } +} diff --git a/Mage.Sets/src/mage/sets/judgment/RiftstonePortal.java b/Mage.Sets/src/mage/sets/judgment/RiftstonePortal.java new file mode 100644 index 0000000000..3531c787e6 --- /dev/null +++ b/Mage.Sets/src/mage/sets/judgment/RiftstonePortal.java @@ -0,0 +1,78 @@ +/* + * 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.judgment; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.common.continious.GainAbilityControlledEffect; +import mage.abilities.mana.ColorlessManaAbility; +import mage.abilities.mana.GreenManaAbility; +import mage.abilities.mana.WhiteManaAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.common.FilterControlledLandPermanent; + +/** + * + * @author emerald000 + */ +public class RiftstonePortal extends CardImpl { + + public RiftstonePortal(UUID ownerId) { + super(ownerId, 143, "Riftstone Portal", Rarity.UNCOMMON, new CardType[]{CardType.LAND}, ""); + this.expansionSetCode = "JUD"; + + // {tap}: Add {1} to your mana pool. + this.addAbility(new ColorlessManaAbility()); + + // As long as Riftstone Portal is in your graveyard, lands you control have "{tap}: Add {G} or {W} to your mana pool." + ContinuousEffect effect = new GainAbilityControlledEffect(new GreenManaAbility(), + Duration.WhileOnBattlefield, new FilterControlledLandPermanent()); + effect.setText("As long as Riftstone Portal is in your graveyard, lands you control have \"{tap}: Add {G} or {W} to your mana pool.\""); + Ability ability = new SimpleStaticAbility(Zone.GRAVEYARD, effect); + effect = new GainAbilityControlledEffect(new WhiteManaAbility(), + Duration.WhileOnBattlefield, new FilterControlledLandPermanent()); + effect.setText(""); + ability.addEffect(effect); + this.addAbility(ability); + } + + public RiftstonePortal(final RiftstonePortal card) { + super(card); + } + + @Override + public RiftstonePortal copy() { + return new RiftstonePortal(this); + } +} diff --git a/Mage.Sets/src/mage/sets/onslaught/FalseCure.java b/Mage.Sets/src/mage/sets/onslaught/FalseCure.java new file mode 100644 index 0000000000..25cb8b8b3a --- /dev/null +++ b/Mage.Sets/src/mage/sets/onslaught/FalseCure.java @@ -0,0 +1,101 @@ +/* + * 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.DelayedTriggeredAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.effects.common.LoseLifeTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author emerald000 + */ +public class FalseCure extends CardImpl { + + public FalseCure(UUID ownerId) { + super(ownerId, 146, "False Cure", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{B}{B}"); + this.expansionSetCode = "ONS"; + + this.color.setBlack(true); + + // Until end of turn, whenever a player gains life, that player loses 2 life for each 1 life he or she gained. + this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new FalseCureTriggeredAbility())); + } + + public FalseCure(final FalseCure card) { + super(card); + } + + @Override + public FalseCure copy() { + return new FalseCure(this); + } +} + +class FalseCureTriggeredAbility extends DelayedTriggeredAbility { + + FalseCureTriggeredAbility() { + super(new LoseLifeTargetEffect(0), Duration.EndOfTurn, false); + } + + FalseCureTriggeredAbility(final FalseCureTriggeredAbility ability) { + super(ability); + } + + @Override + public FalseCureTriggeredAbility copy() { + return new FalseCureTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == EventType.GAINED_LIFE) { + this.getEffects().clear(); + Effect effect = new LoseLifeTargetEffect(2 * event.getAmount()); + effect.setTargetPointer(new FixedTarget(event.getPlayerId())); + this.addEffect(effect); + return true; + } + return false; + } + + @Override + public String getRule() { + return "Until end of turn, whenever a player gains life, that player loses 2 life for each 1 life he or she gained."; + } +} diff --git a/Mage.Sets/src/mage/sets/vintagemasters/CouncilsJudgment.java b/Mage.Sets/src/mage/sets/vintagemasters/CouncilsJudgment.java new file mode 100644 index 0000000000..aa41259f02 --- /dev/null +++ b/Mage.Sets/src/mage/sets/vintagemasters/CouncilsJudgment.java @@ -0,0 +1,143 @@ +/* + * 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.vintagemasters; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.common.FilterNonlandPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.ControllerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.players.PlayerList; +import mage.target.Target; +import mage.target.common.TargetNonlandPermanent; + +/** + * + * @author emerald000 + */ +public class CouncilsJudgment extends CardImpl { + + public CouncilsJudgment(UUID ownerId) { + super(ownerId, 20, "Council's Judgment", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{1}{W}{W}"); + this.expansionSetCode = "VMA"; + + this.color.setWhite(true); + + // Will of the council - Starting with you, each player votes for a nonland permanent you don't control. Exile each permanent with the most votes or tied for most votes. + this.getSpellAbility().addEffect(new CouncilsJudgmentEffect()); + } + + public CouncilsJudgment(final CouncilsJudgment card) { + super(card); + } + + @Override + public CouncilsJudgment copy() { + return new CouncilsJudgment(this); + } +} + +class CouncilsJudgmentEffect extends OneShotEffect { + + CouncilsJudgmentEffect() { + super(Outcome.Exile); + this.staticText = "Will of the council — Starting with you, each player votes for a nonland permanent you don't control. Exile each permanent with the most votes or tied for most votes"; + } + + CouncilsJudgmentEffect(final CouncilsJudgmentEffect effect) { + super(effect); + } + + @Override + public CouncilsJudgmentEffect copy() { + return new CouncilsJudgmentEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Map chosenCards = new HashMap<>(2); + int maxCount = 0; + FilterNonlandPermanent filter = new FilterNonlandPermanent("a nonland permanent " + controller.getName() + " doesn't control"); + filter.add(Predicates.not(new ControllerIdPredicate(controller.getId()))); + //Players each choose a legal permanent + PlayerList playerList = game.getState().getPlayerList(); + while (!playerList.get().equals(controller.getId()) && controller.isInGame()) { + playerList.getNext(); + } + do { + Player player = game.getPlayer(playerList.get()); + if (player != null) { + Target target = new TargetNonlandPermanent(filter); + target.setNotTarget(true); + if (player.choose(Outcome.Exile, target, source.getSourceId(), game)) { + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent != null) { + if (chosenCards.containsKey(permanent)) { + int count = chosenCards.get(permanent) + 1; + if (count > maxCount) { + maxCount = count; + } + chosenCards.put(permanent, count); + } + else { + if (maxCount == 0) { + maxCount = 1; + } + chosenCards.put(permanent, 1); + } + game.informPlayers(player.getName() + " has chosen: " + permanent.getName()); + } + } + } + } while (playerList.getNextInRange(controller, game) != controller && controller.isInGame()); + //Exile the card(s) with the most votes. + for (Entry entry : chosenCards.entrySet()) { + if (entry.getValue() == maxCount) { + Permanent permanent = entry.getKey(); + controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD); + } + } + return true; + } + return false; + } +}