* Mirari - Fixed that it can select any spell instead triggered use.

This commit is contained in:
Oleg Agafonov 2018-11-22 21:53:32 +04:00
parent 9d7c59fed9
commit e5bdb85076
3 changed files with 32 additions and 14 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
@ -19,17 +17,17 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.Spell;
import mage.target.TargetSpell;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class Mirari extends CardImpl {
public Mirari(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{5}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}");
addSuperType(SuperType.LEGENDARY);
// Whenever you cast an instant or sorcery spell, you may pay {3}. If you do, copy that spell. You may choose new targets for the copy.
@ -58,8 +56,9 @@ class MirariTriggeredAbility extends TriggeredAbilityImpl {
}
MirariTriggeredAbility() {
super(Zone.BATTLEFIELD, new DoIfCostPaid(new CopyTargetSpellEffect(true), new GenericManaCost(3)), false);
this.addTarget(new TargetSpell(filter));
super(Zone.BATTLEFIELD, new DoIfCostPaid(
new CopyTargetSpellEffect(true),
new GenericManaCost(3)), false);
}
MirariTriggeredAbility(final MirariTriggeredAbility ability) {
@ -82,7 +81,11 @@ class MirariTriggeredAbility extends TriggeredAbilityImpl {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (isControlledInstantOrSorcery(spell)) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(spell.getId()));
if (effect instanceof DoIfCostPaid) {
for (Effect execEffect : ((DoIfCostPaid) effect).getExecutingEffects()) {
execEffect.setTargetPointer(new FixedTarget(spell.getId()));
}
}
}
return true;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
@ -13,7 +12,6 @@ import mage.players.Player;
/**
* @author BetaSteward_at_googlemail.com
*
*/
public class CopyTargetSpellEffect extends OneShotEffect {
@ -79,7 +77,14 @@ public class CopyTargetSpellEffect extends OneShotEffect {
return staticText;
}
StringBuilder sb = new StringBuilder();
sb.append("copy target ").append(mode.getTargets().get(0).getTargetName()).append(". You may choose new targets for the copy");
sb.append("copy ");
if (!mode.getTargets().isEmpty()) {
sb.append("target ").append(mode.getTargets().get(0).getTargetName());
} else {
sb.append("that spell");
}
sb.append(". You may choose new targets for the copy");
return sb.toString();
}
}

View file

@ -1,6 +1,5 @@
package mage.abilities.effects.common;
import java.util.Locale;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -14,6 +13,8 @@ import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.Locale;
public class DoIfCostPaid extends OneShotEffect {
protected Effects executingEffects = new Effects();
@ -27,9 +28,10 @@ public class DoIfCostPaid extends OneShotEffect {
}
public DoIfCostPaid(Effect effect, Effect effect2, Cost cost) {
this(effect,effect2,cost,true);
this(effect, effect2, cost, true);
}
public DoIfCostPaid(Effect effect, Effect effect2, Cost cost,boolean optional) {
public DoIfCostPaid(Effect effect, Effect effect2, Cost cost, boolean optional) {
this(effect, cost, null, optional);
this.otherwiseEffects.add(effect2);
}
@ -62,6 +64,14 @@ public class DoIfCostPaid extends OneShotEffect {
return this;
}
public Effects getExecutingEffects() {
return this.executingEffects;
}
public Effects getOtherwiseEffects() {
return this.otherwiseEffects;
}
@Override
public boolean apply(Game game, Ability source) {
Player player = getPayingPlayer(game, source);