Fix copy effect and gain triggerAbility effect

This commit is contained in:
Plopman 2012-11-19 11:25:15 +01:00
parent 14cbddcf11
commit bfd3bcaf78
4 changed files with 42 additions and 4 deletions

View file

@ -239,7 +239,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
@Override
public boolean contains(T ability) {
for (T test: this) {
if (ability.getId().equals(test.getId()) || ability.getRule().equals(test.getRule())) {
if (ability.getId().equals(test.getId())/* || ability.getRule().equals(test.getRule())*/) {
return true;
}
}

View file

@ -371,6 +371,10 @@ public class ContinuousEffects implements Serializable {
for (ContinuousEffect effect: layer) {
effect.apply(Layer.CopyEffects_1, SubLayer.NA, layeredEffects.getAbility(effect.getId()), game);
}
//Reload layerEffect
layerEffects = getLayeredEffects(game);
layer = filterLayeredEffects(layerEffects, Layer.ControlChangingEffects_2);
for (ContinuousEffect effect: layer) {
effect.apply(Layer.ControlChangingEffects_2, SubLayer.NA, layeredEffects.getAbility(effect.getId()), game);
@ -395,6 +399,9 @@ public class ContinuousEffects implements Serializable {
}
}
//Reload layerEffect
layerEffects = getLayeredEffects(game);
layer = filterLayeredEffects(layerEffects, Layer.PTChangingEffects_7);
for (ContinuousEffect effect: layer) {
effect.apply(Layer.PTChangingEffects_7, SubLayer.SetPT_7b, layeredEffects.getAbility(effect.getId()), game);

View file

@ -36,6 +36,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
import mage.cards.Card;
/**
*
@ -48,19 +49,36 @@ public class CopyEffect extends ContinuousEffectImpl<CopyEffect> {
*/
private MageObject target;
private UUID sourceId;
private int zoneChangeCounter;
public CopyEffect(Permanent target, UUID sourceId) {
super(Duration.WhileOnBattlefield, Layer.CopyEffects_1, SubLayer.NA, Outcome.BecomeCreature);
super(Duration.Custom, Layer.CopyEffects_1, SubLayer.NA, Outcome.BecomeCreature);
this.target = target;
this.sourceId = sourceId;
this.zoneChangeCounter = 0;
}
public CopyEffect(final CopyEffect effect) {
super(effect);
this.target = effect.target.copy();
this.sourceId = effect.sourceId;
this.zoneChangeCounter = effect.zoneChangeCounter;
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Permanent permanent = game.getPermanent(this.sourceId);
if(permanent != null) {
Card card = game.getCard(this.sourceId);
if(card != null)
{
this.zoneChangeCounter = card.getZoneChangeCounter();
}
}
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(this.sourceId);
@ -115,4 +133,17 @@ public class CopyEffect extends ContinuousEffectImpl<CopyEffect> {
public UUID getSourceId() {
return sourceId;
}
@Override
public boolean isInactive(Ability source, Game game) {
Permanent permanent = game.getPermanent(this.sourceId);
if(permanent != null) {
Card card = game.getCard(this.sourceId);
if(card != null)
{
return this.zoneChangeCounter != card.getZoneChangeCounter();
}
}
return true;
}
}

View file

@ -852,7 +852,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
if (effect instanceof CopyEffect) {
CopyEffect copyEffect = (CopyEffect) effect;
// there is another copy effect that our targetPermanent copies stats from
if (copyEffect.getSourceId().equals(copyFromPermanent.getId())) {
if (!copyEffect.isInactive(null, this) && copyEffect.getSourceId().equals(copyFromPermanent.getId())) {
MageObject object = ((CopyEffect) effect).getTarget();
if (object instanceof Permanent) {
// so we will use original card instead of target
@ -866,7 +866,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
}
}
state.addEffect(newEffect, newAbility);
state.addEffect(newEffect, copyToPermanent.getId(), newAbility);
}
@Override