* Compost - Fixed that it triggered for all cards going to opponents graveyard (instead of only black cards).

This commit is contained in:
LevelX2 2015-09-28 15:14:50 +02:00
parent b95d7ca705
commit 0680560225
3 changed files with 78 additions and 11 deletions

View file

@ -32,9 +32,7 @@ import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.EntersOrLeavesTheBattlefieldSourceTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -98,19 +96,18 @@ class SunderingTitanDestroyLandEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
Set<UUID> lands = new HashSet<>();
if (controller != null && sourcePermanent != null) {
for (String landName : new String[] {"Forest","Island","Mountain","Plains","Swamp"}) {
FilterLandPermanent filter = new FilterLandPermanent(new StringBuilder(landName).append(" to destroy").toString());
for (String landName : new String[]{"Forest", "Island", "Mountain", "Plains", "Swamp"}) {
FilterLandPermanent filter = new FilterLandPermanent(landName + " to destroy");
filter.add(new SubtypePredicate(landName));
Target target = new TargetLandPermanent(1,1, filter, true);
Target target = new TargetLandPermanent(1, 1, filter, true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
controller.chooseTarget(outcome, target, source, game);
lands.add(target.getFirstTarget());
}
}
if (!lands.isEmpty()) {
int destroyedLands = 0;
for (UUID landId: lands) {
for (UUID landId : lands) {
Permanent land = game.getPermanent(landId);
if (land != null) {
if (land.destroy(source.getSourceId(), game, false)) {
@ -118,9 +115,9 @@ class SunderingTitanDestroyLandEffect extends OneShotEffect {
}
}
}
game.informPlayers(new StringBuilder(sourcePermanent.getName()).append(": ").append(destroyedLands).append(destroyedLands > 1 ? " lands were destroyed":"land was destroyed").toString());
game.informPlayers(sourcePermanent.getLogName() + ": " + destroyedLands + (destroyedLands > 1 ? " lands were" : "land was") + " destroyed");
}
return true;
}
return false;
}

View file

@ -54,10 +54,9 @@ public class Compost extends CardImpl {
super(ownerId, 235, "Compost", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
this.expansionSetCode = "7ED";
// Whenever a black card is put into an opponent's graveyard from anywhere, you may draw a card.
this.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility(
new DrawCardSourceControllerEffect(1), true, TargetController.OPPONENT));
new DrawCardSourceControllerEffect(1), true, filter, TargetController.OPPONENT));
}
public Compost(final Compost card) {

View file

@ -0,0 +1,71 @@
/*
* 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.triggers.dies;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class SunderingTitanTest extends CardTestPlayerBase {
/**
* the card Sundering Titan doesn't trigger for the aposing player
*
*/
@Test
public void testComesIntoTriggeredAbility() {
// // When Sundering Titan enters the battlefield or leaves the battlefield, choose a land of each basic land type, then destroy those lands.
addCard(Zone.HAND, playerA, "Sundering Titan"); // {8}
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2);
addCard(Zone.BATTLEFIELD, playerB, "Plains", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sundering Titan");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Sundering Titan", 1);
assertGraveyardCount(playerA, "Swamp", 1);
assertGraveyardCount(playerA, "Forest", 1);
assertGraveyardCount(playerA, "Island", 1);
assertGraveyardCount(playerB, "Mountain", 1);
assertGraveyardCount(playerB, "Plains", 1);
}
}