* Guilded Drake - Fixed that the sacrifice did not happen if the target creature for exchange is no longer a valid target during resolution (fixes #1546).

This commit is contained in:
LevelX2 2016-02-21 10:20:26 +01:00
parent ea5c825897
commit cf3488d5e5
8 changed files with 80 additions and 22 deletions

View file

@ -568,4 +568,8 @@ public interface Ability extends Controllable, Serializable {
MageObject getSourceObjectIfItStillExists(Game game);
String getTargetDescription(Targets targets, Game game);
void setCanFizzle(boolean canFizzle);
boolean canFizzle();
}

View file

@ -114,6 +114,7 @@ public abstract class AbilityImpl implements Ability {
protected int sourceObjectZoneChangeCounter;
protected List<Watcher> watchers = null;
protected List<Ability> subAbilities = null;
protected boolean canFizzle = true;
public AbilityImpl(AbilityType abilityType, Zone zone) {
this.id = UUID.randomUUID();
@ -164,6 +165,7 @@ public abstract class AbilityImpl implements Ability {
this.abilityWord = ability.abilityWord;
this.sourceObject = ability.sourceObject;
this.sourceObjectZoneChangeCounter = ability.sourceObjectZoneChangeCounter;
this.canFizzle = ability.canFizzle;
}
@Override
@ -1222,4 +1224,14 @@ public abstract class AbilityImpl implements Ability {
this.sourceObjectZoneChangeCounter = game.getState().getZoneChangeCounter(sourceId);
}
@Override
public boolean canFizzle() {
return canFizzle;
}
@Override
public void setCanFizzle(boolean canFizzle) {
this.canFizzle = canFizzle;
}
}

View file

@ -1486,10 +1486,6 @@ public abstract class GameImpl implements Game, Serializable {
} else {
TriggeredAbility newAbility = ability.copy();
newAbility.newId();
// Too early, because no targets set yet !!!!!!!!!!!
for (Effect effect : newAbility.getEffects()) {
effect.getTargetPointer().init(this, newAbility);
}
state.addTriggeredAbility(newAbility);
}
}

View file

@ -104,7 +104,7 @@ public class StackAbility extends StackObjImpl implements Ability {
@Override
public boolean resolve(Game game) {
if (ability.getTargets().stillLegal(ability, game)) {
if (ability.getTargets().stillLegal(ability, game) || !canFizzle()) {
boolean result = ability.resolve(game);
game.getStack().remove(this);
return result;
@ -581,4 +581,13 @@ public class StackAbility extends StackObjImpl implements Ability {
return getAbilities().get(0).getTargetDescription(targets, game);
}
@Override
public boolean canFizzle() {
return ability.canFizzle();
}
@Override
public void setCanFizzle(boolean canFizzle) {
throw new UnsupportedOperationException("Not supported.");
}
}