mirror of
https://github.com/correl/mage.git
synced 2024-12-29 11:09:17 +00:00
Added a test.
This commit is contained in:
parent
4fa4b7198b
commit
54d28550b4
3 changed files with 56 additions and 35 deletions
|
@ -94,12 +94,12 @@ class IllGottenGainsEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
Target target = new TargetCardInYourGraveyard(0, 3, new FilterCard());
|
||||
if (target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), game)) {
|
||||
controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
|
||||
player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ package org.mage.test.cards.replacement;
|
|||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
|
@ -37,7 +36,6 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class LeylineOfTheVoidTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
|
@ -57,20 +55,51 @@ public class LeylineOfTheVoidTest extends CardTestPlayerBase {
|
|||
// If Leyline of the Void is in your opening hand, you may begin the game with it on the battlefield.
|
||||
// If a card would be put into an opponent's graveyard from anywhere, exile it instead.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Leyline of the Void");
|
||||
|
||||
|
||||
// {X}, {T}: Target opponent puts cards from the top of his or her library into his or her graveyard until a creature card or X cards are put into that graveyard this way, whichever comes first. If a creature card is put into that graveyard this way, sacrifice Helm of Obedience and put that card onto the battlefield under your control. X can't be 0.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Helm of Obedience");
|
||||
|
||||
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{X},{T}: Target opponent puts cards", playerB);
|
||||
setChoice(playerA, "X=1");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
|
||||
assertExileCount(playerB, 71); // All cards go to exile replaced from Leyline of the void
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Today i casted Ill-gotten Gains in EDH (with a leyline of the veil in
|
||||
* play) and the spell simply discarded both players hands not letting
|
||||
* either of us choose cards to get back, this ended up with me losing the
|
||||
* game as i was going to combo off some cards in yard.
|
||||
*/
|
||||
@Test
|
||||
public void testIllgottenGains() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
|
||||
|
||||
// If Leyline of the Void is in your opening hand, you may begin the game with it on the battlefield.
|
||||
// If a card would be put into an opponent's graveyard from anywhere, exile it instead.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Leyline of the Void");
|
||||
|
||||
// Exile Ill-Gotten Gains.
|
||||
// Each player discards his or her hand,
|
||||
// then returns up to three cards from his or her graveyard to his or her hand.
|
||||
addCard(Zone.HAND, playerA, "Ill-Gotten Gains"); // Sorcery - {2}{B}{B}
|
||||
addCard(Zone.HAND, playerA, "Silvercoat Lion", 4);
|
||||
addCard(Zone.HAND, playerB, "Silvercoat Lion", 4);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ill-Gotten Gains");
|
||||
setChoice(playerA, "Silvercoat Lion^Silvercoat Lion^Silvercoat Lion");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertExileCount(playerB, 4);
|
||||
assertHandCount(playerB, 0);
|
||||
|
||||
assertExileCount(playerA, 1);
|
||||
assertHandCount(playerA, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ package org.mage.test.player;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -94,7 +93,6 @@ import mage.target.TargetPermanent;
|
|||
import mage.target.TargetPlayer;
|
||||
import mage.target.TargetSource;
|
||||
import mage.target.TargetSpell;
|
||||
import mage.target.common.TargetCardInGraveyard;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetCreaturePermanentAmount;
|
||||
|
@ -638,42 +636,36 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (target instanceof TargetCardInGraveyard) {
|
||||
TargetCardInGraveyard targetCardInGraveyard = ((TargetCardInGraveyard) target);
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId : this.getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
possibleTargets.addAll(player.getGraveyard());
|
||||
}
|
||||
}
|
||||
|
||||
if (target instanceof TargetCard) {
|
||||
TargetCard targetCard = ((TargetCard) target);
|
||||
Set<UUID> possibleTargets = targetCard.possibleTargets(sourceId, target.getTargetController() == null ? getId() : target.getTargetController(), game);
|
||||
for (String choose2 : choices) {
|
||||
String[] targetList = choose2.split("\\^");
|
||||
boolean targetFound = false;
|
||||
for (UUID targetId : possibleTargets) {
|
||||
MageObject targetObject = game.getObject(targetId);
|
||||
if (targetObject != null) {
|
||||
for (String targetName : targetList) {
|
||||
Choice:
|
||||
for (String targetName : targetList) {
|
||||
for (UUID targetId : possibleTargets) {
|
||||
MageObject targetObject = game.getObject(targetId);
|
||||
if (targetObject != null) {
|
||||
if (targetObject.getName().equals(targetName)) {
|
||||
List<UUID> alreadyTargetted = targetCardInGraveyard.getTargets();
|
||||
if (targetCardInGraveyard.canTarget(targetObject.getId(), game)) {
|
||||
if (alreadyTargetted != null && !alreadyTargetted.contains(targetObject.getId())) {
|
||||
targetCardInGraveyard.add(targetObject.getId(), game);
|
||||
if (targetCard.canTarget(targetObject.getId(), game)) {
|
||||
if (targetCard.getTargets() != null && !targetCard.getTargets().contains(targetObject.getId())) {
|
||||
targetCard.add(targetObject.getId(), game);
|
||||
targetFound = true;
|
||||
if (target.getTargets().size() >= target.getMaxNumberOfTargets()) {
|
||||
break;
|
||||
break Choice;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetFound && targetCardInGraveyard.isChosen()) {
|
||||
choices.remove(choose2);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (targetFound && targetCard.isChosen()) {
|
||||
choices.remove(choose2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target instanceof TargetSource) {
|
||||
|
|
Loading…
Reference in a new issue