mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
* Vindictive Lich - Fixed that it did only execute the first effect (fixes #4742).
This commit is contained in:
parent
425e68167b
commit
03f5b8c2da
3 changed files with 150 additions and 42 deletions
|
|
@ -63,6 +63,7 @@ public class VindictiveLich extends CardImpl {
|
||||||
Ability ability = new DiesTriggeredAbility(new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, "target opponent"));
|
Ability ability = new DiesTriggeredAbility(new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, "target opponent"));
|
||||||
ability.getModes().setMinModes(1);
|
ability.getModes().setMinModes(1);
|
||||||
ability.getModes().setMaxModes(3);
|
ability.getModes().setMaxModes(3);
|
||||||
|
ability.getModes().setEachModeOnlyOnce(true);
|
||||||
ability.getModes().setMaxModesFilter(new FilterOpponent("a different player"));
|
ability.getModes().setMaxModesFilter(new FilterOpponent("a different player"));
|
||||||
|
|
||||||
FilterOpponent filter = new FilterOpponent("opponent (sacrifice)");
|
FilterOpponent filter = new FilterOpponent("opponent (sacrifice)");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* 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.multiplayer;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import mage.constants.MultiplayerAttackOption;
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.RangeOfInfluence;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.game.FreeForAll;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.GameException;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestMultiPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class VindictiveLichTest extends CardTestMultiPlayerBase {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
|
||||||
|
Game game = new FreeForAll(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, 0, 40);
|
||||||
|
// Player order: A -> D -> C -> B
|
||||||
|
playerA = createPlayer(game, playerA, "PlayerA");
|
||||||
|
playerB = createPlayer(game, playerB, "PlayerB");
|
||||||
|
playerC = createPlayer(game, playerC, "PlayerC");
|
||||||
|
playerD = createPlayer(game, playerD, "PlayerD");
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests multiplayer effects Player order: A -> D -> C -> B
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void CallerOfThePackTest() {
|
||||||
|
|
||||||
|
// When Vindictive Lich dies, choose one or more. Each mode must target a different player.
|
||||||
|
// *Target opponent sacrifices a creature.
|
||||||
|
// *Target opponent discards two cards.
|
||||||
|
// *Target opponent loses 5 life.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Vindictive Lich"); // Creature {3}{B} 4/1
|
||||||
|
|
||||||
|
// Sacrifice a creature: Put a +1/+1 counter on Bloodflow Connoisseur.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Bloodflow Connoisseur"); // Creature {2}{B} 1/1
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 2);
|
||||||
|
addCard(Zone.HAND, playerC, "Lightning Bolt", 2);
|
||||||
|
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sacrifice");
|
||||||
|
setChoice(playerA, "Vindictive Lich");
|
||||||
|
|
||||||
|
setModeChoice(playerA, "1");
|
||||||
|
addTarget(playerA, playerB);
|
||||||
|
setModeChoice(playerA, "2");
|
||||||
|
addTarget(playerA, playerC);
|
||||||
|
setModeChoice(playerA, "3");
|
||||||
|
addTarget(playerA, playerD);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, "Vindictive Lich", 1);
|
||||||
|
assertPowerToughness(playerA, "Bloodflow Connoisseur", 2, 2);
|
||||||
|
|
||||||
|
assertPermanentCount(playerB, "Silvercoat Lion", 1);
|
||||||
|
assertHandCount(playerC, 0);
|
||||||
|
assertLife(playerD, 35);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,10 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
|
@ -46,6 +50,7 @@ import mage.cards.SplitCard;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.command.Emblem;
|
import mage.game.command.Emblem;
|
||||||
|
import mage.game.command.Plane;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ManaEvent;
|
import mage.game.events.ManaEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
@ -59,12 +64,6 @@ import mage.util.ThreadLocalStringBuilder;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.game.command.Plane;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -179,7 +178,20 @@ public abstract class AbilityImpl implements Ability {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
//20100716 - 117.12
|
//20100716 - 117.12
|
||||||
if (checkIfClause(game)) {
|
if (checkIfClause(game)) {
|
||||||
|
if (this instanceof TriggeredAbility) {
|
||||||
|
for (UUID modeId : this.getModes().getSelectedModes()) {
|
||||||
|
this.getModes().setActiveMode(modeId);
|
||||||
|
result = resolveMode(game);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = resolveMode(game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean resolveMode(Game game) {
|
||||||
|
boolean result = true;
|
||||||
for (Effect effect : getEffects()) {
|
for (Effect effect : getEffects()) {
|
||||||
if (effect instanceof OneShotEffect) {
|
if (effect instanceof OneShotEffect) {
|
||||||
boolean effectResult = effect.apply(game, this);
|
boolean effectResult = effect.apply(game, this);
|
||||||
|
|
@ -202,27 +214,24 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* All restrained trigger events are fired now. To restrain the
|
* All restrained trigger events are fired now. To restrain the
|
||||||
* events is mainly neccessary because of the movement of
|
* events is mainly neccessary because of the movement of multiple
|
||||||
* multiple object at once. If the event is fired directly as
|
* object at once. If the event is fired directly as one object
|
||||||
* one object moved, other objects are not already in the
|
* moved, other objects are not already in the correct zone to check
|
||||||
* correct zone to check for their effects. (e.g. Valakut, the
|
* for their effects. (e.g. Valakut, the Molten Pinnacle)
|
||||||
* Molten Pinnacle)
|
|
||||||
*/
|
*/
|
||||||
game.getState().handleSimultaneousEvent(game);
|
game.getState().handleSimultaneousEvent(game);
|
||||||
game.resetShortLivingLKI();
|
game.resetShortLivingLKI();
|
||||||
/**
|
/**
|
||||||
* game.applyEffects() has to be done at least for every effect
|
* game.applyEffects() has to be done at least for every effect that
|
||||||
* that moves cards/permanent between zones, or changes control
|
* moves cards/permanent between zones, or changes control of
|
||||||
* of objects so Static effects work as intened if dependant
|
* objects so Static effects work as intened if dependant from the
|
||||||
* from the moved objects zone it is in Otherwise for example
|
* moved objects zone it is in Otherwise for example were static
|
||||||
* were static abilities with replacement effects deactivated
|
* abilities with replacement effects deactivated too late Example:
|
||||||
* too late Example:
|
|
||||||
* {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
|
* {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
|
||||||
*/
|
*/
|
||||||
game.applyEffects();
|
game.applyEffects();
|
||||||
game.getState().getTriggers().checkStateTriggers(game);
|
game.getState().getTriggers().checkStateTriggers(game);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue