mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
* Fixed AddCardTypeSourceEffect with limited duration and object reference was applied on wrong objects (fixes failing crew test).
This commit is contained in:
parent
624e69ecb6
commit
f06ee144f7
1 changed files with 15 additions and 3 deletions
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue