mirror of
https://github.com/correl/mage.git
synced 2025-04-08 01:01:04 -09:00
* Karn Liberated - Fixed that commanders were not returned to command zone after game reset.
This commit is contained in:
parent
b3deb7bedd
commit
3beb5568c4
4 changed files with 53 additions and 20 deletions
Mage.Sets/src/mage/sets/newphyrexia
Mage.Tests/src/test/java/org/mage/test/commander/duel
Mage/src/mage
|
@ -139,12 +139,17 @@ class KarnLiberatedEffect extends OneShotEffect {
|
|||
if (card.getOwnerId().equals(player.getId()) && !card.isCopy() // no copies
|
||||
&& !player.getSideboard().contains(card.getId())
|
||||
&& !cards.contains(card)) { // not the exiled cards
|
||||
player.getLibrary().putOnTop(card, game);
|
||||
if (card.getId().equals(player.getCommanderId())) {
|
||||
card.moveToZone(Zone.COMMAND, null, game, true);
|
||||
} else {
|
||||
player.getLibrary().putOnTop(card, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
player.init(game);
|
||||
}
|
||||
for (Card card : cards) {
|
||||
game.getState().setZone(card.getId(), Zone.EXILED);
|
||||
if (CardUtil.isPermanentCard(card) && !card.getSubtype().contains("Aura")) {
|
||||
game.getExile().add(exileId, sourceObject.getIdName(), card);
|
||||
}
|
||||
|
@ -209,16 +214,21 @@ class KarnLiberatedDelayedEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ExileZone exile = game.getExile().getExileZone(exileId);
|
||||
if (exile != null) {
|
||||
Cards cards = new CardsImpl(); // needed because putOntoTheBattlefield removes from exile
|
||||
cards.addAll(exile);
|
||||
for (Card card : cards.getCards(game)) {
|
||||
card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
((PermanentImpl) permanent).removeSummoningSickness();
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
ExileZone exile = game.getExile().getExileZone(exileId);
|
||||
if (exile != null) {
|
||||
// Creatures put onto the battlefield due to Karn's ability will have been under their controller's control continuously
|
||||
// since the beginning of the first turn. They can attack and their activated abilities with {T} in the cost can be activated.
|
||||
Cards cards = new CardsImpl(); // needed because putOntoTheBattlefield removes from exile
|
||||
cards.addAll(exile);
|
||||
controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
|
||||
for (Card card : cards.getCards(game)) {
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
((PermanentImpl) permanent).removeSummoningSickness();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -69,4 +69,31 @@ public class CastBRGCommanderTest extends CardTestCommanderDuelBase {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Activating Karn Liberated 's ultimate in an edh game (human OR ai) causes
|
||||
* all the command zones to lose their generals upon the new game restart
|
||||
*/
|
||||
@Test
|
||||
public void castCommanderAfterKarnUltimate() {
|
||||
// +4: Target player exiles a card from his or her hand.
|
||||
// -3: Exile target permanent.
|
||||
// -14: Restart the game, leaving in exile all non-Aura permanent cards exiled with Karn Liberated. Then put those cards onto the battlefield under your control.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Karn Liberated", 1);
|
||||
addCard(Zone.HAND, playerA, "Silvercoat Lion", 2);
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+4: Target player", playerA);
|
||||
addTarget(playerA, "Silvercoat Lion");
|
||||
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "+4: Target player", playerA);
|
||||
addTarget(playerA, "Silvercoat Lion");
|
||||
activateAbility(5, PhaseStep.PRECOMBAT_MAIN, playerA, "-14: Restart");
|
||||
|
||||
setStopAt(5, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Karn Liberated", 0);
|
||||
assertPermanentCount(playerA, "Silvercoat Lion", 2);
|
||||
assertCommandZoneCount(playerA, "Prossh, Skyraider of Kher", 1);
|
||||
assertCommandZoneCount(playerB, "Ob Nixilis of the Black Oath", 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.abilities.effects.common;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
|
@ -91,16 +91,11 @@ public class ExileFromZoneTargetEffect extends OneShotEffect {
|
|||
default:
|
||||
}
|
||||
if (target != null && target.canChoose(source.getSourceId(), player.getId(), game)) {
|
||||
if (target.choose(Outcome.Exile, player.getId(), source.getSourceId(), game)) {
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
card.moveToExile(exileId, exileName, source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (target.chooseTarget(Outcome.Exile, player.getId(), source, game)) {
|
||||
player.moveCardsToExile(new CardsImpl(target.getTargets()).getCards(game), source, game, true, exileId, exileName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -671,7 +671,8 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeBookmark(int bookmark) {
|
||||
public void removeBookmark(int bookmark
|
||||
) {
|
||||
if (!simulation) {
|
||||
if (bookmark != 0) {
|
||||
while (savedStates.size() > bookmark) {
|
||||
|
|
Loading…
Add table
Reference in a new issue