* Figure of Destiny - Fixed that effects didn't work correctly if Figure returned to battlefield.

This commit is contained in:
LevelX2 2013-08-30 20:43:16 +02:00
parent dec4794fbc
commit 2b916a5dfb
2 changed files with 33 additions and 10 deletions

View file

@ -63,17 +63,32 @@ public class ConditionalContinousEffect extends ContinuousEffectImpl<Conditional
public ConditionalContinousEffect(final ConditionalContinousEffect effect) { public ConditionalContinousEffect(final ConditionalContinousEffect effect) {
super(effect); super(effect);
this.effect = effect.effect; this.effect = (ContinuousEffect) effect.effect.copy();
this.otherwiseEffect = effect.otherwiseEffect; if (otherwiseEffect != null) {
this.otherwiseEffect = (ContinuousEffect) effect.otherwiseEffect.copy();
}
this.condition = effect.condition; this.condition = effect.condition;
this.lockedInCondition = effect.lockedInCondition; this.lockedInCondition = effect.lockedInCondition;
} }
@Override @Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { public boolean isDiscarded() {
if (lockedInCondition && !(condition instanceof FixedCondition)) { return effect.isDiscarded() || (otherwiseEffect != null && otherwiseEffect.isDiscarded());
}
@Override
public void init(Ability source, Game game) {
if (lockedInCondition) {
condition = new FixedCondition(condition.apply(game, source)); condition = new FixedCondition(condition.apply(game, source));
} }
effect.init(source, game);
if (otherwiseEffect != null) {
otherwiseEffect.init(source, game);
}
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
if (condition.apply(game, source)) { if (condition.apply(game, source)) {
effect.setTargetPointer(this.targetPointer); effect.setTargetPointer(this.targetPointer);
return effect.apply(layer, sublayer, source, game); return effect.apply(layer, sublayer, source, game);

View file

@ -28,8 +28,10 @@
package mage.abilities.effects.common.continious; package mage.abilities.effects.common.continious;
import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.Card;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Layer; import mage.constants.Layer;
@ -47,6 +49,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl<BecomesCre
protected Token token; protected Token token;
protected String type; protected String type;
protected int zoneChangeCounter;
public BecomesCreatureSourceEffect(Token token, String type, Duration duration) { public BecomesCreatureSourceEffect(Token token, String type, Duration duration) {
super(duration, Outcome.BecomeCreature); super(duration, Outcome.BecomeCreature);
@ -59,6 +62,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl<BecomesCre
super(effect); super(effect);
this.token = effect.token.copy(); this.token = effect.token.copy();
this.type = effect.type; this.type = effect.type;
this.zoneChangeCounter = effect.zoneChangeCounter;
} }
@Override @Override
@ -70,12 +74,16 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl<BecomesCre
public void init(Ability source, Game game) { public void init(Ability source, Game game) {
super.init(source, game); super.init(source, game);
this.getAffectedObjects().add(source.getSourceId()); this.getAffectedObjects().add(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
this.zoneChangeCounter = permanent.getZoneChangeCounter();
}
} }
@Override @Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null && permanent.getZoneChangeCounter() == this.zoneChangeCounter) {
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) { if (sublayer == SubLayer.NA) {
@ -112,11 +120,11 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl<BecomesCre
break; break;
case PTChangingEffects_7: case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) { if (sublayer == SubLayer.SetPT_7b) {
int power = token.getPower().getValue(); MageInt power = token.getPower();
int toughness = token.getToughness().getValue(); MageInt toughness = token.getToughness();
if (power != 0 && toughness != 0) { if (power != null && toughness != null) {
permanent.getPower().setValue(power); permanent.getPower().setValue(power.getValue());
permanent.getToughness().setValue(toughness); permanent.getToughness().setValue(toughness.getValue());
} }
} }
} }