Fixing copy and cast from exile effects (#10436)

* Added unit test for magefree/mage#10435

* Added test for potential breakage of prosper functionality

* Copies of cards are now created in the right zone

* Added PlayCardTriggeredAbility

This triggered ability checks to make sure a card was actually played (as opposed to a copy of a card).
Common abilities have been refactored to use this new ability

* Added mizzix's mastery overload test

* Fixed Mizzix's mastery overload

* Added new ability to Juju Bubble

---------

Co-authored-by: xenohedron <xenohedron@users.noreply.github.com>
This commit is contained in:
Alexander Novotny 2023-06-08 18:32:59 -07:00 committed by GitHub
parent 2f79343bc8
commit a0f8a42699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 337 additions and 225 deletions

View file

@ -0,0 +1,41 @@
package org.mage.test.cards.single.afc;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import mage.constants.PhaseStep;
import mage.constants.Zone;
public class ProsperTomeBoundTest extends CardTestPlayerBase {
static final String prosper = "Prosper, Tome-Bound";
@Test
// Author: alexander-novo
// As copies of cards aren't themselves cards, and Prosper specifies that his ability only triggers when a *card* is played from exile,
// Prosper shouldn't work with cards a la Mizzix's Mastery, which creates copies of cards in exile and then casts them.
// As of right now, this is true, but I'd guess this is due to the fact that effects like Mizzix's Mastery currently don't cast the copies from exile properly,
// not because Prosper is actually checking that the spells come from actual cards.
public void castCopyFromExileTest() {
String mastery = "Mizzix's Mastery";
String bolt = "Lightning Bolt";
// Cast mastery from hand targetting bolt, which will be exiled, copied, and cast. Prosper will see this cast.
addCard(Zone.GRAVEYARD, playerA, bolt);
addCard(Zone.HAND, playerA, mastery);
addCard(Zone.BATTLEFIELD, playerA, prosper);
// Enough mana for Mizzix's mastery
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
// Cast mastery. Choose target for bolt
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, mastery, bolt);
addTarget(playerA, playerB);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertLife(playerB, 20 - 3);
assertExileCount(playerA, bolt, 1);
assertTokenCount(playerA, "Treasure Token", 0);
}
}

View file

@ -0,0 +1,38 @@
package org.mage.test.cards.single.c15;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import mage.constants.PhaseStep;
import mage.constants.Zone;
public class MizzixsMasteryTest extends CardTestPlayerBase {
private static final String mastery = "Mizzix's Mastery";
@Test
// Author: alexander-novo
// Making sure overload works correctly.
public void overloadTest() {
String fireball = "Delayed Blast Fireball";
// Prep for exiling fireball from graveyard, copying, and then casting copy
addCard(Zone.GRAVEYARD, playerA, fireball, 2);
addCard(Zone.HAND, playerA, mastery);
// Enough mana to overload mastery
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 8);
// Cast Mizzix's Mastery targetting delayed blast fireball. This should exile it, copy it into exile, and then cast the copy from exile, which should end up dealing 5 damage to player B
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, mastery + " with overload");
addTarget(playerA, fireball, 2);
setChoice(playerA, true);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertLife(playerB, 20 - 2 * 5);
assertExileCount(playerA, fireball, 2);
}
}

View file

@ -0,0 +1,37 @@
package org.mage.test.cards.single.clb;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import mage.constants.PhaseStep;
import mage.constants.Zone;
public class DelayedBlastFireballTest extends CardTestPlayerBase {
static final String fireball = "Delayed Blast Fireball";
@Test
// Author: alexander-novo
// Issue: magefree/mage#10435
// If you create a copy of a card in exile and then cast that copy, it should be cast from exile.
// But if we do this with Delayed Blast Fireball (and Mizzix's Mastery, for instance), it won't deal the extra damage for casting from exile.
public void testCopyCardAndCastFromExile() {
String mastery = "Mizzix's Mastery";
// Prep for exiling fireball from graveyard, copying, and then casting copy
addCard(Zone.GRAVEYARD, playerA, fireball);
addCard(Zone.HAND, playerA, mastery);
// Enough mana to cast mastery
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
// Cast Mizzix's Mastery targetting delayed blast fireball. This hsoul exile it, copy it into exile, and then cast the copy from exile, which should end up dealing 5 damage to player B
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, mastery, fireball);
setChoice(playerA, true);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertLife(playerB, 20 - 5);
}
}