mirror of
https://github.com/correl/mage.git
synced 2024-12-27 03:00:13 +00:00
Fix copy effect and gain triggerAbility effect
This commit is contained in:
parent
14cbddcf11
commit
bfd3bcaf78
4 changed files with 42 additions and 4 deletions
|
@ -239,7 +239,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(T ability) {
|
public boolean contains(T ability) {
|
||||||
for (T test: this) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,6 +371,10 @@ public class ContinuousEffects implements Serializable {
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect: layer) {
|
||||||
effect.apply(Layer.CopyEffects_1, SubLayer.NA, layeredEffects.getAbility(effect.getId()), game);
|
effect.apply(Layer.CopyEffects_1, SubLayer.NA, layeredEffects.getAbility(effect.getId()), game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Reload layerEffect
|
||||||
|
layerEffects = getLayeredEffects(game);
|
||||||
|
|
||||||
layer = filterLayeredEffects(layerEffects, Layer.ControlChangingEffects_2);
|
layer = filterLayeredEffects(layerEffects, Layer.ControlChangingEffects_2);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect: layer) {
|
||||||
effect.apply(Layer.ControlChangingEffects_2, SubLayer.NA, layeredEffects.getAbility(effect.getId()), game);
|
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);
|
layer = filterLayeredEffects(layerEffects, Layer.PTChangingEffects_7);
|
||||||
for (ContinuousEffect effect: layer) {
|
for (ContinuousEffect effect: layer) {
|
||||||
effect.apply(Layer.PTChangingEffects_7, SubLayer.SetPT_7b, layeredEffects.getAbility(effect.getId()), game);
|
effect.apply(Layer.PTChangingEffects_7, SubLayer.SetPT_7b, layeredEffects.getAbility(effect.getId()), game);
|
||||||
|
|
|
@ -36,6 +36,7 @@ import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.cards.Card;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -48,19 +49,36 @@ public class CopyEffect extends ContinuousEffectImpl<CopyEffect> {
|
||||||
*/
|
*/
|
||||||
private MageObject target;
|
private MageObject target;
|
||||||
private UUID sourceId;
|
private UUID sourceId;
|
||||||
|
private int zoneChangeCounter;
|
||||||
|
|
||||||
public CopyEffect(Permanent target, UUID sourceId) {
|
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.target = target;
|
||||||
this.sourceId = sourceId;
|
this.sourceId = sourceId;
|
||||||
|
this.zoneChangeCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CopyEffect(final CopyEffect effect) {
|
public CopyEffect(final CopyEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.target = effect.target.copy();
|
this.target = effect.target.copy();
|
||||||
this.sourceId = effect.sourceId;
|
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
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = game.getPermanent(this.sourceId);
|
Permanent permanent = game.getPermanent(this.sourceId);
|
||||||
|
@ -115,4 +133,17 @@ public class CopyEffect extends ContinuousEffectImpl<CopyEffect> {
|
||||||
public UUID getSourceId() {
|
public UUID getSourceId() {
|
||||||
return sourceId;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -852,7 +852,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
if (effect instanceof CopyEffect) {
|
if (effect instanceof CopyEffect) {
|
||||||
CopyEffect copyEffect = (CopyEffect) effect;
|
CopyEffect copyEffect = (CopyEffect) effect;
|
||||||
// there is another copy effect that our targetPermanent copies stats from
|
// 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();
|
MageObject object = ((CopyEffect) effect).getTarget();
|
||||||
if (object instanceof Permanent) {
|
if (object instanceof Permanent) {
|
||||||
// so we will use original card instead of target
|
// 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
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue