Merge pull request #3015 from drmDev/bug/tokens-exile-end-combat

fixing tokens exiled at end of combat - not at end step
This commit is contained in:
Derek M 2017-03-23 11:24:06 -04:00 committed by GitHub
commit f3ff01fcdf
4 changed files with 15 additions and 3 deletions

View file

@ -89,7 +89,7 @@ class GeistOfSaintTraftEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && effect.apply(game, source)) {
effect.exileTokensCreatedAtNextEndStep(game, source);
effect.exileTokensCreatedAtEndOfCombat(game, source);
return true;
}
return false;

View file

@ -97,7 +97,7 @@ class InvocationOfSaintTraftEffect extends OneShotEffect {
CreateTokenEffect effect = new CreateTokenEffect(new AngelToken(), 1, true, true);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && (effect.apply(game, source))) {
effect.exileTokensCreatedAtNextEndStep(game, source);
effect.exileTokensCreatedAtEndOfCombat(game, source);
return true;
}
return false;

View file

@ -94,7 +94,7 @@ class KariZevSkyshipRaiderEffect extends OneShotEffect {
CreateTokenEffect effect = new CreateTokenEffect(new RagavanToken(), 1, true, true);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && effect.apply(game, source)) {
effect.exileTokensCreatedAtNextEndStep(game, source);
effect.exileTokensCreatedAtEndOfCombat(game, source);
return true;
}
return false;

View file

@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
@ -124,6 +125,17 @@ public class CreateTokenEffect extends OneShotEffect {
}
}
public void exileTokensCreatedAtEndOfCombat(Game game, Ability source) {
for (UUID tokenId : this.getLastAddedTokenIds()) {
Permanent tokenPermanent = game.getPermanent(tokenId);
if (tokenPermanent != null) {
ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
}
}
}
private void setText() {
StringBuilder sb = new StringBuilder("create ");
if (amount.toString().equals("1")) {