* Fixed a bug that replacemet effects did not work if the source object of the replacemet effect also changed zone (fixes #759).

This commit is contained in:
LevelX2 2015-02-28 12:55:49 +01:00
parent 6bd17716cd
commit 01ef3f9354
3 changed files with 37 additions and 5 deletions

View file

@ -331,6 +331,7 @@ public class ContinuousEffects implements Serializable {
if(auraReplacementEffect.checksEventType(event, game) && auraReplacementEffect.applies(event, null, game)){
replaceEffects.put(auraReplacementEffect, null);
}
boolean checkLKI = event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT);
//get all applicable transient Replacement effects
for (ReplacementEffect effect: replacementEffects) {
if (!effect.checksEventType(event, game)) {
@ -344,7 +345,7 @@ public class ContinuousEffects implements Serializable {
HashSet<Ability> abilities = replacementEffects.getAbility(effect.getId());
HashSet<Ability> applicableAbilities = new HashSet<>();
for (Ability ability : abilities) {
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, false)) {
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, checkLKI)) {
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
if (!game.getScopeRelevant() || effect.hasSelfScope() || !event.getTargetId().equals(ability.getSourceId())) {
if (checkAbilityStillExists(ability, effect, event, game)) {

View file

@ -40,7 +40,6 @@ public class UndyingAbility extends DiesTriggeredAbility {
if (super.checkTrigger(event, game)) {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (!permanent.getCounters().containsKey(CounterType.P1P1) || permanent.getCounters().getCount(CounterType.P1P1) == 0) {
Logger.getLogger(UndyingAbility.class).info("Undying trigger: " + getSourceId());
game.getState().setValue("undying" + getSourceId(),permanent.getId());
return true;
}
@ -115,8 +114,6 @@ class UndyingReplacementEffect extends ReplacementEffectImpl {
if (event.getTargetId().equals(source.getSourceId())) {
// Check if undying condition is true
UUID targetId = (UUID) game.getState().getValue("undying" + source.getSourceId());
Logger.getLogger(UndyingReplacementEffect.class).info("Undying replacement applies: " + targetId + " eventSourceId " + event.getTargetId());
if (targetId != null && targetId.equals(source.getSourceId())) {
return true;
}