* Phantasmal Image - Fixed that under some circumstances copied Dies-Triggered abilities did not work (e.g. copying a Wurmcoil Engine and dying in combat).

This commit is contained in:
LevelX2 2015-06-12 22:17:41 +02:00
parent 8acfbf0ab3
commit 3032fff50e
6 changed files with 38 additions and 9 deletions

View file

@ -247,7 +247,7 @@ public abstract class AbilityImpl implements Ability {
return false;
}
game.applyEffects();
/* 20130201 - 601.2b
* If the spell is modal the player announces the mode choice (see rule 700.2).
*/

View file

@ -61,4 +61,7 @@ public interface ContinuousEffect extends Effect {
void newId();
@Override
ContinuousEffect copy();
boolean isTemporary();
void setTemporary(boolean temporary);
}

View file

@ -68,7 +68,8 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
protected boolean discarded = false; // for manual effect discard
protected boolean affectedObjectsSet = false;
protected List<MageObjectReference> affectedObjectList = new ArrayList<>();
protected boolean temporary = false;
// until your next turn
protected int startingTurn;
protected UUID startingControllerId;
@ -96,6 +97,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
this.discarded = effect.discarded;
this.affectedObjectsSet = effect.affectedObjectsSet;
this.affectedObjectList.addAll(effect.affectedObjectList);
this.temporary = effect.temporary;
this.startingTurn = effect.startingTurn;
this.startingControllerId = effect.startingControllerId;
}
@ -234,4 +236,18 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
return affectedObjectList;
}
/**
* Returns the status if the effect is temporary added to the ContinuousEffects
* @return
*/
@Override
public boolean isTemporary() {
return temporary;
}
@Override
public void setTemporary(boolean temporary) {
this.temporary = temporary;
}
}

View file

@ -939,6 +939,7 @@ public class ContinuousEffects implements Serializable {
*/
public void addEffect(ContinuousEffect effect, UUID sourceId, Ability source) {
if (!(source instanceof MageSingleton)) { // because MageSingletons may never be removed by removing the temporary effecs they are not added to the temporaryEffects to prevent this
effect.setTemporary(true);
Set abilities = temporaryEffects.get(effect);
if (abilities == null) {
abilities = new HashSet<>();

View file

@ -40,6 +40,7 @@ import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
@ -56,6 +57,7 @@ public class CopyEffect extends ContinuousEffectImpl {
* Object we copy from
*/
private MageObject target;
private UUID sourceId;
private ApplyToPermanent applier;
@ -93,9 +95,14 @@ public class CopyEffect extends ContinuousEffectImpl {
permanent = game.getPermanent(this.sourceId);
}
if (permanent == null) {
discard();
return false;
permanent = (Permanent) game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD, source.getSourceObjectZoneChangeCounter());
// As long as the permanent is still in the LKI continue to copy to get triggered abilities to TriggeredAbilites for dies events.
if (permanent == null) {
discard();
return false;
}
}
permanent.setCopy(true);
permanent.setName(target.getName());
permanent.getColor(game).setColor(target.getColor(game));
permanent.getManaCost().clear();
@ -134,9 +141,7 @@ public class CopyEffect extends ContinuousEffectImpl {
} else if (target instanceof PermanentToken || target instanceof Card) {
permanent.setCardNumber(((Card) target).getCardNumber());
permanent.setExpansionSetCode(((Card) target).getExpansionSetCode());
}
permanent.setCopy(true);
}
return true;
}

View file

@ -36,8 +36,8 @@ import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
@ -76,12 +76,16 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
MageObject mageObject = game.getObject(source.getSourceId());
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject == null) {
if (duration.equals(Duration.Custom)) {
discard();
}
return false;
} else if (isTemporary()) { // it's somehow w
if (!(mageObject instanceof Permanent)) {
return false;
}
}
if (amount != null) {
int value = amount.calculate(game, source, this);