mirror of
https://github.com/correl/mage.git
synced 2025-03-12 17:00:08 -09: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.getModes().setMinModes(1);
|
||||
ability.getModes().setMaxModes(3);
|
||||
ability.getModes().setEachModeOnlyOnce(true);
|
||||
ability.getModes().setMaxModesFilter(new FilterOpponent("a different player"));
|
||||
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectReference;
|
||||
import mage.Mana;
|
||||
|
@ -46,6 +50,7 @@ import mage.cards.SplitCard;
|
|||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.command.Plane;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ManaEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -59,12 +64,6 @@ import mage.util.ThreadLocalStringBuilder;
|
|||
import mage.watchers.Watcher;
|
||||
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
|
||||
*/
|
||||
|
@ -179,49 +178,59 @@ public abstract class AbilityImpl implements Ability {
|
|||
boolean result = true;
|
||||
//20100716 - 117.12
|
||||
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;
|
||||
}
|
||||
|
||||
for (Effect effect : getEffects()) {
|
||||
if (effect instanceof OneShotEffect) {
|
||||
boolean effectResult = effect.apply(game, this);
|
||||
result &= effectResult;
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (this.getAbilityType() != AbilityType.MANA) {
|
||||
if (!effectResult) {
|
||||
if (this.getSourceId() != null) {
|
||||
MageObject mageObject = game.getObject(this.getSourceId());
|
||||
if (mageObject != null) {
|
||||
logger.debug("AbilityImpl.resolve: object: " + mageObject.getName());
|
||||
}
|
||||
private boolean resolveMode(Game game) {
|
||||
boolean result = true;
|
||||
for (Effect effect : getEffects()) {
|
||||
if (effect instanceof OneShotEffect) {
|
||||
boolean effectResult = effect.apply(game, this);
|
||||
result &= effectResult;
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (this.getAbilityType() != AbilityType.MANA) {
|
||||
if (!effectResult) {
|
||||
if (this.getSourceId() != null) {
|
||||
MageObject mageObject = game.getObject(this.getSourceId());
|
||||
if (mageObject != null) {
|
||||
logger.debug("AbilityImpl.resolve: object: " + mageObject.getName());
|
||||
}
|
||||
logger.debug("AbilityImpl.resolve: effect returned false -" + effect.getText(this.getModes().getMode()));
|
||||
}
|
||||
logger.debug("AbilityImpl.resolve: effect returned false -" + effect.getText(this.getModes().getMode()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
game.addEffect((ContinuousEffect) effect, this);
|
||||
}
|
||||
/**
|
||||
* All restrained trigger events are fired now. To restrain the
|
||||
* events is mainly neccessary because of the movement of
|
||||
* multiple object at once. If the event is fired directly as
|
||||
* one object moved, other objects are not already in the
|
||||
* correct zone to check for their effects. (e.g. Valakut, the
|
||||
* Molten Pinnacle)
|
||||
*/
|
||||
game.getState().handleSimultaneousEvent(game);
|
||||
game.resetShortLivingLKI();
|
||||
/**
|
||||
* game.applyEffects() has to be done at least for every effect
|
||||
* that moves cards/permanent between zones, or changes control
|
||||
* of objects so Static effects work as intened if dependant
|
||||
* from the moved objects zone it is in Otherwise for example
|
||||
* were static abilities with replacement effects deactivated
|
||||
* too late Example:
|
||||
* {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
|
||||
*/
|
||||
game.applyEffects();
|
||||
game.getState().getTriggers().checkStateTriggers(game);
|
||||
} else {
|
||||
game.addEffect((ContinuousEffect) effect, this);
|
||||
}
|
||||
/**
|
||||
* All restrained trigger events are fired now. To restrain the
|
||||
* events is mainly neccessary because of the movement of multiple
|
||||
* object at once. If the event is fired directly as one object
|
||||
* moved, other objects are not already in the correct zone to check
|
||||
* for their effects. (e.g. Valakut, the Molten Pinnacle)
|
||||
*/
|
||||
game.getState().handleSimultaneousEvent(game);
|
||||
game.resetShortLivingLKI();
|
||||
/**
|
||||
* game.applyEffects() has to be done at least for every effect that
|
||||
* moves cards/permanent between zones, or changes control of
|
||||
* objects so Static effects work as intened if dependant from the
|
||||
* moved objects zone it is in Otherwise for example were static
|
||||
* abilities with replacement effects deactivated too late Example:
|
||||
* {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
|
||||
*/
|
||||
game.applyEffects();
|
||||
game.getState().getTriggers().checkStateTriggers(game);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue