From 16924b0c9b6e58321f317c4d30cf1e513f8a9929 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Fri, 3 Nov 2017 19:06:20 +0100 Subject: [PATCH 01/12] Implemented Norritt --- Mage.Sets/src/mage/cards/n/Norritt.java | 140 ++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/n/Norritt.java diff --git a/Mage.Sets/src/mage/cards/n/Norritt.java b/Mage.Sets/src/mage/cards/n/Norritt.java new file mode 100644 index 0000000000..c69b56528f --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/Norritt.java @@ -0,0 +1,140 @@ +/* + * 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.n; + +import java.util.UUID; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; +import mage.abilities.condition.InvertCondition; +import mage.abilities.condition.common.TargetAttackedThisTurnCondition; +import mage.abilities.condition.common.BeforeAttackersAreDeclaredCondition; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.decorator.ConditionalActivatedAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.UntapTargetEffect; +import mage.abilities.effects.common.combat.AttacksIfAbleTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControlledFromStartOfControllerTurnPredicate; +import mage.filter.predicate.permanent.ControllerPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCreaturePermanent; +import mage.target.targetpointer.FixedTarget; +import mage.watchers.common.AttackedThisTurnWatcher; + +/** + * + * @author MTGfan & L_J + */ +public class Norritt extends CardImpl { + + private static final FilterCreaturePermanent filterBlue = new FilterCreaturePermanent("blue creature"); + static { + filterBlue.add(new ColorPredicate(ObjectColor.BLUE)); + } + + private static final FilterCreaturePermanent filterCreature = new FilterCreaturePermanent("non-Wall creature"); + static { + filterCreature.add(Predicates.not(new SubtypePredicate(SubType.WALL))); + filterCreature.add(new ControlledFromStartOfControllerTurnPredicate()); + filterCreature.add(new ControllerPredicate(TargetController.ACTIVE)); + filterCreature.setMessage("non-Wall creature the active player has controlled continuously since the beginning of the turn."); + } + + public Norritt(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}"); + + this.subtype.add(SubType.IMP); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // {T}: Untap target blue creature. + Ability ability1 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new UntapTargetEffect(), new TapSourceCost()); + ability1.addTarget(new TargetCreaturePermanent(filterBlue)); + this.addAbility(ability1); + + // {T}: Choose target non-Wall creature the active player has controlled continuously since the beginning of the turn. That creature attacks this turn if able. If it doesn't, destroy it at the beginning of the next end step. Activate this ability only before attackers are declared. + Ability ability2 = new ConditionalActivatedAbility(Zone.BATTLEFIELD, new AttacksIfAbleTargetEffect(Duration.EndOfTurn), + new TapSourceCost(), BeforeAttackersAreDeclaredCondition.instance, + "{T}: Choose target non-Wall creature the active player has controlled continuously since the beginning of the turn. " + + "That creature attacks this turn if able. If it doesn't, destroy it at the beginning of the next end step. " + + "Activate this ability only before attackers are declared."); + ability2.addEffect(new NorrittDelayedDestroyEffect()); + ability2.addTarget(new TargetCreaturePermanent(filterCreature)); + this.addAbility(ability2, new AttackedThisTurnWatcher()); + + } + + public Norritt(final Norritt card) { + super(card); + } + + @Override + public Norritt copy() { + return new Norritt(this); + } +} + +class NorrittDelayedDestroyEffect extends OneShotEffect { + + public NorrittDelayedDestroyEffect() { + super(Outcome.Detriment); + this.staticText = "If it doesn't, destroy it at the beginning of the next end step"; + } + + public NorrittDelayedDestroyEffect(final NorrittDelayedDestroyEffect effect) { + super(effect); + } + + @Override + public NorrittDelayedDestroyEffect copy() { + return new NorrittDelayedDestroyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + DestroyTargetEffect effect = new DestroyTargetEffect(); + effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); + AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility + = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.ALL, effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance)); + delayedAbility.getDuration(); + delayedAbility.getTargets().addAll(source.getTargets()); + game.addDelayedTriggeredAbility(delayedAbility, source); + return true; + } +} From e94c8a2dd2262eb9dc683bda2974ae5e641e5751 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Fri, 3 Nov 2017 19:07:52 +0100 Subject: [PATCH 02/12] Implemented Season of the Witch --- .../src/mage/cards/s/SeasonOfTheWitch.java | 189 ++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java diff --git a/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java b/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java new file mode 100644 index 0000000000..ed6be2da1e --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java @@ -0,0 +1,189 @@ +/* + * 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.s; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.PayLifeCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.WatcherScope; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.filter.StaticFilters; +import mage.players.Player; +import mage.watchers.Watcher; +import mage.watchers.common.AttackedThisTurnWatcher; + +/** + * + * @author L_J + */ +public class SeasonOfTheWitch extends CardImpl { + + public SeasonOfTheWitch(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{B}{B}{B}"); + + // At the beginning of your upkeep, sacrifice Season of the Witch unless you pay 2 life. + Cost cost = new PayLifeCost(2); + cost.setText("2 life"); + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(cost), TargetController.YOU, false)); + + // At the beginning of the end step, destroy all untapped creatures that didn't attack this turn, except for creatures that couldn't attack. + Ability ability = new BeginningOfEndStepTriggeredAbility(new SeasonOfTheWitchEffect(), TargetController.ANY, false); + ability.addWatcher(new AttackedThisTurnWatcher()); + ability.addWatcher(new CouldAttackThisTurnWatcher()); + this.addAbility(ability); + } + + public SeasonOfTheWitch(final SeasonOfTheWitch card) { + super(card); + } + + @Override + public SeasonOfTheWitch copy() { + return new SeasonOfTheWitch(this); + } +} + +class SeasonOfTheWitchEffect extends OneShotEffect { + + SeasonOfTheWitchEffect() { + super(Outcome.DestroyPermanent); + this.staticText = "destroy all untapped creatures that didn't attack this turn, except for creatures that couldn't attack"; + } + + SeasonOfTheWitchEffect(final SeasonOfTheWitchEffect effect) { + super(effect); + } + + @Override + public SeasonOfTheWitchEffect copy() { + return new SeasonOfTheWitchEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player activePlayer = game.getPlayer(game.getActivePlayerId()); + if (activePlayer != null) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, game)) { + // Noncreature cards are safe. + if (!permanent.isCreature()) { + continue; + } + // Tapped cards are safe. + if (permanent.isTapped()) { + continue; + } + // Creatures that attacked are safe. + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + if (watcher != null + && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game)) ) { + continue; + } + // Creatures that couldn't attack are safe. + CouldAttackThisTurnWatcher watcher2 = (CouldAttackThisTurnWatcher) game.getState().getWatchers().get(CouldAttackThisTurnWatcher.class.getSimpleName()); + if (watcher2 != null + && !watcher2.getCouldAttackThisTurnCreatures().contains(new MageObjectReference(permanent, game)) ) { + continue; + } + // Destroy the rest. + permanent.destroy(source.getSourceId(), game, false); + } + return true; + } + return false; + } +} + +class CouldAttackThisTurnWatcher extends Watcher { + + public final Set couldAttackThisTurnCreatures = new HashSet<>(); + + public CouldAttackThisTurnWatcher() { + super(CouldAttackThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); + } + + public CouldAttackThisTurnWatcher(final CouldAttackThisTurnWatcher watcher) { + super(watcher); + this.couldAttackThisTurnCreatures.addAll(watcher.couldAttackThisTurnCreatures); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.DECLARE_ATTACKERS_STEP_PRE) { + Player activePlayer = game.getPlayer(game.getActivePlayerId()); + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(activePlayer.getId())) { + if (permanent.isCreature()) { + for (UUID defender : game.getCombat().getDefenders()) { + if (defender != activePlayer.getId()) { + if (permanent.canAttack(defender, game)) { + // exclude Propaganda style effects + if (!game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects( + GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER, + defender, permanent.getId(), permanent.getControllerId()), game)) { + this.couldAttackThisTurnCreatures.add(new MageObjectReference(permanent.getId(), game)); + break; + } + } + } + } + } + } + } + } + + public Set getCouldAttackThisTurnCreatures() { + return this.couldAttackThisTurnCreatures; + } + + @Override + public CouldAttackThisTurnWatcher copy() { + return new CouldAttackThisTurnWatcher(this); + } + + @Override + public void reset() { + super.reset(); + this.couldAttackThisTurnCreatures.clear(); + } +} From 89398d97b3154619a8bc8277ca5a4855115bb7dd Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Fri, 3 Nov 2017 19:08:38 +0100 Subject: [PATCH 03/12] Implemented Total War --- Mage.Sets/src/mage/cards/TotalWar.java | 152 +++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/TotalWar.java diff --git a/Mage.Sets/src/mage/cards/TotalWar.java b/Mage.Sets/src/mage/cards/TotalWar.java new file mode 100644 index 0000000000..5aca291c7a --- /dev/null +++ b/Mage.Sets/src/mage/cards/TotalWar.java @@ -0,0 +1,152 @@ +/* + * 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.t; + +import java.util.UUID; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.watchers.common.AttackedOrBlockedThisCombatWatcher; + +/** + * + * @author jeffwadsworth & emerald000 & L_J + */ +public class TotalWar extends CardImpl { + + public TotalWar(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{R}"); + + // Whenever a player attacks with one or more creatures, destroy all untapped non-Wall creatures that player controls that didn't attack, except for creatures the player hasn't controlled continuously since the beginning of the turn. + this.addAbility(new TotalWarTriggeredAbility(), new AttackedOrBlockedThisCombatWatcher()); + } + + public TotalWar(final TotalWar card) { + super(card); + } + + @Override + public TotalWar copy() { + return new TotalWar(this); + } +} + +class TotalWarTriggeredAbility extends TriggeredAbilityImpl { + + public TotalWarTriggeredAbility() { + super(Zone.BATTLEFIELD, new TotalWarDestroyEffect()); + } + + public TotalWarTriggeredAbility(final TotalWarTriggeredAbility ability) { + super(ability); + } + + @Override + public TotalWarTriggeredAbility copy() { + return new TotalWarTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == EventType.DECLARED_ATTACKERS; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return !game.getCombat().getAttackers().isEmpty(); + } + + @Override + public String getRule() { + return "Whenever a player attacks with one or more creatures, " + super.getRule(); + } +} + +class TotalWarDestroyEffect extends OneShotEffect { + + TotalWarDestroyEffect() { + super(Outcome.DestroyPermanent); + this.staticText = "destroy all untapped non-Wall creatures that player controls that didn't attack, except for creatures the player hasn't controlled continuously since the beginning of the turn"; + } + + TotalWarDestroyEffect(final TotalWarDestroyEffect effect) { + super(effect); + } + + @Override + public TotalWarDestroyEffect copy() { + return new TotalWarDestroyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player activePlayer = game.getPlayer(game.getActivePlayerId()); + if (activePlayer != null) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(activePlayer.getId())) { + // Noncreature cards are safe. + if (!permanent.isCreature()) { + continue; + } + // Tapped cards are safe. + if (permanent.isTapped()) { + continue; + } + // Walls are safe. + if (permanent.hasSubtype(SubType.WALL, game)) { + continue; + } + // Creatures that attacked are safe. + AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getSimpleName()); + if (watcher != null + && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { + continue; + } + // Creatures that weren't controlled since the beginning of turn are safe. + if (!permanent.wasControlledFromStartOfControllerTurn()) { + continue; + } + // Destroy the rest. + permanent.destroy(source.getSourceId(), game, false); + } + return true; + } + return false; + } +} From ec0fc182c08713092068fc0c1a8afbac26c8a5ad Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Fri, 3 Nov 2017 19:09:20 +0100 Subject: [PATCH 04/12] Moved TotalWar.java --- Mage.Sets/src/mage/cards/{ => t}/TotalWar.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Mage.Sets/src/mage/cards/{ => t}/TotalWar.java (100%) diff --git a/Mage.Sets/src/mage/cards/TotalWar.java b/Mage.Sets/src/mage/cards/t/TotalWar.java similarity index 100% rename from Mage.Sets/src/mage/cards/TotalWar.java rename to Mage.Sets/src/mage/cards/t/TotalWar.java From da9cc63ce0c02e37a49cfc0f6dd1c156698591e5 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Fri, 3 Nov 2017 19:11:53 +0100 Subject: [PATCH 05/12] Implemented Norritt and Total War --- Mage.Sets/src/mage/sets/IceAge.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Mage.Sets/src/mage/sets/IceAge.java b/Mage.Sets/src/mage/sets/IceAge.java index 277e614b3b..01deb96424 100644 --- a/Mage.Sets/src/mage/sets/IceAge.java +++ b/Mage.Sets/src/mage/sets/IceAge.java @@ -234,6 +234,7 @@ public class IceAge extends ExpansionSet { cards.add(new SetCardInfo("Naked Singularity", 305, Rarity.RARE, mage.cards.n.NakedSingularity.class)); cards.add(new SetCardInfo("Nature's Lore", 143, Rarity.UNCOMMON, mage.cards.n.NaturesLore.class)); cards.add(new SetCardInfo("Necropotence", 42, Rarity.RARE, mage.cards.n.Necropotence.class)); + cards.add(new SetCardInfo("Norritt", 43, Rarity.COMMON, mage.cards.n.Norritt.class)); cards.add(new SetCardInfo("Onyx Talisman", 306, Rarity.UNCOMMON, mage.cards.o.OnyxTalisman.class)); cards.add(new SetCardInfo("Orcish Cannoneers", 205, Rarity.UNCOMMON, mage.cards.o.OrcishCannoneers.class)); cards.add(new SetCardInfo("Orcish Healer", 208, Rarity.UNCOMMON, mage.cards.o.OrcishHealer.class)); @@ -318,6 +319,7 @@ public class IceAge extends ExpansionSet { cards.add(new SetCardInfo("Time Bomb", 317, Rarity.RARE, mage.cards.t.TimeBomb.class)); cards.add(new SetCardInfo("Tinder Wall", 158, Rarity.COMMON, mage.cards.t.TinderWall.class)); cards.add(new SetCardInfo("Tor Giant", 220, Rarity.COMMON, mage.cards.t.TorGiant.class)); + cards.add(new SetCardInfo("Total War", 221, Rarity.RARE, mage.cards.t.TotalWar.class)); cards.add(new SetCardInfo("Touch of Death", 55, Rarity.COMMON, mage.cards.t.TouchOfDeath.class)); cards.add(new SetCardInfo("Trailblazer", 160, Rarity.RARE, mage.cards.t.Trailblazer.class)); cards.add(new SetCardInfo("Underground River", 357, Rarity.RARE, mage.cards.u.UndergroundRiver.class)); From b352a318520313ead45e06ff00ca86b9d634880e Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Fri, 3 Nov 2017 19:13:07 +0100 Subject: [PATCH 06/12] Implemented Season of the Witch --- Mage.Sets/src/mage/sets/TheDark.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/sets/TheDark.java b/Mage.Sets/src/mage/sets/TheDark.java index 8f077c9ab8..a3586cc625 100644 --- a/Mage.Sets/src/mage/sets/TheDark.java +++ b/Mage.Sets/src/mage/sets/TheDark.java @@ -105,7 +105,7 @@ public class TheDark extends ExpansionSet { cards.add(new SetCardInfo("Marsh Gas", 10, Rarity.COMMON, mage.cards.m.MarshGas.class)); cards.add(new SetCardInfo("Marsh Goblins", 118, Rarity.COMMON, mage.cards.m.MarshGoblins.class)); cards.add(new SetCardInfo("Marsh Viper", 44, Rarity.COMMON, mage.cards.m.MarshViper.class)); - cards.add(new SetCardInfo("Martyr's Cry", 85, Rarity.RARE, mage.cards.m.MartyrsCry.class)); + cards.add(new SetCardInfo("Martyr's Cry", 85, Rarity.RARE, mage.cards.m.MartyrsCry.class)); cards.add(new SetCardInfo("Maze of Ith", 114, Rarity.UNCOMMON, mage.cards.m.MazeOfIth.class)); cards.add(new SetCardInfo("Merfolk Assassin", 31, Rarity.UNCOMMON, mage.cards.m.MerfolkAssassin.class)); cards.add(new SetCardInfo("Mind Bomb", 32, Rarity.RARE, mage.cards.m.MindBomb.class)); @@ -124,6 +124,7 @@ public class TheDark extends ExpansionSet { cards.add(new SetCardInfo("Scarwood Goblins", 119, Rarity.COMMON, mage.cards.s.ScarwoodGoblins.class)); cards.add(new SetCardInfo("Scarwood Hag", 49, Rarity.UNCOMMON, mage.cards.s.ScarwoodHag.class)); cards.add(new SetCardInfo("Scavenger Folk", 50, Rarity.COMMON, mage.cards.s.ScavengerFolk.class)); + cards.add(new SetCardInfo("Season of the Witch", 14, Rarity.RARE, mage.cards.s.SeasonOfTheWitch.class)); cards.add(new SetCardInfo("Sisters of the Flame", 73, Rarity.UNCOMMON, mage.cards.s.SistersOfTheFlame.class)); cards.add(new SetCardInfo("Skull of Orm", 106, Rarity.UNCOMMON, mage.cards.s.SkullOfOrm.class)); cards.add(new SetCardInfo("Squire", 90, Rarity.COMMON, mage.cards.s.Squire.class)); From 4176b35f2a2658b60bdabeb8b16104a6e2869dba Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Fri, 3 Nov 2017 19:15:35 +0100 Subject: [PATCH 07/12] Allowed choosing X=0 to act as an attack cost --- Mage.Sets/src/mage/cards/w/WarTax.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Mage.Sets/src/mage/cards/w/WarTax.java b/Mage.Sets/src/mage/cards/w/WarTax.java index 689779066c..d22850aff6 100644 --- a/Mage.Sets/src/mage/cards/w/WarTax.java +++ b/Mage.Sets/src/mage/cards/w/WarTax.java @@ -86,17 +86,15 @@ class WarTaxReplacementEffect extends ReplacementEffectImpl { Player player = game.getPlayer(event.getPlayerId()); if (player != null) { int amount = xCosts.calculate(game, source, this); - if (amount > 0) { - String mana = "{" + amount + '}'; - ManaCostsImpl cost = new ManaCostsImpl(mana); - if (cost.canPay(source, source.getSourceId(), event.getPlayerId(), game) - && player.chooseUse(Outcome.Benefit, "Pay " + mana + " to declare attacker?", source, game)) { - if (cost.payOrRollback(source, game, source.getSourceId(), event.getPlayerId())) { - return false; - } + String mana = "{" + amount + '}'; + ManaCostsImpl cost = new ManaCostsImpl(mana); + if (cost.canPay(source, source.getSourceId(), event.getPlayerId(), game) + && player.chooseUse(Outcome.Benefit, "Pay " + mana + " to declare attacker?", source, game)) { + if (cost.payOrRollback(source, game, source.getSourceId(), event.getPlayerId())) { + return false; } - return true; } + return true; } return false; } From 299e164da3d8df7a18253f2a3539d94071d59b75 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Fri, 3 Nov 2017 21:19:47 +0100 Subject: [PATCH 08/12] Fixed War Tax to work with Seasons of the Witch (fixes #4145) --- Mage.Sets/src/mage/cards/w/WarTax.java | 60 ++++++++++++-------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/Mage.Sets/src/mage/cards/w/WarTax.java b/Mage.Sets/src/mage/cards/w/WarTax.java index d22850aff6..a82625fd18 100644 --- a/Mage.Sets/src/mage/cards/w/WarTax.java +++ b/Mage.Sets/src/mage/cards/w/WarTax.java @@ -30,10 +30,11 @@ package mage.cards.w; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.ManacostVariableValue; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.PayCostToAttackBlockEffectImpl; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -42,12 +43,12 @@ import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.players.Player; +import mage.game.permanent.Permanent; /** * * - * @author HCrescent original code by LevelX2 edited from War Cadence + * @author HCrescent & L_J */ public class WarTax extends CardImpl { @@ -55,7 +56,7 @@ public class WarTax extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}"); // {X}{U}: This turn, creatures can't attack unless their controller pays {X} for each attacking creature he or she controls. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WarTaxReplacementEffect(), new ManaCostsImpl("{X}{U}"))); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WarTaxCantAttackUnlessPaysEffect(), new ManaCostsImpl("{X}{U}"))); } public WarTax(final WarTax card) { @@ -68,49 +69,42 @@ public class WarTax extends CardImpl { } } -class WarTaxReplacementEffect extends ReplacementEffectImpl { +class WarTaxCantAttackUnlessPaysEffect extends PayCostToAttackBlockEffectImpl { DynamicValue xCosts = new ManacostVariableValue(); - WarTaxReplacementEffect() { - super(Duration.EndOfTurn, Outcome.Neutral); + WarTaxCantAttackUnlessPaysEffect() { + super(Duration.EndOfTurn, Outcome.Neutral, RestrictType.ATTACK); staticText = "This turn, creatures can't attack unless their controller pays {X} for each attacking creature he or she controls"; } - WarTaxReplacementEffect(WarTaxReplacementEffect effect) { + WarTaxCantAttackUnlessPaysEffect(WarTaxCantAttackUnlessPaysEffect effect) { super(effect); } - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - Player player = game.getPlayer(event.getPlayerId()); - if (player != null) { - int amount = xCosts.calculate(game, source, this); - String mana = "{" + amount + '}'; - ManaCostsImpl cost = new ManaCostsImpl(mana); - if (cost.canPay(source, source.getSourceId(), event.getPlayerId(), game) - && player.chooseUse(Outcome.Benefit, "Pay " + mana + " to declare attacker?", source, game)) { - if (cost.payOrRollback(source, game, source.getSourceId(), event.getPlayerId())) { - return false; - } - } - return true; - } - return false; - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DECLARE_ATTACKER; - } - @Override public boolean applies(GameEvent event, Ability source, Game game) { return true; } @Override - public WarTaxReplacementEffect copy() { - return new WarTaxReplacementEffect(this); + public ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game) { + Permanent sourceObject = game.getPermanent(source.getSourceId()); + if (sourceObject != null) { + int amount = xCosts.calculate(game, source, this); + return new ManaCostsImpl<>("{" + amount + '}'); + } + return null; } + + @Override + public boolean isCostless(GameEvent event, Ability source, Game game) { + return false; + } + + @Override + public WarTaxCantAttackUnlessPaysEffect copy() { + return new WarTaxCantAttackUnlessPaysEffect(this); + } + } From feb798ec72343f1a0ec61046f92c563319f18634 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Sat, 4 Nov 2017 00:59:47 +0100 Subject: [PATCH 09/12] Implemented Elkin Lair --- Mage.Sets/src/mage/cards/e/ElkinLair.java | 190 ++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/e/ElkinLair.java diff --git a/Mage.Sets/src/mage/cards/e/ElkinLair.java b/Mage.Sets/src/mage/cards/e/ElkinLair.java new file mode 100644 index 0000000000..fae0b6fb47 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/ElkinLair.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.cards.e; + +import java.util.Set; +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.AsThoughEffectType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SuperType; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.filter.FilterCard; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; +import mage.util.CardUtil; +import mage.util.RandomUtil; + +/** + * + * @author L_J + */ +public class ElkinLair extends CardImpl { + + public ElkinLair(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{R}"); + addSuperType(SuperType.WORLD); + + // At the beginning of each player's upkeep, that player exiles a card at random from his or her hand. The player may play that card this turn. At the beginning of the next end step, if the player hasn't played the card, he or she puts it into his or her graveyard. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ElkinLairUpkeepEffect(), TargetController.ANY, false)); + + } + + public ElkinLair(final ElkinLair card) { + super(card); + } + + @Override + public ElkinLair copy() { + return new ElkinLair(this); + } + +} + +class ElkinLairUpkeepEffect extends OneShotEffect { + + public ElkinLairUpkeepEffect() { + super(Outcome.Benefit); + this.staticText = "that player exiles a card at random from his or her hand. The player may play that card this turn. At the beginning of the next end step, if the player hasn't played the card, he or she puts it into his or her graveyard"; + } + + public ElkinLairUpkeepEffect(final ElkinLairUpkeepEffect effect) { + super(effect); + } + + @Override + public ElkinLairUpkeepEffect copy() { + return new ElkinLairUpkeepEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(game.getActivePlayerId()); + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (player != null && sourcePermanent != null) { + Card[] cards = player.getHand().getCards(new FilterCard(), game).toArray(new Card[0]); + if (cards.length > 0) { + Card card = cards[RandomUtil.nextInt(cards.length)]; + if (card != null) { + String exileName = sourcePermanent.getIdName() + " cardsInExile = game.getExile().getExileZone(source.getSourceId()).getCards(game); + if (cardsInExile != null) { + player.moveCardsToGraveyardWithInfo(cardsInExile, source, game, Zone.EXILED); + return true; + } + } + return false; + } + + @Override + public ElkinLairPutIntoGraveyardEffect copy() { + return new ElkinLairPutIntoGraveyardEffect(this); + } +} From c6567360edeca78fe26f5f78910439fa648843b9 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Sat, 4 Nov 2017 01:00:31 +0100 Subject: [PATCH 10/12] Implemented Elkin Lair --- Mage.Sets/src/mage/sets/Visions.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Mage.Sets/src/mage/sets/Visions.java b/Mage.Sets/src/mage/sets/Visions.java index e016bce9fa..339ced90a7 100644 --- a/Mage.Sets/src/mage/sets/Visions.java +++ b/Mage.Sets/src/mage/sets/Visions.java @@ -81,6 +81,7 @@ public class Visions extends ExpansionSet { cards.add(new SetCardInfo("Dream Tides", 31, Rarity.UNCOMMON, mage.cards.d.DreamTides.class)); cards.add(new SetCardInfo("Dwarven Vigilantes", 77, Rarity.COMMON, mage.cards.d.DwarvenVigilantes.class)); cards.add(new SetCardInfo("Elephant Grass", 54, Rarity.UNCOMMON, mage.cards.e.ElephantGrass.class)); + cards.add(new SetCardInfo("Elkin Lair", 78, Rarity.RARE, mage.cards.e.ElkinLair.class)); cards.add(new SetCardInfo("Elven Cache", 55, Rarity.COMMON, mage.cards.e.ElvenCache.class)); cards.add(new SetCardInfo("Emerald Charm", 56, Rarity.COMMON, mage.cards.e.EmeraldCharm.class)); cards.add(new SetCardInfo("Equipoise", 103, Rarity.RARE, mage.cards.e.Equipoise.class)); From 39d2471132e462b412f5290f4acb825594d1c5f8 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Sat, 4 Nov 2017 16:04:10 +0100 Subject: [PATCH 11/12] Implemented Risky Move --- Mage.Sets/src/mage/cards/RiskyMove.java | 240 ++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/RiskyMove.java diff --git a/Mage.Sets/src/mage/cards/RiskyMove.java b/Mage.Sets/src/mage/cards/RiskyMove.java new file mode 100644 index 0000000000..321c407d7b --- /dev/null +++ b/Mage.Sets/src/mage/cards/RiskyMove.java @@ -0,0 +1,240 @@ +/* + * 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.r; + +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.common.TargetOpponent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author L_J + */ +public class RiskyMove extends CardImpl { + + public RiskyMove(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}{R}{R}"); + + // At the beginning of each player's upkeep, that player gains control of Risky Move. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new RiskyMoveGetControlEffect(), TargetController.ANY, false, true)); + + // When you gain control of Risky Move from another player, choose a creature you control and an opponent. Flip a coin. If you lose the flip, that opponent gains control of that creature. + Ability ability = new RiskyMoveTriggeredAbility(); + this.addAbility(ability); + } + + public RiskyMove(final RiskyMove card) { + super(card); + } + + @Override + public RiskyMove copy() { + return new RiskyMove(this); + } +} + +class RiskyMoveGetControlEffect extends OneShotEffect { + + public RiskyMoveGetControlEffect() { + super(Outcome.GainControl); + this.staticText = "that player gains control of {this}"; + } + + public RiskyMoveGetControlEffect(final RiskyMoveGetControlEffect effect) { + super(effect); + } + + @Override + public RiskyMoveGetControlEffect copy() { + return new RiskyMoveGetControlEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + Player newController = game.getPlayer(getTargetPointer().getFirst(game, source)); + if (newController != null && controller != null && sourceObject != null && sourceObject.equals(sourcePermanent)) { + // remove old control effects of the same player + for (ContinuousEffect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) { + if (effect instanceof GainControlTargetEffect) { + UUID checkId = (UUID) ((GainControlTargetEffect) effect).getValue("RiskyMoveSourceId"); + UUID controllerId = (UUID) ((GainControlTargetEffect) effect).getValue("RiskyMoveControllerId"); + if (source.getSourceId().equals(checkId) && newController.getId().equals(controllerId)) { + effect.discard(); + } + } + } + ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, newController.getId()); + effect.setValue("RiskyMoveSourceId", source.getSourceId()); + effect.setValue("RiskyMoveControllerId", newController.getId()); + effect.setTargetPointer(new FixedTarget(sourcePermanent.getId())); + effect.setText("and gains control of it"); + game.addEffect(effect, source); + return true; + } + return false; + } +} + +class RiskyMoveTriggeredAbility extends TriggeredAbilityImpl { + + public RiskyMoveTriggeredAbility() { + super(Zone.BATTLEFIELD, new RiskyMoveFlipCoinEffect(), false); + } + + public RiskyMoveTriggeredAbility(final RiskyMoveTriggeredAbility ability) { + super(ability); + } + + @Override + public RiskyMoveTriggeredAbility copy() { + return new RiskyMoveTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.GAINED_CONTROL; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return event.getTargetId().equals(sourceId); + } + + @Override + public String getRule() { + return "When you gain control of {this} from another player, " + super.getRule(); + } +} + + +class RiskyMoveFlipCoinEffect extends OneShotEffect { + + public RiskyMoveFlipCoinEffect() { + super(Outcome.Detriment); + this.staticText = "choose a creature you control and an opponent. Flip a coin. If you lose the flip, that opponent gains control of that creature"; + } + + public RiskyMoveFlipCoinEffect(final RiskyMoveFlipCoinEffect effect) { + super(effect); + } + + @Override + public RiskyMoveFlipCoinEffect copy() { + return new RiskyMoveFlipCoinEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Target target1 = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent(), true); + Target target2 = new TargetOpponent(true); + + if (target1.canChoose(source.getSourceId(), controller.getId(), game)) { + while (!target1.isChosen() && target1.canChoose(controller.getId(), game) && controller.canRespond()) { + controller.chooseTarget(outcome, target1, source, game); + } + } + if (target2.canChoose(source.getSourceId(), controller.getId(), game)) { + while (!target2.isChosen() && target2.canChoose(controller.getId(), game) && controller.canRespond()) { + controller.chooseTarget(outcome, target2, source, game); + } + } + Permanent permanent = game.getPermanent(target1.getFirstTarget()); + Player chosenOpponent = game.getPlayer(target2.getFirstTarget()); + if (!controller.flipCoin(game)) { + if (permanent != null && chosenOpponent != null) { + ContinuousEffect effect = new RiskyMoveCreatureGainControlEffect(Duration.Custom, chosenOpponent.getId()); + effect.setTargetPointer(new FixedTarget(permanent.getId())); + game.addEffect(effect, source); + return true; + } + } + } + return false; + } +} + +class RiskyMoveCreatureGainControlEffect extends ContinuousEffectImpl { + + private UUID controller; + + public RiskyMoveCreatureGainControlEffect(Duration duration, UUID controller) { + super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); + this.controller = controller; + } + + public RiskyMoveCreatureGainControlEffect(final RiskyMoveCreatureGainControlEffect effect) { + super(effect); + this.controller = effect.controller; + } + + @Override + public RiskyMoveCreatureGainControlEffect copy() { + return new RiskyMoveCreatureGainControlEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (targetPointer != null) { + permanent = game.getPermanent(targetPointer.getFirst(game, source)); + } + if (permanent != null) { + return permanent.changeControllerId(controller, game); + } + return false; + } + + @Override + public String getText(Mode mode) { + return "If you lose the flip, that opponent gains control of that creature"; + } +} From 53aa0136b8933a0ddd936237d83240ea01c4dcf6 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Sat, 4 Nov 2017 16:04:22 +0100 Subject: [PATCH 12/12] Implemented Risky Move --- Mage.Sets/src/mage/sets/Onslaught.java | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/sets/Onslaught.java b/Mage.Sets/src/mage/sets/Onslaught.java index 335a165dbd..8e76f69828 100644 --- a/Mage.Sets/src/mage/sets/Onslaught.java +++ b/Mage.Sets/src/mage/sets/Onslaught.java @@ -145,7 +145,7 @@ public class Onslaught extends ExpansionSet { cards.add(new SetCardInfo("Glory Seeker", 31, Rarity.COMMON, mage.cards.g.GlorySeeker.class)); cards.add(new SetCardInfo("Gluttonous Zombie", 151, Rarity.UNCOMMON, mage.cards.g.GluttonousZombie.class)); cards.add(new SetCardInfo("Goblin Burrows", 318, Rarity.UNCOMMON, mage.cards.g.GoblinBurrows.class)); - cards.add(new SetCardInfo("Goblin Machinist", 204, Rarity.UNCOMMON, mage.cards.g.GoblinMachinist.class)); + cards.add(new SetCardInfo("Goblin Machinist", 204, Rarity.UNCOMMON, mage.cards.g.GoblinMachinist.class)); cards.add(new SetCardInfo("Goblin Piledriver", 205, Rarity.RARE, mage.cards.g.GoblinPiledriver.class)); cards.add(new SetCardInfo("Goblin Pyromancer", 206, Rarity.RARE, mage.cards.g.GoblinPyromancer.class)); cards.add(new SetCardInfo("Goblin Sharpshooter", 207, Rarity.RARE, mage.cards.g.GoblinSharpshooter.class)); @@ -198,13 +198,13 @@ public class Onslaught extends ExpansionSet { cards.add(new SetCardInfo("Mana Echoes", 218, Rarity.RARE, mage.cards.m.ManaEchoes.class)); cards.add(new SetCardInfo("Menacing Ogre", 219, Rarity.RARE, mage.cards.m.MenacingOgre.class)); cards.add(new SetCardInfo("Misery Charm", 158, Rarity.COMMON, mage.cards.m.MiseryCharm.class)); - cards.add(new SetCardInfo("Mistform Dreamer", 93, Rarity.COMMON, mage.cards.m.MistformDreamer.class)); - cards.add(new SetCardInfo("Mistform Mask", 94, Rarity.COMMON, mage.cards.m.MistformMask.class)); + cards.add(new SetCardInfo("Mistform Dreamer", 93, Rarity.COMMON, mage.cards.m.MistformDreamer.class)); + cards.add(new SetCardInfo("Mistform Mask", 94, Rarity.COMMON, mage.cards.m.MistformMask.class)); cards.add(new SetCardInfo("Mistform Mutant", 95, Rarity.UNCOMMON, mage.cards.m.MistformMutant.class)); - cards.add(new SetCardInfo("Mistform Shrieker", 96, Rarity.UNCOMMON, mage.cards.m.MistformShrieker.class)); - cards.add(new SetCardInfo("Mistform Skyreaver", 97, Rarity.RARE, mage.cards.m.MistformSkyreaver.class)); - cards.add(new SetCardInfo("Mistform Stalker", 98, Rarity.UNCOMMON, mage.cards.m.MistformStalker.class)); - cards.add(new SetCardInfo("Mistform Wall", 99, Rarity.COMMON, mage.cards.m.MistformWall.class)); + cards.add(new SetCardInfo("Mistform Shrieker", 96, Rarity.UNCOMMON, mage.cards.m.MistformShrieker.class)); + cards.add(new SetCardInfo("Mistform Skyreaver", 97, Rarity.RARE, mage.cards.m.MistformSkyreaver.class)); + cards.add(new SetCardInfo("Mistform Stalker", 98, Rarity.UNCOMMON, mage.cards.m.MistformStalker.class)); + cards.add(new SetCardInfo("Mistform Wall", 99, Rarity.COMMON, mage.cards.m.MistformWall.class)); cards.add(new SetCardInfo("Mobilization", 44, Rarity.RARE, mage.cards.m.Mobilization.class)); cards.add(new SetCardInfo("Mountain", 343, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mountain", 344, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); @@ -247,12 +247,13 @@ public class Onslaught extends ExpansionSet { cards.add(new SetCardInfo("Riptide Laboratory", 322, Rarity.RARE, mage.cards.r.RiptideLaboratory.class)); cards.add(new SetCardInfo("Riptide Replicator", 309, Rarity.RARE, mage.cards.r.RiptideReplicator.class)); cards.add(new SetCardInfo("Riptide Shapeshifter", 109, Rarity.UNCOMMON, mage.cards.r.RiptideShapeshifter.class)); + cards.add(new SetCardInfo("Risky Move", 223, Rarity.RARE, mage.cards.r.RiskyMove.class)); cards.add(new SetCardInfo("Rorix Bladewing", 224, Rarity.RARE, mage.cards.r.RorixBladewing.class)); cards.add(new SetCardInfo("Rotlung Reanimator", 164, Rarity.RARE, mage.cards.r.RotlungReanimator.class)); cards.add(new SetCardInfo("Rummaging Wizard", 110, Rarity.UNCOMMON, mage.cards.r.RummagingWizard.class)); cards.add(new SetCardInfo("Run Wild", 279, Rarity.UNCOMMON, mage.cards.r.RunWild.class)); cards.add(new SetCardInfo("Sage Aven", 111, Rarity.COMMON, mage.cards.s.SageAven.class)); - cards.add(new SetCardInfo("Sandskin", 52, Rarity.COMMON, mage.cards.s.Sandskin.class)); + cards.add(new SetCardInfo("Sandskin", 52, Rarity.COMMON, mage.cards.s.Sandskin.class)); cards.add(new SetCardInfo("Screaming Seahawk", 112, Rarity.COMMON, mage.cards.s.ScreamingSeahawk.class)); cards.add(new SetCardInfo("Screeching Buzzard", 165, Rarity.COMMON, mage.cards.s.ScreechingBuzzard.class)); cards.add(new SetCardInfo("Searing Flesh", 225, Rarity.UNCOMMON, mage.cards.s.SearingFlesh.class)); @@ -261,12 +262,12 @@ public class Onslaught extends ExpansionSet { cards.add(new SetCardInfo("Secluded Steppe", 324, Rarity.COMMON, mage.cards.s.SecludedSteppe.class)); cards.add(new SetCardInfo("Serpentine Basilisk", 280, Rarity.UNCOMMON, mage.cards.s.SerpentineBasilisk.class)); cards.add(new SetCardInfo("Severed Legion", 166, Rarity.COMMON, mage.cards.s.SeveredLegion.class)); - cards.add(new SetCardInfo("Shade's Breath", 167, Rarity.UNCOMMON, mage.cards.s.ShadesBreath.class)); + cards.add(new SetCardInfo("Shade's Breath", 167, Rarity.UNCOMMON, mage.cards.s.ShadesBreath.class)); cards.add(new SetCardInfo("Shaleskin Bruiser", 226, Rarity.UNCOMMON, mage.cards.s.ShaleskinBruiser.class)); cards.add(new SetCardInfo("Shared Triumph", 53, Rarity.RARE, mage.cards.s.SharedTriumph.class)); cards.add(new SetCardInfo("Shepherd of Rot", 168, Rarity.COMMON, mage.cards.s.ShepherdOfRot.class)); cards.add(new SetCardInfo("Shock", 227, Rarity.COMMON, mage.cards.s.Shock.class)); - cards.add(new SetCardInfo("Sigil of the New Dawn", 55, Rarity.RARE, mage.cards.s.SigilOfTheNewDawn.class)); + cards.add(new SetCardInfo("Sigil of the New Dawn", 55, Rarity.RARE, mage.cards.s.SigilOfTheNewDawn.class)); cards.add(new SetCardInfo("Silent Specter", 169, Rarity.RARE, mage.cards.s.SilentSpecter.class)); cards.add(new SetCardInfo("Silklash Spider", 281, Rarity.RARE, mage.cards.s.SilklashSpider.class)); cards.add(new SetCardInfo("Silvos, Rogue Elemental", 282, Rarity.RARE, mage.cards.s.SilvosRogueElemental.class)); @@ -282,7 +283,7 @@ public class Onslaught extends ExpansionSet { cards.add(new SetCardInfo("Soulless One", 171, Rarity.UNCOMMON, mage.cards.s.SoullessOne.class)); cards.add(new SetCardInfo("Sparksmith", 235, Rarity.COMMON, mage.cards.s.Sparksmith.class)); cards.add(new SetCardInfo("Spined Basher", 172, Rarity.COMMON, mage.cards.s.SpinedBasher.class)); - cards.add(new SetCardInfo("Spitfire Handler", 236, Rarity.UNCOMMON, mage.cards.s.SpitfireHandler.class)); + cards.add(new SetCardInfo("Spitfire Handler", 236, Rarity.UNCOMMON, mage.cards.s.SpitfireHandler.class)); cards.add(new SetCardInfo("Spitting Gourna", 284, Rarity.COMMON, mage.cards.s.SpittingGourna.class)); cards.add(new SetCardInfo("Spurred Wolverine", 237, Rarity.COMMON, mage.cards.s.SpurredWolverine.class)); cards.add(new SetCardInfo("Stag Beetle", 285, Rarity.RARE, mage.cards.s.StagBeetle.class)); @@ -313,13 +314,13 @@ public class Onslaught extends ExpansionSet { cards.add(new SetCardInfo("Trade Secrets", 118, Rarity.RARE, mage.cards.t.TradeSecrets.class)); cards.add(new SetCardInfo("Tranquil Thicket", 326, Rarity.COMMON, mage.cards.t.TranquilThicket.class)); cards.add(new SetCardInfo("Treespring Lorian", 293, Rarity.COMMON, mage.cards.t.TreespringLorian.class)); - cards.add(new SetCardInfo("Tribal Golem", 311, Rarity.RARE, mage.cards.t.TribalGolem.class)); + cards.add(new SetCardInfo("Tribal Golem", 311, Rarity.RARE, mage.cards.t.TribalGolem.class)); cards.add(new SetCardInfo("Tribal Unity", 294, Rarity.UNCOMMON, mage.cards.t.TribalUnity.class)); cards.add(new SetCardInfo("Trickery Charm", 119, Rarity.COMMON, mage.cards.t.TrickeryCharm.class)); cards.add(new SetCardInfo("True Believer", 57, Rarity.RARE, mage.cards.t.TrueBeliever.class)); cards.add(new SetCardInfo("Undead Gladiator", 178, Rarity.RARE, mage.cards.u.UndeadGladiator.class)); cards.add(new SetCardInfo("Unholy Grotto", 327, Rarity.RARE, mage.cards.u.UnholyGrotto.class)); - cards.add(new SetCardInfo("Unified Strike", 58, Rarity.COMMON, mage.cards.u.UnifiedStrike.class)); + cards.add(new SetCardInfo("Unified Strike", 58, Rarity.COMMON, mage.cards.u.UnifiedStrike.class)); cards.add(new SetCardInfo("Venomspout Brackus", 295, Rarity.UNCOMMON, mage.cards.v.VenomspoutBrackus.class)); cards.add(new SetCardInfo("Visara the Dreadful", 179, Rarity.RARE, mage.cards.v.VisaraTheDreadful.class)); cards.add(new SetCardInfo("Vitality Charm", 296, Rarity.COMMON, mage.cards.v.VitalityCharm.class)); @@ -339,7 +340,7 @@ public class Onslaught extends ExpansionSet { cards.add(new SetCardInfo("Wirewood Lodge", 329, Rarity.RARE, mage.cards.w.WirewoodLodge.class)); cards.add(new SetCardInfo("Wirewood Pride", 303, Rarity.COMMON, mage.cards.w.WirewoodPride.class)); cards.add(new SetCardInfo("Wirewood Savage", 304, Rarity.COMMON, mage.cards.w.WirewoodSavage.class)); - cards.add(new SetCardInfo("Withering Hex", 181, Rarity.UNCOMMON, mage.cards.w.WitheringHex.class)); + cards.add(new SetCardInfo("Withering Hex", 181, Rarity.UNCOMMON, mage.cards.w.WitheringHex.class)); cards.add(new SetCardInfo("Wooded Foothills", 330, Rarity.RARE, mage.cards.w.WoodedFoothills.class, new CardGraphicInfo(new ObjectColor("RG"), null, false))); cards.add(new SetCardInfo("Words of War", 244, Rarity.RARE, mage.cards.w.WordsOfWar.class)); cards.add(new SetCardInfo("Words of Waste", 182, Rarity.RARE, mage.cards.w.WordsOfWaste.class));