Test and fix for sacrificing creature with protection

This commit is contained in:
magenoxx 2012-06-11 14:25:27 +04:00
parent 8bceab52de
commit 5199e2e81a
3 changed files with 43 additions and 31 deletions

View file

@ -0,0 +1,29 @@
package org.mage.test.cards.abilities.oneshot.sacrifice;
import mage.Constants;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author noxx
*/
public class GethsVerdictTest extends CardTestPlayerBase {
/**
* Checks that pro black can still be sacrificed
*/
@Test
public void testVersusProtectionFromBlack() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
addCard(Constants.Zone.HAND, playerA, "Geth's Verdict");
addCard(Constants.Zone.BATTLEFIELD, playerB, "White Knight");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Geth's Verdict");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerB, "White Knight", 0);
assertLife(playerB, 19);
}
}

View file

@ -1,22 +0,0 @@
package org.mage.test.cards.targets.sacrifice;
import mage.Constants;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestBase;
public class GethsVerdict extends CardTestBase {
@Test
public void test() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
addCard(Constants.Zone.HAND, playerA, "Geth's Verdict");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Copper Myr");
castSpell(playerA, "Geth's Verdict");
execute();
assertPermanentCount(playerB, "Copper Myr", 0);
assertLife(playerB, 19);
}
}

View file

@ -28,9 +28,6 @@
package mage.target; package mage.target;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.Constants.Zone; import mage.Constants.Zone;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -38,6 +35,10 @@ import mage.filter.FilterPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -108,8 +109,9 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
} }
/** /**
* Checks if there are enough {@link Permanent} that can be chosen. Should only be used * Checks if there are enough {@link Permanent} that can be chosen.
* for Ability targets since this checks for protection, shroud etc. *
* Takes into account notTarget parameter, it case it's true doesn't check for protection, shroud etc.
* *
* @param sourceId - the target event source * @param sourceId - the target event source
* @param sourceControllerId - controller of the target event source * @param sourceControllerId - controller of the target event source
@ -124,11 +126,14 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
int count = 0; int count = 0;
MageObject targetSource = game.getObject(sourceId); MageObject targetSource = game.getObject(sourceId);
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { if (!targets.containsKey(permanent.getId())) {
if (!notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
count++; count++;
if (count >= remainingTargets) if (count >= remainingTargets) {
return true; return true;
} }
}
}
} }
return false; return false;
} }