From 15e3fd906ece4b2753dffc97293be11058606a95 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 2 May 2014 19:14:59 +0200 Subject: [PATCH] Added Ashling the Pilgrim, Reset and Flash of insight. --- .../mage/sets/judgment/FlashOfInsight.java | 162 ++++++++++++++++++ Mage.Sets/src/mage/sets/legends/Reset.java | 112 ++++++++++++ .../mage/sets/lorwyn/AshlingThePilgrim.java | 136 +++++++++++++++ Mage/src/mage/game/events/GameEvent.java | 2 +- 4 files changed, 411 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/sets/judgment/FlashOfInsight.java create mode 100644 Mage.Sets/src/mage/sets/legends/Reset.java create mode 100644 Mage.Sets/src/mage/sets/lorwyn/AshlingThePilgrim.java diff --git a/Mage.Sets/src/mage/sets/judgment/FlashOfInsight.java b/Mage.Sets/src/mage/sets/judgment/FlashOfInsight.java new file mode 100644 index 0000000000..de50e9c7a3 --- /dev/null +++ b/Mage.Sets/src/mage/sets/judgment/FlashOfInsight.java @@ -0,0 +1,162 @@ +/* + * 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.MageObject; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.costs.common.ExileXFromYourGraveCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlashbackAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.TimingRule; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; + +/** + * + * @author LevelX2 + */ +public class FlashOfInsight extends CardImpl { + + private static final FilterCard filter = new FilterCard("blue cards from your graveyard"); + + static { + filter.add(new ColorPredicate(ObjectColor.BLUE)); + } + + public FlashOfInsight(UUID ownerId) { + super(ownerId, 40, "Flash of Insight", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{X}{1}{U}"); + this.expansionSetCode = "JUD"; + + this.color.setBlue(true); + + // Look at the top X cards of your library. Put one of them into your hand and the rest on the bottom of your library in any order. + this.getSpellAbility().addEffect(new FlashOfInsightEffect()); + // Flashback-{1}{U}, Exile X blue cards from your graveyard. + Ability ability = new FlashbackAbility(new ManaCostsImpl("{1}{U}"), TimingRule.INSTANT); + ability.addCost(new ExileXFromYourGraveCost(filter)); + this.addAbility(ability); + } + + public FlashOfInsight(final FlashOfInsight card) { + super(card); + } + + @Override + public FlashOfInsight copy() { + return new FlashOfInsight(this); + } +} + +class FlashOfInsightEffect extends OneShotEffect { + + public FlashOfInsightEffect() { + super(Outcome.DrawCard); + this.staticText = "Look at the top X cards of your library. Put one of them into your hand and the rest on the bottom of your library in any order"; + } + + public FlashOfInsightEffect(final FlashOfInsightEffect effect) { + super(effect); + } + + @Override + public FlashOfInsightEffect copy() { + return new FlashOfInsightEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (player == null || sourceObject == null) { + return false; + } + + int xValue; + xValue = source.getManaCostsToPay().getX(); + + Cards cards = new CardsImpl(Zone.PICK); + int count = Math.min(player.getLibrary().size(), xValue); + for (int i = 0; i < count; i++) { + Card card = player.getLibrary().removeFromTop(game); + if (card != null) { + cards.add(card); + game.setZone(card.getId(), Zone.PICK); + } + } + player.lookAtCards(sourceObject.getName(), cards, game); + + TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put into your hand")); + if (player.choose(Outcome.DrawCard, cards, target, game)) { + Card card = cards.get(target.getFirstTarget(), game); + if (card != null) { + cards.remove(card); + card.moveToZone(Zone.HAND, source.getSourceId(), game, false); + game.informPlayers(sourceObject.getName() + ": " + player.getName() + " puts a card into his or her hand"); + } + } + + target = new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library")); + target.setRequired(true); + if (cards.size() > 0) { + game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ") + .append(player.getName()).append(" puts ") + .append(cards.size() == 1 ? "a":cards.size()) + .append(" card").append(cards.size() > 1 ? "s":"") + .append(" on the bottom of his or her library").toString()); + } + while (cards.size() > 1) { + player.choose(Outcome.Neutral, cards, target, game); + Card card = cards.get(target.getFirstTarget(), game); + if (card != null) { + cards.remove(card); + card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); + } + target.clearChosen(); + } + if (cards.size() == 1) { + Card card = cards.get(cards.iterator().next(), game); + card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); + } + + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/legends/Reset.java b/Mage.Sets/src/mage/sets/legends/Reset.java new file mode 100644 index 0000000000..a127d6082e --- /dev/null +++ b/Mage.Sets/src/mage/sets/legends/Reset.java @@ -0,0 +1,112 @@ +/* + * 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.legends; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.UntapAllLandsControllerEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.PhaseStep; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; + +/** + * + * @author LevelX2 + */ +public class Reset extends CardImpl { + + public Reset(UUID ownerId) { + super(ownerId, 73, "Reset", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{U}{U}"); + this.expansionSetCode = "LEG"; + + this.color.setBlue(true); + + // Cast Reset only during an opponent's turn after his or her upkeep step. + Ability ability = new SimpleStaticAbility(Zone.ALL, new ResetReplacementEffect()); + ability.setRuleAtTheTop(true); + this.addAbility(ability); + // Untap all lands you control. + this.getSpellAbility().addEffect(new UntapAllLandsControllerEffect()); + } + + public Reset(final Reset card) { + super(card); + } + + @Override + public Reset copy() { + return new Reset(this); + } +} + +class ResetReplacementEffect extends ReplacementEffectImpl { + ResetReplacementEffect() { + super(Duration.EndOfGame, Outcome.Detriment); + staticText = "Cast {this} only during an opponent's turn after his or her upkeep step"; + } + + ResetReplacementEffect(final ResetReplacementEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType().equals(GameEvent.EventType.CAST_SPELL) && event.getSourceId().equals(source.getSourceId())) { + if (game.getTurn().getStepType().equals(PhaseStep.UNTAP) + || game.getTurn().getStepType().equals(PhaseStep.UPKEEP) + || !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId())) { + return true; + } + + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public ResetReplacementEffect copy() { + return new ResetReplacementEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/lorwyn/AshlingThePilgrim.java b/Mage.Sets/src/mage/sets/lorwyn/AshlingThePilgrim.java new file mode 100644 index 0000000000..ab0bebdd39 --- /dev/null +++ b/Mage.Sets/src/mage/sets/lorwyn/AshlingThePilgrim.java @@ -0,0 +1,136 @@ +/* + * 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.lorwyn; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DamageEverythingEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author LevelX2 + */ +public class AshlingThePilgrim extends CardImpl { + + public AshlingThePilgrim(UUID ownerId) { + super(ownerId, 149, "Ashling the Pilgrim", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{R}"); + this.expansionSetCode = "LRW"; + this.supertype.add("Legendary"); + this.subtype.add("Elemental"); + this.subtype.add("Shaman"); + + this.color.setRed(true); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // {1}{R}: Put a +1/+1 counter on Ashling the Pilgrim. If this is the third time this ability has resolved this turn, remove all +1/+1 counters from Ashling the Pilgrim, and it deals that much damage to each creature and each player. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance(), true), new ManaCostsImpl("{1}{R}")); + ability.addEffect(new AshlingThePilgrimEffect()); + this.addAbility(ability); + } + + public AshlingThePilgrim(final AshlingThePilgrim card) { + super(card); + } + + @Override + public AshlingThePilgrim copy() { + return new AshlingThePilgrim(this); + } +} + +class AshlingThePilgrimEffect extends OneShotEffect { + + class ActivationInfo { + public int zoneChangeCounter; + public int turn; + public int activations; + } + + public AshlingThePilgrimEffect() { + super(Outcome.Damage); + this.staticText = "If this is the third time this ability has resolved this turn, remove all +1/+1 counters from {this}, and it deals that much damage to each creature and each player"; + } + + public AshlingThePilgrimEffect(final AshlingThePilgrimEffect effect) { + super(effect); + } + + @Override + public AshlingThePilgrimEffect copy() { + return new AshlingThePilgrimEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + if (controller != null && sourcePermanent != null) { + ActivationInfo info; + Object object = game.getState().getValue(source.getSourceId() + "ActivationInfo"); + if (object instanceof ActivationInfo) { + info = (ActivationInfo) object; + if (info.turn != game.getTurnNum() || sourcePermanent.getZoneChangeCounter() != info.zoneChangeCounter) { + info.turn = game.getTurnNum(); + info.zoneChangeCounter = sourcePermanent.getZoneChangeCounter(); + info.activations = 0; + } + } else { + info = new ActivationInfo(); + info.turn = game.getTurnNum(); + info.zoneChangeCounter = sourcePermanent.getZoneChangeCounter(); + game.getState().setValue(source.getSourceId() + "ActivationInfo", info); + } + info.activations++; + if (info.activations == 3) { + int damage = sourcePermanent.getCounters().getCount(CounterType.P1P1); + if (damage > 0) { + sourcePermanent.removeCounters(CounterType.P1P1.getName(), damage, game); + return new DamageEverythingEffect(damage, new FilterCreaturePermanent()).apply(game, source); + } + } + return true; + } + return false; + } +} diff --git a/Mage/src/mage/game/events/GameEvent.java b/Mage/src/mage/game/events/GameEvent.java index 1a0b8c5b05..6a3f02c1a1 100644 --- a/Mage/src/mage/game/events/GameEvent.java +++ b/Mage/src/mage/game/events/GameEvent.java @@ -46,7 +46,7 @@ public class GameEvent { protected boolean flag; protected String data; protected Zone zone; - protected ArrayList appliedEffects = new ArrayList(); + protected ArrayList appliedEffects = new ArrayList<>(); public enum EventType {