Fixed faulty token generation (fixes #4755)

This commit is contained in:
L_J 2018-04-17 11:51:04 +00:00 committed by GitHub
parent a6ec7d8ee8
commit c303f429bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,7 +34,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.common.TapTargetCost; import mage.abilities.costs.common.TapTargetCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
@ -51,6 +51,7 @@ import mage.game.permanent.token.SpiritWhiteToken;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* @author noxx * @author noxx
@ -103,20 +104,17 @@ class GallowsAtWillowHillEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int affectedTargets = 0; Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (!targetPointer.getTargets(game, source).isEmpty()) { if (permanent != null) {
for (UUID permanentId : targetPointer.getTargets(game, source)) { Player controller = game.getPlayer(permanent.getControllerId());
Permanent permanent = game.getPermanent(permanentId); permanent.destroy(source.getSourceId(), game, false);
if (permanent != null) { if (controller != null) {
Player controller = game.getPlayer(permanent.getControllerId()); CreateTokenTargetEffect effect = new CreateTokenTargetEffect(new SpiritWhiteToken());
permanent.destroy(source.getSourceId(), game, false); effect.setTargetPointer(new FixedTarget(controller.getId()));
if (controller != null) { effect.apply(game, source);
new CreateTokenEffect(new SpiritWhiteToken()).apply(game, source);
}
affectedTargets++;
}
} }
return true;
} }
return affectedTargets > 0; return false;
} }
} }