* Fixed AddCardTypeSourceEffect with limited duration and object reference was applied on wrong objects (fixes failing crew test).
*/
package mage.abilities.effects.common.continuous;
+import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffectImpl;
@@ -59,16 +60,27 @@ public class AddCardTypeSourceEffect extends ContinuousEffectImpl {
this.addedCardType = effect.addedCardType;
}
+ @Override
+ public void init(Ability source, Game game) {
+ super.init(source, game);
+ if (Duration.Custom.equals(this.duration) || this.duration.toString().startsWith("End")) {
+ affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()), game));
+ if (affectedObjectList.isEmpty()) {
+ this.discard();
+ }
+ }
+ }
+
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
- if (permanent != null) {
+ if (permanent != null
+ && (affectedObjectList.isEmpty() || affectedObjectList.contains(new MageObjectReference(permanent, game)))) {
if (!permanent.getCardType().contains(addedCardType)) {
permanent.getCardType().add(addedCardType);
}
return true;
- }
- else if (this.getDuration().equals(Duration.Custom)) {
+ } else if (this.getDuration().equals(Duration.Custom)) {
this.discard();
}
return false;
