Added test.

This commit is contained in:
LevelX2 2016-03-07 18:30:58 +01:00
parent 0a31a8b479
commit d7ae1c51c9
4 changed files with 126 additions and 57 deletions

View file

@ -1,7 +1,9 @@
package org.mage.test.cards.copy;
import mage.constants.CardType;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import org.junit.Assert;
@ -36,43 +38,49 @@ public class ProgenitorMimicTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Runeclaw Bear", 1);
assertPermanentCount(playerB, "Runeclaw Bear", 2);
int tokens = 0;
int tokens = 0;
int nonTokens = 0;
for (Permanent permanent : currentGame.getBattlefield().getAllPermanents()) {
if (permanent.getControllerId().equals(playerB.getId())) {
if (permanent.getCardType().contains(CardType.CREATURE)) {
if (permanent instanceof PermanentToken) {
tokens++;
tokens++;
} else {
nonTokens++;
nonTokens++;
}
}
}
}
Assert.assertEquals("Only one non token permanent ",1, nonTokens);
Assert.assertEquals("Only one token permanent ",1, tokens);
}
/**
* If you have Progenitor Mimic copy a creature it gets all of the abilities plus "At the beginning of upkeep
* if this creature isn't a token, put a token that's a copy of this creature".
* Up to this point everything works correctly.
*
* If you then summon another mimic and have it be a copy of the first mimic it should have "At the beginning of
* upkeep if this creature isn't a token, put a token that's a copy of this creature" two times. The second mimic
* would then make two copies and the first mimic would make one copy every turn. Right now the second mimc only
* makes one copy per turn.
*
* 706.9a Some copy effects cause the copy to gain an ability as part of the copying process. This ability becomes
* part of the copiable values for the copy, along with any other abilities that were copied.
* Example: Quirion Elves enters the battlefield and an Unstable Shapeshifter copies it. The copiable values of the
* Shapeshifter now match those of the Elves, except that the Shapeshifter also has the ability Whenever a creature
* enters the battlefield, Unstable Shapeshifter becomes a copy of that creature and gains this ability. Then a Clone
* enters the battlefield as a copy of the Unstable Shapeshifter. The Clone copies the new copiable values of the
* Shapeshifter, including the ability that the Shapeshifter gave itself when it copied the Elves.
Assert.assertEquals("Only one non token permanent ", 1, nonTokens);
Assert.assertEquals("Only one token permanent ", 1, tokens);
}
/**
* If you have Progenitor Mimic copy a creature it gets all of the abilities
* plus "At the beginning of upkeep if this creature isn't a token, put a
* token that's a copy of this creature". Up to this point everything works
* correctly.
*
* If you then summon another mimic and have it be a copy of the first mimic
* it should have "At the beginning of upkeep if this creature isn't a
* token, put a token that's a copy of this creature" two times. The second
* mimic would then make two copies and the first mimic would make one copy
* every turn. Right now the second mimc only makes one copy per turn.
*
* 706.9a Some copy effects cause the copy to gain an ability as part of the
* copying process. This ability becomes part of the copiable values for the
* copy, along with any other abilities that were copied. Example: Quirion
* Elves enters the battlefield and an Unstable Shapeshifter copies it. The
* copiable values of the Shapeshifter now match those of the Elves, except
* that the Shapeshifter also has the ability Whenever a creature enters
* the battlefield, Unstable Shapeshifter becomes a copy of that creature
* and gains this ability. Then a Clone enters the battlefield as a copy of
* the Unstable Shapeshifter. The Clone copies the new copiable values of
* the Shapeshifter, including the ability that the Shapeshifter gave itself
* when it copied the Elves.
*
*/
@Test
public void testTwoMimic() {
@ -81,7 +89,7 @@ public class ProgenitorMimicTest extends CardTestPlayerBase {
// Return target permanent you control to its owner's hand. You gain 4 life.
addCard(Zone.HAND, playerA, "Narrow Escape");
// You may have Progenitor Mimic enter the battlefield as a copy of any creature on the battlefield except
// You may have Progenitor Mimic enter the battlefield as a copy of any creature on the battlefield except
// it gains "At the beginning of your upkeep, if this creature isn't a token, put a token onto the battlefield
// that's a copy of this creature."
addCard(Zone.HAND, playerB, "Progenitor Mimic", 2);
@ -90,9 +98,9 @@ public class ProgenitorMimicTest extends CardTestPlayerBase {
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Progenitor Mimic");
setChoice(playerB, "Runeclaw Bear");
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Narrow Escape", "Runeclaw Bear");
// Begin of upkeep 1 token added
castSpell(4, PhaseStep.PRECOMBAT_MAIN, playerB, "Progenitor Mimic");
setChoice(playerB, "Runeclaw Bear");
@ -107,27 +115,71 @@ public class ProgenitorMimicTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Narrow Escape", 1);
assertPermanentCount(playerA, "Runeclaw Bear", 0);
assertHandCount(playerA, "Runeclaw Bear", 1);
assertPermanentCount(playerB, "Runeclaw Bear", 6);
int tokens = 0;
int tokens = 0;
int nonTokens = 0;
for (Permanent permanent : currentGame.getBattlefield().getAllPermanents()) {
if (permanent.getControllerId().equals(playerB.getId())) {
if (permanent.getCardType().contains(CardType.CREATURE)) {
if (permanent instanceof PermanentToken) {
tokens++;
tokens++;
} else {
nonTokens++;
nonTokens++;
}
}
}
}
Assert.assertEquals("Two non token permanents ",2, nonTokens);
Assert.assertEquals("Four token permanents",4, tokens);
}
Assert.assertEquals("Two non token permanents ", 2, nonTokens);
Assert.assertEquals("Four token permanents", 4, tokens);
}
/**
* In a Commander FFA game, I controlled 5 vampires (one of which was
* Captivating Vampire). My opponent cast Progenitor Mimic, copying
* Captivating Vampire. I used the ability of my Captivating Vampire to gain
* control of his Mimic/Vampire but the buff didn't switch control. His
* other vampire still got the buff even after I gained control of the
* Mimic/Vampire.
*
* Did not get to see if the Mimic/Vampire produced tokens on the right side
* of the field (my side) as the game ended just after my turn.
*/
@Test
public void testChangeControl() {
// Other Vampire creatures you control get +1/+1.
// Tap five untapped Vampires you control: Gain control of target creature. It becomes a Vampire in addition to its other types.
addCard(Zone.BATTLEFIELD, playerA, "Captivating Vampire", 1); // 2/2
// Lifelink
addCard(Zone.BATTLEFIELD, playerA, "Child of Night", 4); // 2/1
// You may have Progenitor Mimic enter the battlefield as a copy of any creature on the battlefield except
// it gains "At the beginning of your upkeep, if this creature isn't a token, put a token onto the battlefield
// that's a copy of this creature."
addCard(Zone.HAND, playerB, "Progenitor Mimic", 1);
addCard(Zone.BATTLEFIELD, playerB, "Island", 3);
addCard(Zone.BATTLEFIELD, playerB, "Forest", 3);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Progenitor Mimic");
setChoice(playerB, "Captivating Vampire");
activateAbility(2, PhaseStep.POSTCOMBAT_MAIN, playerA, "Tap five untapped Vampire", "Captivating Vampire[only copy]");
setChoice(playerA, "Captivating Vampire");
setChoice(playerA, "Child of Night");
setChoice(playerA, "Child of Night");
setChoice(playerA, "Child of Night");
setChoice(playerA, "Child of Night");
setStopAt(2, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, "Captivating Vampire", 2);
assertPowerToughness(playerA, "Captivating Vampire", 3, 3, Filter.ComparisonScope.All); // +1 from the other Captivating Vampire
assertPowerToughness(playerA, "Child of Night", 4, 3, Filter.ComparisonScope.All); // +2 from the two Captivating Vampire
}
}

View file

@ -318,10 +318,23 @@ public class TestPlayer implements Player {
}
}
} else {
boolean originOnly = false;
boolean copyOnly = false;
if (targetName.endsWith("]")) {
if (targetName.endsWith("[no copy]")) {
originOnly = true;
targetName = targetName.substring(0, targetName.length() - 9);
}
if (targetName.endsWith("[only copy]")) {
copyOnly = true;
targetName = targetName.substring(0, targetName.length() - 11);
}
}
for (UUID id : currentTarget.possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) {
if (!currentTarget.getTargets().contains(id)) {
MageObject object = game.getObject(id);
if (object != null
&& ((object.isCopy() && !originOnly) || (!object.isCopy() && !copyOnly))
&& ((!targetName.isEmpty() && object.getName().startsWith(targetName)) || (targetName.isEmpty() && object.getName().isEmpty()))) {
if (currentTarget.getNumberOfTargets() == 1) {
currentTarget.clearChosen();