* Made a lot of changes to handling of continuous and triggered abilities. This should fix the problems with Mage Singletons like Flyinging / Intimidate / Reach not working. Fixed also #533 and some other problems with copy effects of cards like Clone that did not end if e.g. Clone left the battlefield.

This commit is contained in:
LevelX2 2014-12-25 02:07:40 +01:00
parent f9b80e5c81
commit 4f1368f3de
25 changed files with 316 additions and 169 deletions

View file

@ -1,7 +1,15 @@
package org.mage.test.cards.copy;
import java.util.Iterator;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectsList;
import mage.cards.Card;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.NamePredicate;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -90,4 +98,51 @@ public class CloneTest extends CardTestPlayerBase {
assertPowerToughness(playerB, "Craw Wurm", 4, 4);
assertPowerToughness(playerA, "Craw Wurm", 6, 4);
}
// copy Nightmare test, check that the P/T setting effect ends
// if the clone leaves battlefield
@Test
public void testCopyNightmare() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 5);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 6);
addCard(Zone.BATTLEFIELD, playerB, "Forest", 1);
addCard(Zone.HAND, playerB, "Ranger's Guile");
addCard(Zone.HAND, playerA, "Clone");
addCard(Zone.HAND, playerA, "Disperse");
addCard(Zone.BATTLEFIELD, playerB, "Nightmare", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Clone");
setChoice(playerA, "Nightmare");
castSpell(1, PhaseStep.BEGIN_COMBAT, playerB, "Ranger's Guile", "Nightmare");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Disperse", "Nightmare");
setStopAt(2, PhaseStep.UPKEEP);
execute();
assertPermanentCount(playerB, "Nightmare", 1);
assertPowerToughness(playerB, "Nightmare", 6, 6);
assertPermanentCount(playerA, "Nightmare", 0);
assertHandCount(playerA, "Disperse", 0);
FilterCard filter = new FilterCard();
filter.add(new NamePredicate("Clone"));
Card card = playerA.getHand().getCards(filter, currentGame).iterator().next();
if (card != null) {
Assert.assertEquals("Power has to be 0 because copy from nightmare P/T ability may no longer be applied", 0, card.getPower().getValue());
}
Logger.getLogger(CloneTest.class).debug("EXISTING CONTINUOUS EFFECTS:");
for (ContinuousEffectsList effectsList : currentGame.getContinuousEffects().allEffectsLists) {
Iterator it = effectsList.iterator();
while (it.hasNext()) {
ContinuousEffect effect = (ContinuousEffect) it.next();
Logger.getLogger(CloneTest.class).debug("- " + effect.toString());
}
}
}
}

View file

@ -30,8 +30,12 @@ public class LazavDimirMastermindTest extends CardTestPlayerBase {
@Test
public void testCopySimpleCreature() {
addCard(Zone.BATTLEFIELD, playerA, "Lazav, Dimir Mastermind", 1);
// Codex Shredder - Artifact
// {T}: Target player puts the top card of his or her library into his or her graveyard.
// {5}, {T}, Sacrifice Codex Shredder: Return target card from your graveyard to your hand.
addCard(Zone.BATTLEFIELD, playerA, "Codex Shredder", 1);
// Flying 3/2
addCard(Zone.LIBRARY, playerB, "Assault Griffin",5);
skipInitShuffling();

View file

@ -136,6 +136,8 @@ public class ZoneChangeReplacementTest extends CardTestPlayerBase {
@Test
public void testHumilityDeactivatesReplacementEffectAbilities() {
// Protection from everything
// If Progenitus would be put into a graveyard from anywhere, reveal Progenitus and shuffle it into its owner's library instead.
addCard(Zone.BATTLEFIELD, playerA, "Progenitus");
// Enchantment {2}{W}{W}
// All creatures lose all abilities and are 1/1.

View file

@ -45,9 +45,16 @@ public class WorldAtWarTest extends CardTestPlayerBase {
@Test
public void testCardWithRebound() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
// Enchantment - Creatures you control have haste. (They can attack and as soon as they come under your control.)
addCard(Zone.BATTLEFIELD, playerA, "Fervor");
// After the first postcombat main phase this turn, there's an additional combat phase followed by
// an additional main phase. At the beginning of that combat, untap all creatures that attacked this turn.
// Rebound (If you cast this spell from your hand, exile it as it resolves. At the beginning of your
// next upkeep, you may cast this card from exile without paying its mana cost.)
addCard(Zone.HAND, playerA, "World at War");
// Creature - Human Soldier 2/1
addCard(Zone.BATTLEFIELD, playerA, "Elite Vanguard");
// Creature - Hound 1/1
addCard(Zone.BATTLEFIELD, playerA, "Warclamp Mastiff");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "World at War");
@ -71,7 +78,7 @@ public class WorldAtWarTest extends CardTestPlayerBase {
}
/**
* Tests creatures attack thrice
* Tests creatures attack three times
*/
@Test
public void testDoubleCast() {

View file

@ -60,12 +60,12 @@ public class ReefWormTest extends CardTestPlayerBase {
assertLife(playerA, 20);
assertLife(playerB, 20);
assertGraveyardCount(playerA, "Lightning Bolt", 4);
assertPermanentCount(playerB, "Fish", 0);
assertPermanentCount(playerB, "Whale", 0);
assertPermanentCount(playerB, "Kraken", 1);
assertGraveyardCount(playerB, "Reef Worm", 1);
assertGraveyardCount(playerA, "Lightning Bolt", 4);
}
}

View file

@ -6,7 +6,9 @@ log4j.logger.com.j256.ormlite=warn
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
log4j.appender.console.Threshold=INFO
log4j.appender.console.Threshold=info
#log4j.appender.console.Threshold=debug
#file log
log4j.appender.file=org.apache.log4j.FileAppender