mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Test and fix for sacrificing creature with protection
This commit is contained in:
parent
8bceab52de
commit
5199e2e81a
3 changed files with 43 additions and 31 deletions
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -28,9 +28,6 @@
|
|||
|
||||
package mage.target;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -38,6 +35,10 @@ import mage.filter.FilterPermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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
|
||||
* for Ability targets since this checks for protection, shroud etc.
|
||||
* Checks if there are enough {@link Permanent} that can be chosen.
|
||||
*
|
||||
* Takes into account notTarget parameter, it case it's true doesn't check for protection, shroud etc.
|
||||
*
|
||||
* @param sourceId - 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;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
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++;
|
||||
if (count >= remainingTargets)
|
||||
if (count >= remainingTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue