forked from External/mage
* Helm of Obedience - Fixed that card movement to graveyard was not handled correct. It was not checked, if card was really moved to graveyard (fixes #1004).
This commit is contained in:
parent
78961ad511
commit
bb28394f71
4 changed files with 108 additions and 31 deletions
|
|
@ -97,32 +97,32 @@ class HelmOfObedienceEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (targetOpponent != null) {
|
||||
int max = amount.calculate(game, source, this);
|
||||
if(max != 0){
|
||||
int numberOfCard = 0;
|
||||
|
||||
while(player.getLibrary().size() > 0) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
while(targetOpponent.getLibrary().size() > 0) {
|
||||
Card card = targetOpponent.getLibrary().removeFromTop(game);
|
||||
if (card != null){
|
||||
player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
|
||||
if(card.getCardType().contains(CardType.CREATURE)){
|
||||
// If a creature card is put into that graveyard this way, sacrifice Helm of Obedience
|
||||
// and put that card onto the battlefield under your control.
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
sourcePermanent.sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
if (game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
|
||||
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
else{
|
||||
numberOfCard++;
|
||||
if(numberOfCard >= max){
|
||||
if (targetOpponent.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game)) {
|
||||
if(card.getCardType().contains(CardType.CREATURE)){
|
||||
// If a creature card is put into that graveyard this way, sacrifice Helm of Obedience
|
||||
// and put that card onto the battlefield under your control.
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
sourcePermanent.sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
if (game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
|
||||
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
break;
|
||||
} else{
|
||||
numberOfCard++;
|
||||
if(numberOfCard >= max){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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.replacement;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class LeylineOfTheVoidTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Leyline of the Void is on the battlefield, Helm of Obedience is used on
|
||||
* an opponent with X=1. Now the Helm states to mill "until a creature card
|
||||
* or X cards are put into the graveyard this way". For each of those milled
|
||||
* cards, Leyline states to "remove [them] from the game instead". In other
|
||||
* words: Leyline + Helm and X of at least 1 exiles the library of one
|
||||
* unlucky opponent. Or should, because right now it doesn't. Right now it's
|
||||
* Helm's originally intended "X or 1st Creature" amount of cards that after
|
||||
* it's effect get exiled.
|
||||
*/
|
||||
@Test
|
||||
public void testGrindstoneProgenius() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains");
|
||||
|
||||
// If Leyline of the Void is in your opening hand, you may begin the game with it on the battlefield.
|
||||
// If a card would be put into an opponent's graveyard from anywhere, exile it instead.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Leyline of the Void");
|
||||
|
||||
// {X}, {T}: Target opponent puts cards from the top of his or her library into his or her graveyard until a creature card or X cards are put into that graveyard this way, whichever comes first. If a creature card is put into that graveyard this way, sacrifice Helm of Obedience and put that card onto the battlefield under your control. X can't be 0.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Helm of Obedience");
|
||||
|
||||
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{X},{T}: Target opponent puts cards", playerB);
|
||||
setChoice(playerA, "X=1");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertExileCount(playerB, 71); // All cards go to exile replaced from Leyline of the void
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2900,6 +2900,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
@Override
|
||||
public boolean moveCardsToGraveyardWithInfo(List<Card> allCards, Ability source, Game game, Zone fromZone) {
|
||||
boolean result = true;
|
||||
UUID sourceId = source == null ? null : source.getSourceId();
|
||||
while (!allCards.isEmpty()) {
|
||||
// identify cards from one owner
|
||||
Cards cards = new CardsImpl();
|
||||
|
|
@ -2914,7 +2916,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
cards.add(card);
|
||||
}
|
||||
}
|
||||
// move cards ot graveyard in order the owner decides
|
||||
// move cards to graveyard in order the owner decides
|
||||
if (!cards.isEmpty()) {
|
||||
Player choosingPlayer = this;
|
||||
if (ownerId != this.getId()) {
|
||||
|
|
@ -2936,22 +2938,21 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
Card card = cards.get(targetObjectId, game);
|
||||
cards.remove(targetObjectId);
|
||||
if (card != null) {
|
||||
choosingPlayer.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, fromZone);
|
||||
result &= choosingPlayer.moveCardToGraveyardWithInfo(card, sourceId, game, fromZone);
|
||||
}
|
||||
target.clearChosen();
|
||||
}
|
||||
if (cards.size() == 1) {
|
||||
choosingPlayer.moveCardToGraveyardWithInfo(cards.getCards(game).iterator().next(), source == null ? null : source.getSourceId(), game, fromZone);
|
||||
result &= choosingPlayer.moveCardToGraveyardWithInfo(cards.getCards(game).iterator().next(), sourceId, game, fromZone);
|
||||
}
|
||||
} else {
|
||||
for (Card card : cards.getCards(game)) {
|
||||
choosingPlayer.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, fromZone);
|
||||
result &= choosingPlayer.moveCardToGraveyardWithInfo(card, sourceId, game, fromZone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ public class PlayerLostLifeWatcher extends Watcher {
|
|||
if (playerId != null) {
|
||||
Integer amount = amountOfLifeLostThisTurn.get(playerId);
|
||||
if (amount == null) {
|
||||
amount = Integer.valueOf(event.getAmount());
|
||||
amount = event.getAmount();
|
||||
} else {
|
||||
amount = Integer.valueOf(amount + event.getAmount());
|
||||
amount = amount + event.getAmount();
|
||||
}
|
||||
amountOfLifeLostThisTurn.put(playerId, amount);
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ public class PlayerLostLifeWatcher extends Watcher {
|
|||
public int getLiveLost(UUID playerId) {
|
||||
Integer amount = amountOfLifeLostThisTurn.get(playerId);
|
||||
if (amount != null) {
|
||||
return amount.intValue();
|
||||
return amount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ public class PlayerLostLifeWatcher extends Watcher {
|
|||
public int getLiveLostLastTurn(UUID playerId) {
|
||||
Integer amount = amountOfLifeLostLastTurn.get(playerId);
|
||||
if (amount != null) {
|
||||
return amount.intValue();
|
||||
return amount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue