From 436d1481ffa485f7c761f6204ace97903bfbf690 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 11 Nov 2013 16:54:14 +0100 Subject: [PATCH] [C13] Added Primal Vigor, Spoils of Victory and HuaTuo Honored Physician. --- .../commander2013/HuaTuoHonoredPhysician.java | 104 ++++++++++++ .../mage/sets/commander2013/PrimalVigor.java | 157 ++++++++++++++++++ .../sets/commander2013/SpoilsOfVictory.java | 75 +++++++++ .../mage/sets/gatecrash/NightveilSpecter.java | 2 - .../mage/game/turn/DeclareAttackersStep.java | 1 + Mage/src/mage/game/turn/Turn.java | 22 ++- 6 files changed, 352 insertions(+), 9 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/commander2013/HuaTuoHonoredPhysician.java create mode 100644 Mage.Sets/src/mage/sets/commander2013/PrimalVigor.java create mode 100644 Mage.Sets/src/mage/sets/commander2013/SpoilsOfVictory.java diff --git a/Mage.Sets/src/mage/sets/commander2013/HuaTuoHonoredPhysician.java b/Mage.Sets/src/mage/sets/commander2013/HuaTuoHonoredPhysician.java new file mode 100644 index 0000000000..3e7001ae7e --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2013/HuaTuoHonoredPhysician.java @@ -0,0 +1,104 @@ +/* + * 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.commander2013; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.ActivateIfConditionActivatedAbility; +import mage.abilities.condition.Condition; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.common.PutOnLibraryTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.TurnPhase; +import mage.constants.Zone; +import mage.filter.common.FilterCreatureCard; +import mage.game.Game; +import mage.game.turn.Phase; +import mage.target.common.TargetCardInYourGraveyard; + +/** + * + * @author LevelX2 + */ +public class HuaTuoHonoredPhysician extends CardImpl { + + public HuaTuoHonoredPhysician(UUID ownerId) { + super(ownerId, 149, "Hua Tuo, Honored Physician", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{G}{G}"); + this.expansionSetCode = "C13"; + this.supertype.add("Legendary"); + this.subtype.add("Human"); + + this.color.setGreen(true); + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + // {tap}: Put target creature card from your graveyard on top of your library. Activate this ability only during your turn, before attackers are declared. + Ability ability = new ActivateIfConditionActivatedAbility(Zone.BATTLEFIELD, new PutOnLibraryTargetEffect(true), new TapSourceCost(), MyTurnBeforeAttackersDeclaredCondition.getInstance()); + ability.addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard"))); + this.addAbility(ability); + } + + public HuaTuoHonoredPhysician(final HuaTuoHonoredPhysician card) { + super(card); + } + + @Override + public HuaTuoHonoredPhysician copy() { + return new HuaTuoHonoredPhysician(this); + } +} + +class MyTurnBeforeAttackersDeclaredCondition implements Condition { + private static MyTurnBeforeAttackersDeclaredCondition fInstance = new MyTurnBeforeAttackersDeclaredCondition(); + + public static Condition getInstance() { + return fInstance; + } + + @Override + public boolean apply(Game game, Ability source) { + if (game.getActivePlayerId().equals(source.getControllerId())) { + TurnPhase turnPhase = game.getTurn().getPhase().getType(); + if (turnPhase.equals(TurnPhase.BEGINNING) || turnPhase.equals(TurnPhase.PRECOMBAT_MAIN)) { + return true; + } + if (turnPhase.equals(TurnPhase.COMBAT)) { + return !game.getTurn().isDeclareAttackersStepStarted(); + } + } + return false; + } + + @Override + public String toString() { + return "during your turn, before attackers are declared"; + } +} diff --git a/Mage.Sets/src/mage/sets/commander2013/PrimalVigor.java b/Mage.Sets/src/mage/sets/commander2013/PrimalVigor.java new file mode 100644 index 0000000000..befac56302 --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2013/PrimalVigor.java @@ -0,0 +1,157 @@ +/* + * 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.commander2013; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +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.events.GameEvent; +import mage.game.permanent.Permanent; + +/** + * + * @author LevelX2 + */ +public class PrimalVigor extends CardImpl { + + public PrimalVigor(UUID ownerId) { + super(ownerId, 162, "Primal Vigor", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{4}{G}"); + this.expansionSetCode = "C13"; + + this.color.setGreen(true); + + // If one or more tokens would be put onto the battlefield, twice that many of those tokens are put onto the battlefield instead. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PrimalVigorTokenEffect())); + // If one or more +1/+1 counters would be placed on a creature, twice that many +1/+1 counters are placed on that creature instead. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PrimalVigorCounterEffect())); + + } + + public PrimalVigor(final PrimalVigor card) { + super(card); + } + + @Override + public PrimalVigor copy() { + return new PrimalVigor(this); + } +} + +class PrimalVigorTokenEffect extends ReplacementEffectImpl { + + public PrimalVigorTokenEffect() { + super(Duration.WhileOnBattlefield, Outcome.Copy); + staticText = "If one or more tokens would be put onto the battlefield, twice that many of those tokens are put onto the battlefield instead"; + } + + public PrimalVigorTokenEffect(final PrimalVigorTokenEffect effect) { + super(effect); + } + + @Override + public PrimalVigorTokenEffect copy() { + return new PrimalVigorTokenEffect(this); + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + switch (event.getType()) { + case CREATE_TOKEN: + return true; + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + event.setAmount(event.getAmount() * 2); + return false; + } + +} + +class PrimalVigorCounterEffect extends ReplacementEffectImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); + + PrimalVigorCounterEffect() { + super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false); + staticText = "If one or more +1/+1 counters would be placed on a creature, twice that many +1/+1 counters are placed on that creature instead"; + } + + PrimalVigorCounterEffect(final PrimalVigorCounterEffect effect) { + super(effect); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent p = game.getPermanent(event.getTargetId()); + if (p != null) { + p.addCounters(CounterType.P1P1.createInstance(event.getAmount() * 2), game, event.getAppliedEffects()); + return true; + } + return false; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType() == GameEvent.EventType.ADD_COUNTER) { + Permanent target = game.getPermanent(event.getTargetId()); + if (target != null && filter.match(target, game) + && event.getData() != null && event.getData().equals("+1/+1")) { + return true; + } + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public PrimalVigorCounterEffect copy() { + return new PrimalVigorCounterEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/commander2013/SpoilsOfVictory.java b/Mage.Sets/src/mage/sets/commander2013/SpoilsOfVictory.java new file mode 100644 index 0000000000..d106228321 --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2013/SpoilsOfVictory.java @@ -0,0 +1,75 @@ +/* + * 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.commander2013; + +import java.util.UUID; +import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.target.common.TargetCardInLibrary; + +/** + * + * @author LevelX2 + */ +public class SpoilsOfVictory extends CardImpl { + + private static final FilterCard filter = new FilterCard("Plains, Island, Swamp, Mountain, or Forest card"); + static { + filter.add(Predicates.or( + new SubtypePredicate("Plains"), + new SubtypePredicate("Island"), + new SubtypePredicate("Swamp"), + new SubtypePredicate("Mountain"), + new SubtypePredicate("Forest"))); + } + + public SpoilsOfVictory(UUID ownerId) { + super(ownerId, 172, "Spoils of Victory", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{G}"); + this.expansionSetCode = "C13"; + + this.color.setGreen(true); + + // Search your library for a Plains, Island, Swamp, Mountain, or Forest card and put that card onto the battlefield. Then shuffle your library. + this.getSpellAbility().addEffect(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), false, Outcome.PutLandInPlay)); + } + + public SpoilsOfVictory(final SpoilsOfVictory card) { + super(card); + } + + @Override + public SpoilsOfVictory copy() { + return new SpoilsOfVictory(this); + } +} diff --git a/Mage.Sets/src/mage/sets/gatecrash/NightveilSpecter.java b/Mage.Sets/src/mage/sets/gatecrash/NightveilSpecter.java index d45f67214b..d7589899e2 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/NightveilSpecter.java +++ b/Mage.Sets/src/mage/sets/gatecrash/NightveilSpecter.java @@ -156,12 +156,10 @@ class NightveilSpecterEffect extends AsThoughEffectImpl if (card.getCardType().contains(CardType.LAND)) { // If the revealed card is a land, you can play it only if it's your turn and you haven't yet played a land this turn. if (game.getActivePlayerId().equals(source.getControllerId()) && controller.canPlayLand()) { - card.setControllerId(source.getControllerId()); return true; } } else { if (card.getSpellAbility().spellCanBeActivatedRegularlyNow(source.getControllerId(), game)) { - card.setControllerId(source.getControllerId()); return true; } } diff --git a/Mage/src/mage/game/turn/DeclareAttackersStep.java b/Mage/src/mage/game/turn/DeclareAttackersStep.java index d78760620d..f5a00ad907 100644 --- a/Mage/src/mage/game/turn/DeclareAttackersStep.java +++ b/Mage/src/mage/game/turn/DeclareAttackersStep.java @@ -61,6 +61,7 @@ public class DeclareAttackersStep extends Step { @Override public void beginStep(Game game, UUID activePlayerId) { super.beginStep(game, activePlayerId); + game.getTurn().setDeclareAttackersStepStarted(true); game.getCombat().selectAttackers(game); } diff --git a/Mage/src/mage/game/turn/Turn.java b/Mage/src/mage/game/turn/Turn.java index 9c94d004e9..e756ac2bb1 100644 --- a/Mage/src/mage/game/turn/Turn.java +++ b/Mage/src/mage/game/turn/Turn.java @@ -28,18 +28,16 @@ package mage.game.turn; -import mage.constants.PhaseStep; -import mage.constants.TurnPhase; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.players.Player; - import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.UUID; - +import mage.constants.PhaseStep; +import mage.constants.TurnPhase; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.players.Player; /** * @@ -50,6 +48,7 @@ public class Turn implements Serializable { private Phase currentPhase; private UUID activePlayerId; private List phases = new ArrayList(); + private boolean declareAttackersStepStarted = false; public Turn() { phases.add(new BeginningPhase()); @@ -109,6 +108,7 @@ public class Turn implements Serializable { } public void play(Game game, UUID activePlayerId) { + this.setDeclareAttackersStepStarted(false); if (game.isPaused() || game.isGameOver()) { return; } @@ -270,6 +270,14 @@ public class Turn implements Serializable { //phase.play(game, activePlayerId); } + public boolean isDeclareAttackersStepStarted() { + return declareAttackersStepStarted; + } + + public void setDeclareAttackersStepStarted(boolean declareAttackersStepStarted) { + this.declareAttackersStepStarted = declareAttackersStepStarted; + } + public Turn copy() { return new Turn(this); }