mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22: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
|
|
@ -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
Add a link
Reference in a new issue