Merge origin/master

This commit is contained in:
fireshoes 2015-07-20 11:29:24 -05:00
commit a7f893ca25
12 changed files with 438 additions and 62 deletions

View file

@ -0,0 +1,63 @@
/*
* 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.coldsnap;
import java.util.UUID;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.keyword.RecoverAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
/**
*
* @author LevelX2
*/
public class SunsBounty extends CardImpl {
public SunsBounty(UUID ownerId) {
super(ownerId, 18, "Sun's Bounty", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{W}");
this.expansionSetCode = "CSP";
// You gain 4 life.
this.getSpellAbility().addEffect(new GainLifeEffect(4));
// Recover {1}{W}
this.addAbility(new RecoverAbility(new ManaCostsImpl("{1}{W}"), this));
}
public SunsBounty(final SunsBounty card) {
super(card);
}
@Override
public SunsBounty copy() {
return new SunsBounty(this);
}
}

View file

@ -75,7 +75,6 @@ public class DarettiScrapSavant extends CardImpl {
this.expansionSetCode = "C14";
this.subtype.add("Daretti");
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(3)), false));
// +2: Discard up to two cards, then draw that many cards.
@ -126,7 +125,7 @@ class DarettiDiscardDrawEffect extends OneShotEffect {
TargetDiscard target = new TargetDiscard(0, 2, new FilterCard(), controller.getId());
target.choose(outcome, controller.getId(), source.getSourceId(), game);
int count = 0;
for (UUID cardId: target.getTargets()) {
for (UUID cardId : target.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
controller.discard(card, source, game);
@ -160,9 +159,9 @@ class DarettiSacrificeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetControlledPermanent(1,1,new FilterControlledArtifactPermanent(), true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) &&
controller.chooseTarget(outcome, target, source, game)) {
Target target = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent(), true);
if (target.canChoose(source.getSourceId(), controller.getId(), game)
&& controller.chooseTarget(outcome, target, source, game)) {
Permanent artifact = game.getPermanent(target.getFirstTarget());
if (artifact != null && artifact.sacrifice(source.getSourceId(), game)) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
@ -178,7 +177,9 @@ class DarettiSacrificeEffect extends OneShotEffect {
}
class DarettiScrapSavantEmblem extends Emblem {
// You get an emblem with "Whenever an artifact is put into your graveyard from the battlefield, return that card to the battlefield at the beginning of the next end step."
public DarettiScrapSavantEmblem() {
this.setName("Emblem - Daretti");
this.getAbilities().add(new DarettiScrapSavantTriggeredAbility());
@ -208,10 +209,10 @@ class DarettiScrapSavantTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getToZone() == Zone.GRAVEYARD &&
zEvent.getFromZone() == Zone.BATTLEFIELD &&
zEvent.getTarget().getCardType().contains(CardType.ARTIFACT) &&
zEvent.getTarget().getOwnerId().equals(this.controllerId)) {
if (zEvent.getToZone() == Zone.GRAVEYARD
&& zEvent.getFromZone() == Zone.BATTLEFIELD
&& zEvent.getTarget().getCardType().contains(CardType.ARTIFACT)
&& zEvent.getTarget().getOwnerId().equals(this.controllerId)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(zEvent.getTargetId()));
}
@ -245,9 +246,9 @@ class DarettiScrapSavantEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
if (card != null && game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
effect.setText("return that card to the battlefield at the beginning of the next end step");
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY);
delayedAbility.setSourceId(source.getSourceId());
@ -258,4 +259,4 @@ class DarettiScrapSavantEffect extends OneShotEffect {
}
return false;
}
}
}

View file

@ -38,8 +38,9 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
import mage.target.Target;
import mage.target.common.TargetLandPermanent;
import mage.target.common.TargetControlledPermanent;
/**
*
@ -55,7 +56,7 @@ public class UnstableFrontier extends CardImpl {
this.addAbility(new ColorlessManaAbility());
// {tap}: Target land you control becomes the basic land type of your choice until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesBasicLandTargetEffect(Duration.EndOfTurn), new TapSourceCost());
Target target = new TargetLandPermanent();
Target target = new TargetControlledPermanent(new FilterControlledLandPermanent());
ability.addTarget(target);
this.addAbility(ability);
}

View file

@ -34,8 +34,8 @@ import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -76,21 +76,21 @@ public class RallyTheAncestors extends CardImpl {
}
class RallyTheAncestorsEffect extends OneShotEffect {
RallyTheAncestorsEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "Return each creature card with converted mana cost X or less from your graveyard to the battlefield. Exile those creatures at the beginning of your next upkeep";
}
RallyTheAncestorsEffect(final RallyTheAncestorsEffect effect) {
super(effect);
}
@Override
public RallyTheAncestorsEffect copy() {
return new RallyTheAncestorsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
@ -101,14 +101,15 @@ class RallyTheAncestorsEffect extends OneShotEffect {
Set<Card> cards = player.getGraveyard().getCards(filter, game);
for (Card card : cards) {
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
Effect exileEffect = new ExileTargetEffect("Exile those creatures at the beginning of your next upkeep");
exileEffect.setTargetPointer(new FixedTarget(card.getId()));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
if (player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) {
Effect exileEffect = new ExileTargetEffect("Exile those creatures at the beginning of your next upkeep");
exileEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
}
}
}
return true;

View file

@ -77,13 +77,13 @@ public class HellkiteTyrant extends CardImpl {
// Trample
this.addAbility(TrampleAbility.getInstance());
// Whenever Hellkite Tyrant deals combat damage to a player, gain control of all artifacts that player controls.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new HellkiteTyrantEffect(),false, true));
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new HellkiteTyrantEffect(), false, true));
// At the beginning of your upkeep, if you control twenty or more artifacts, you win the game.
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new WinGameSourceControllerEffect(), TargetController.YOU, false);
this.addAbility(new ConditionalTriggeredAbility(
ability,
new PermanentsOnTheBattlefieldCondition(new FilterArtifactPermanent(), PermanentsOnTheBattlefieldCondition.CountType.MORE_THAN,19),
new PermanentsOnTheBattlefieldCondition(new FilterArtifactPermanent(), PermanentsOnTheBattlefieldCondition.CountType.MORE_THAN, 19),
"At the beginning of your upkeep, if you control twenty or more artifacts, you win the game."));
}
@ -123,7 +123,7 @@ class HellkiteTyrantEffect extends OneShotEffect {
FilterPermanent filter = new FilterArtifactPermanent();
filter.add(new ControllerIdPredicate(player.getId()));
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId() , game);
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
for (Permanent permanent : permanents) {
ContinuousEffect effect = new HellkiteTyrantControlEffect(source.getControllerId());
effect.setTargetPointer(new FixedTarget(permanent.getId()));

View file

@ -1,16 +1,16 @@
/*
* 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
@ -20,20 +20,19 @@
* 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.magic2011;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.Mana;
import mage.abilities.effects.common.BasicManaEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
/**
*
@ -45,6 +44,7 @@ public class PyreticRitual extends CardImpl {
super(ownerId, 153, "Pyretic Ritual", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{R}");
this.expansionSetCode = "M11";
// Add {R}{R}{R} to your mana pool.
this.getSpellAbility().addEffect(new BasicManaEffect(Mana.RedMana(3)));
}

View file

@ -81,25 +81,26 @@ class DaysUndoingEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player sourcePlayer = game.getPlayer(source.getControllerId());
for (UUID playerId: sourcePlayer.getInRange()) {
for (UUID playerId : sourcePlayer.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card: player.getHand().getCards(game)) {
for (Card card : player.getHand().getCards(game)) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
for (Card card: player.getGraveyard().getCards(game)) {
for (Card card : player.getGraveyard().getCards(game)) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
game.informPlayers(player.getLogName() + " puts his or her hand and graveyard into his or her library");
player.shuffleLibrary(game);
}
}
game.getState().handleSimultaneousEvent(game); // needed here so state based triggered effects
for (UUID playerId: sourcePlayer.getInRange()) {
game.getState().handleSimultaneousEvent(game); // needed here so state based triggered effects
for (UUID playerId : sourcePlayer.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.drawCards(7, game);
}
}
}
return true;
}
@ -109,4 +110,4 @@ class DaysUndoingEffect extends OneShotEffect {
return new DaysUndoingEffect(this);
}
}
}

View file

@ -31,7 +31,6 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.common.SpellMasteryCondition;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
@ -98,10 +97,10 @@ class GatherThePackEffect extends OneShotEffect {
}
TargetCard target = new TargetCard(0, max, Zone.LIBRARY, new FilterCreatureCard("creature card" + (max > 1 ? "s" : "") + " to put into your hand"));
if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.LIBRARY, Zone.HAND, source, game);
Cards cardsToHand = new CardsImpl(target.getTargets());
if (cardsToHand.size() > 0) {
cards.removeAll(cardsToHand);
controller.moveCards(cardsToHand, Zone.LIBRARY, Zone.HAND, source, game);
}
}
}

View file

@ -0,0 +1,105 @@
/*
* 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 org.mage.test.cards.abilities.keywords;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class RecoverTest extends CardTestPlayerBase {
/**
* 702.58a Recover is a triggered ability that functions only while the card
* with recover is in a players graveyard. Recover [cost] means When a
* creature is put into your graveyard from the battlefield, you may pay
* [cost]. If you do, return this card from your graveyard to your hand.
* Otherwise, exile this card.
*/
@Test
public void testReturnToHand() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
// You gain 4 life.
// Recover {1}{W}
addCard(Zone.HAND, playerA, "Sun's Bounty");
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.HAND, playerB, "Lightning Bolt", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sun's Bounty");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", "Silvercoat Lion");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerB, "Lightning Bolt", 1);
assertHandCount(playerA, "Sun's Bounty", 1);
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
assertLife(playerA, 24);
assertTappedCount("Plains", true, 4);
}
@Test
public void testGoingToExile() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
// You gain 4 life.
// Recover {1}{W}
addCard(Zone.HAND, playerA, "Sun's Bounty");
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.HAND, playerB, "Lightning Bolt", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sun's Bounty");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", "Silvercoat Lion");
setChoice(playerA, "No");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertTappedCount("Plains", true, 2);
assertGraveyardCount(playerB, "Lightning Bolt", 1);
assertExileCount("Sun's Bounty", 1);
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
assertLife(playerA, 24);
}
}

View file

@ -8,7 +8,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* also tests cost reduction effects
*
*
* @author BetaSteward
*/
public class CostModificationTest extends CardTestPlayerBase {
@ -46,16 +46,12 @@ public class CostModificationTest extends CardTestPlayerBase {
}
/**
* Test that cost reduction also works with mana source restriction
* Myr Superion
* Spend only mana produced by creatures to cast Myr Superion
* Test that cost reduction also works with mana source restriction Myr
* Superion Spend only mana produced by creatures to cast Myr Superion
*
* Etherium Sculptor {1}{U}
* Artifact Creature - Vedalken Artificer
* 1/2
* Etherium Sculptor {1}{U} Artifact Creature - Vedalken Artificer 1/2
* Artifact spells you cast cost {1} less to cast.
*/
@Test
public void testCostReductionWithManaSourceRestrictionWorking() {
// Artifact spells you cast cost {1} less to cast
@ -95,4 +91,31 @@ public class CostModificationTest extends CardTestPlayerBase {
assertHandCount(playerA, "Myr Superion", 1); // Can't be cast because mana was not produced by a creature
}
/*
I had Goblin Electromancer, but somehow Pyretic Ritual wasn't cheaper howeverDesperate Ritual was.
*/
@Test
public void testCostReductionForPyreticRitual() {
// Instant and sorcery spells you cast cost {1} less to cast.
addCard(Zone.BATTLEFIELD, playerA, "Goblin Electromancer");
addCard(Zone.BATTLEFIELD, playerA, "Mountain");
// Add {R}{R}{R} to your mana pool.
addCard(Zone.HAND, playerA, "Pyretic Ritual");
// Fated Conflagration deals 5 damage to target creature or planeswalker.
// If it's your turn, scry 2. (Look at the top two cards of your library, then put any number of them on the bottom of your library and the rest on top in any order.)
addCard(Zone.HAND, playerA, "Fated Conflagration");
addCard(Zone.BATTLEFIELD, playerB, "Carnivorous Moss-Beast"); // 4/5
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pyretic Ritual");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Fated Conflagration", "Carnivorous Moss-Beast");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Pyretic Ritual", 1);
assertGraveyardCount(playerA, "Fated Conflagration", 1);
assertGraveyardCount(playerB, "Carnivorous Moss-Beast", 1);
}
}

View file

@ -36,12 +36,12 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
*
* @author LevelX2
*/
public class SidisiBroodTyrantTest extends CardTestPlayerBase {
/**
* Tests that if Sidisi, Brood Tyrant leaves the battlefield
* before it's first ability resolves, there will be no Zombie token added to the battlefield
* Tests that if Sidisi, Brood Tyrant leaves the battlefield before it's
* first ability resolves, there will be no Zombie token added to the
* battlefield
*
*/
@Test
@ -73,4 +73,43 @@ public class SidisiBroodTyrantTest extends CardTestPlayerBase {
}
/**
* Another potential bug would be related to Sidisi, Brood Tyrant 's second
* trigger. If there is one in play and I play a Satyr Wayfinder or a Gather
* the Pack, then mill some creatures, Sidisi should trigger and make a
* Zombie token, right? This doesn't seem to work currently.
*
*/
@Test
public void testDiesTriggeredAbilityNormal() {
// {1}{B}{G}{U}
// Whenever Sidisi, Brood Tyrant enters the battlefield or attacks, put the top three cards of your library into your graveyard
// Whenever one or more creature cards are put into your graveyard from your library, put a 2/2 black Zombie creature token onto the battlefield.
addCard(Zone.HAND, playerA, "Sidisi, Brood Tyrant"); // 2/2 {1}{B}{G}{U}
// When Satyr Wayfinder enters the battlefield, reveal the top four cards of your library. You may put a land card from among them into your hand. Put the rest into your graveyard.
addCard(Zone.HAND, playerA, "Satyr Wayfinder"); // 1/1 {1}{G}
addCard(Zone.BATTLEFIELD, playerA, "Swamp");
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, "Island");
addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 3);
addCard(Zone.LIBRARY, playerA, "Swamp", 1);
addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 3);
skipInitShuffling();
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sidisi, Brood Tyrant");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Satyr Wayfinder");
setChoice(playerA, "Yes");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, "Sidisi, Brood Tyrant", 1);
assertPermanentCount(playerA, "Satyr Wayfinder", 1);
assertHandCount(playerA, "Swamp", 1);
assertGraveyardCount(playerA, "Silvercoat Lion", 6);
assertPermanentCount(playerA, "Zombie", 2);
}
}

View file

@ -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.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSourceEffect;
import mage.abilities.effects.common.ReturnToHandSourceEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
/**
* 702.58a Recover is a triggered ability that functions only while the card
* with recover is in a players graveyard. Recover [cost] means When a
* creature is put into your graveyard from the battlefield, you may pay [cost].
* If you do, return this card from your graveyard to your hand. Otherwise,
* exile this card.
*
* @author LevelX2
*/
public class RecoverAbility extends TriggeredAbilityImpl {
public RecoverAbility(Cost cost, Card card) {
super(Zone.GRAVEYARD, new RecoverEffect(cost, card.getCardType().contains(CardType.CREATURE)), false);
}
public RecoverAbility(final RecoverAbility ability) {
super(ability);
}
@Override
public RecoverAbility copy() {
return new RecoverAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getFromZone().equals(Zone.BATTLEFIELD) && zEvent.getToZone().equals(Zone.GRAVEYARD)) {
if (zEvent.getTarget().getOwnerId().equals(getControllerId())
&& !zEvent.getTarget().getId().equals(getSourceId())) {
return true;
}
}
return false;
}
@Override
public String getRule() {
return super.getRule();
}
}
class RecoverEffect extends OneShotEffect {
protected Cost cost;
public RecoverEffect(Cost cost, boolean creature) {
super(Outcome.ReturnToHand);
this.cost = cost;
this.staticText = setText(cost, creature);
}
public RecoverEffect(final RecoverEffect effect) {
super(effect);
this.cost = effect.cost;
}
@Override
public RecoverEffect copy() {
return new RecoverEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (controller != null && sourceCard != null
&& game.getState().getZone(source.getSourceId()).equals(Zone.GRAVEYARD)) {
if (controller.chooseUse(Outcome.Damage, "Pay " + cost.getText() + " to recover " + sourceCard.getLogName() + "? (Otherwise the card will be exiled)", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), controller.getId(), false)) {
return new ReturnToHandSourceEffect().apply(game, source);
}
}
return new ExileSourceEffect().apply(game, source);
}
return false;
}
private String setText(Cost cost, boolean creature) {
StringBuilder sb = new StringBuilder();
sb.append("Recover");
if (cost instanceof ManaCost) {
sb.append(" ").append(cost.getText()).append(" ");
} else {
sb.append("&mdash;").append(cost.getText()).append(". ");
}
sb.append("<i>(When ").append(creature ? "another" : "a").append(" creature is put into your graveyard from the battlefield, you may pay ");
sb.append(cost.getText());
sb.append(". If you do, return this card from your graveyard to your hand. Otherwise, exile this card.)</i>");
return sb.toString();
}
}