mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
* Angel of Serenity - Fixed that the exiled cards did not return when the Angel left the battlefield (fixes #1083).
This commit is contained in:
parent
b45cdb9a55
commit
1ee75e3e94
6 changed files with 168 additions and 86 deletions
|
|
@ -29,10 +29,12 @@ package mage.sets.returntoravnica;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
@ -44,10 +46,10 @@ import mage.filter.FilterCard;
|
|||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCardInGraveyard;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
|
@ -74,7 +76,7 @@ public class AngelOfSerenity extends CardImpl {
|
|||
this.addAbility(new AngelOfSerenityTriggeredAbility());
|
||||
|
||||
// When Angel of Serenity leaves the battlefield, return the exiled cards to their owners' hands.
|
||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new AngelOfSerenityLeaveEffect(), false));
|
||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.HAND, false, true), false));
|
||||
}
|
||||
|
||||
public AngelOfSerenity(final AngelOfSerenity card) {
|
||||
|
|
@ -149,13 +151,16 @@ class AngelOfSerenityEnterEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean result = true;
|
||||
if (source.getTargets().size() > 0) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null && source.getTargets().size() > 0) {
|
||||
UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
|
||||
for (Target target : source.getTargets()) {
|
||||
if (target instanceof TargetCreaturePermanent) {
|
||||
for (UUID permanentId : target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
result |= permanent.moveToExile(CardUtil.getCardExileZoneId(game, source), "Angel of Serenity", source.getSourceId(), game);
|
||||
result |= controller.moveCardToExileWithInfo(permanent, exileZoneId, sourceObject.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +168,7 @@ class AngelOfSerenityEnterEffect extends OneShotEffect {
|
|||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
result |= card.moveToExile(CardUtil.getCardExileZoneId(game, source), "Angel of Serenity", source.getSourceId(), game);
|
||||
result |= controller.moveCardToExileWithInfo(card, exileZoneId, sourceObject.getIdName(), source.getSourceId(), game, Zone.GRAVEYARD, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -172,34 +177,3 @@ class AngelOfSerenityEnterEffect extends OneShotEffect {
|
|||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class AngelOfSerenityLeaveEffect extends OneShotEffect {
|
||||
|
||||
public AngelOfSerenityLeaveEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.staticText = "return the exiled cards to their owners' hands";
|
||||
}
|
||||
|
||||
public AngelOfSerenityLeaveEffect(final AngelOfSerenityLeaveEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AngelOfSerenityLeaveEffect copy() {
|
||||
return new AngelOfSerenityLeaveEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ExileZone exZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
|
||||
if (exZone != null) {
|
||||
for (Card card : exZone.getCards(game)) {
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package org.mage.test.cards.triggers;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class EnterLeaveBattlefieldExileTargetTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testAngelOfSerenityExile() {
|
||||
// Flying
|
||||
// When Angel of Serenity enters the battlefield, you may exile up to three other target creatures from the battlefield and/or creature cards from graveyards.
|
||||
// When Angel of Serenity leaves the battlefield, return the exiled cards to their owners' hands.
|
||||
addCard(Zone.HAND, playerA, "Angel of Serenity");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 7);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Angel of Serenity");
|
||||
addTarget(playerA, "Silvercoat Lion^Pillarfield Ox");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Angel of Serenity", 1);
|
||||
assertExileCount("Silvercoat Lion", 1);
|
||||
assertExileCount("Pillarfield Ox", 1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* When Angel of Serenity entered the battlefield on my opponent's main
|
||||
* phase it exiled 3 of my creatures (as it should), I cast Ultimate Price
|
||||
* (destroy monocolored creature) on my next main phase and destroyed the
|
||||
* Angel of Serenity. The log said the exiled cards were returned to my hand
|
||||
* but they remained in exile indefinitely.
|
||||
*/
|
||||
@Test
|
||||
public void testAngelOfSerenityExileReturn() {
|
||||
// Flying
|
||||
// When Angel of Serenity enters the battlefield, you may exile up to three other target creatures from the battlefield and/or creature cards from graveyards.
|
||||
// When Angel of Serenity leaves the battlefield, return the exiled cards to their owners' hands.
|
||||
addCard(Zone.HAND, playerA, "Angel of Serenity");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 7);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox", 1);
|
||||
addCard(Zone.HAND, playerB, "Ultimate Price", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Angel of Serenity");
|
||||
addTarget(playerA, "Silvercoat Lion^Pillarfield Ox");
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Ultimate Price", "Angel of Serenity");
|
||||
|
||||
setStopAt(2, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerB, "Ultimate Price", 1);
|
||||
assertGraveyardCount(playerA, "Angel of Serenity", 1);
|
||||
assertHandCount(playerB, "Silvercoat Lion", 1);
|
||||
assertHandCount(playerB, "Pillarfield Ox", 1);
|
||||
assertExileCount(playerB, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
* @author LeveX2
|
||||
*/
|
||||
|
||||
public class JournexToNowhereTest extends CardTestPlayerBase {
|
||||
public class JourneyToNowhereTest extends CardTestPlayerBase {
|
||||
|
||||
/*
|
||||
Journey to Nowhere Enchantment {1}{W}
|
||||
|
|
@ -25,11 +25,8 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
|
@ -41,6 +38,7 @@ import static mage.constants.Zone.GRAVEYARD;
|
|||
import static mage.constants.Zone.HAND;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
|
@ -70,7 +68,8 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
|
|||
*
|
||||
* @param zone
|
||||
* @param tapped
|
||||
* @param previousZone if this is used from a dies leave battlefield or destroyed trigger, the exile zone is based on previous zone of the object
|
||||
* @param previousZone if this is used from a dies leave battlefield or
|
||||
* destroyed trigger, the exile zone is based on previous zone of the object
|
||||
*/
|
||||
public ReturnFromExileForSourceEffect(Zone zone, boolean tapped, boolean previousZone) {
|
||||
super(Outcome.PutCardInPlay);
|
||||
|
|
@ -95,23 +94,24 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int zoneChangeCounter = source.getSourceObjectZoneChangeCounter() - (previousZone ? 1:0);
|
||||
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter);
|
||||
ExileZone exile = game.getExile().getExileZone(exileId);
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject != null && controller != null) {
|
||||
int zoneChangeCounter = source.getSourceObjectZoneChangeCounter();
|
||||
if (zoneChangeCounter > 0 && previousZone && !(sourceObject instanceof PermanentToken)) {
|
||||
zoneChangeCounter--;
|
||||
}
|
||||
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
|
||||
if (exile != null) { // null is valid if source left battlefield before enters the battlefield effect resolved
|
||||
LinkedList<UUID> cards = new LinkedList<>(exile);
|
||||
for (UUID cardId: cards) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card == null) {
|
||||
return false;
|
||||
if (returnToZone.equals(Zone.BATTLEFIELD)) {
|
||||
for (Card card : exile.getCards(game)) {
|
||||
Player owner = game.getPlayer(card.getOwnerId());
|
||||
if (owner != null) {
|
||||
owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName() + " moves " + card.getLogName() + " from exile to " + returnToZone.toString().toLowerCase());
|
||||
}
|
||||
card.moveToZone(returnToZone, source.getSourceId(), game, tapped);
|
||||
} else {
|
||||
controller.moveCards(exile, Zone.EXILED, returnToZone, source, game);
|
||||
}
|
||||
exile.clear();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2914,6 +2914,12 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone);
|
||||
}
|
||||
return result;
|
||||
case BATTLEFIELD:
|
||||
result = false;
|
||||
for (Card card : cards) {
|
||||
result |= putOntoBattlefieldWithInfo(card, game, fromZone, source == null ? null : source.getSourceId());
|
||||
}
|
||||
return result;
|
||||
default:
|
||||
throw new UnsupportedOperationException("to Zone not supported yet");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,9 @@ git log 757b9ea99ec1f0ce46bb533f9f86f3473d122a60..HEAD --diff-filter=A --name-st
|
|||
since 1.4.2.v0
|
||||
git log cd0cba6ec7d8799bb85247b7b4f5d545e170b093..HEAD --diff-filter=A --name-status | sed -ne "s/^A[^u]Mage.Sets\/src\/mage\/sets\///p" | sort > added_cards.txt
|
||||
|
||||
since 1.4.2.v1
|
||||
git log 0b26aaff6ec033a538179bf607b1c7a7736aedb2..HEAD --diff-filter=A --name-status | sed -ne "s/^A[^u]Mage.Sets\/src\/mage\/sets\///p" | sort > added_cards.txt
|
||||
|
||||
3. Copy added_cards.txt to trunk\Utils folder
|
||||
4. Run script:
|
||||
> perl extract_in_wiki_format.perl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue