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

@ -1388,10 +1388,16 @@ public class GameState implements Serializable, Copyable<GameState> {
// main part prepare (must be called after other parts cause it change ids for all)
prepareCardForCopy(mainCardToCopy, copiedCard, newController);
// 707.12. An effect that instructs a player to cast a copy of an object (and not just copy a spell) follows the rules for casting spells, except that the copy is created in the same zone the object is in and then cast while another spell or ability is resolving.
Zone copyToZone = game.getState().getZone(mainCardToCopy.getId());
if (copyToZone == Zone.BATTLEFIELD) {
throw new UnsupportedOperationException("Cards cannot be copied while on the Battlefield");
}
// add all parts to the game
copiedParts.forEach(card -> {
copiedCards.put(card.getId(), card);
addCard(card);
addCard(card, copyToZone);
});
// copied cards removes from game after battlefield/stack leaves, so remember it here as workaround to fix freeze, see https://github.com/magefree/mage/issues/5437