* Fixed a bug of spell copy that caused that added spliced spells were not copied.

This commit is contained in:
LevelX2 2016-02-14 13:42:46 +01:00
parent 1835671f3d
commit 6726f48669
25 changed files with 198 additions and 199 deletions

View file

@ -64,9 +64,6 @@ public class ClovenCasting extends CardImpl {
super(ownerId, 86, "Cloven Casting", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{5}{U}{R}");
this.expansionSetCode = "ARB";
// Whenever you cast a multicolored instant or sorcery spell, you may pay {1}. If you do, copy that spell. You may choose new targets for the copy.
this.addAbility(new SpellCastControllerTriggeredAbility(new DoIfCostPaid(new ClovenCastingEffect(), new GenericManaCost(1)), filter, true, true));
@ -97,9 +94,7 @@ class ClovenCastingEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
Spell copy = spell.copySpell();
copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
Player player = game.getPlayer(source.getControllerId());
@ -117,4 +112,4 @@ class ClovenCastingEffect extends OneShotEffect {
public ClovenCastingEffect copy() {
return new ClovenCastingEffect(this);
}
}
}

View file

@ -44,11 +44,11 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
*/
public class KorCastigator extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Eldrazi Scions");
private static final FilterCreaturePermanent FILTER = new FilterCreaturePermanent("Eldrazi Scions");
static {
filter.add(new SubtypePredicate("Eldrazi"));
filter.add(new SubtypePredicate("Scion"));
FILTER.add(new SubtypePredicate("Eldrazi"));
FILTER.add(new SubtypePredicate("Scion"));
}
public KorCastigator(UUID ownerId) {
@ -61,7 +61,7 @@ public class KorCastigator extends CardImpl {
this.toughness = new MageInt(1);
// Kor Castigator can't be blocked by Eldrazi Scions.
this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(FILTER, Duration.WhileOnBattlefield)));
}
public KorCastigator(final KorCastigator card) {

View file

@ -103,13 +103,17 @@ class ZadaHedronGrinderTriggeredAbility extends TriggeredAbilityImpl {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (isControlledInstantOrSorcery(spell)) {
boolean targetsSource = false;
for (Mode mode : spell.getSpellAbility().getModes().getSelectedModes()) {
for (Target target : mode.getTargets()) {
for (UUID targetId : target.getTargets()) {
if (targetId.equals(getSourceId())) {
targetsSource = true;
} else {
return false;
for (Ability ability : spell.getSpellAbilities()) {
for (Mode mode : ability.getModes().getSelectedModes()) {
for (Target target : mode.getTargets()) {
if (!target.isNotTarget()) {
for (UUID targetId : target.getTargets()) {
if (targetId.equals(getSourceId())) {
targetsSource = true;
} else {
return false;
}
}
}
}
}
@ -159,14 +163,17 @@ class ZadaHedronGrinderEffect extends OneShotEffect {
}
Player controller = game.getPlayer(source.getControllerId());
if (spell != null && controller != null) {
// search the target that targets source
Target usedTarget = null;
setUsedTarget:
for (Mode mode : spell.getSpellAbility().getModes().getSelectedModes()) {
for (Target target : mode.getTargets()) {
if (target.getFirstTarget().equals(source.getSourceId())) {
usedTarget = target.copy();
usedTarget.clearChosen();
break setUsedTarget;
for (Ability ability : spell.getSpellAbilities()) {
for (Mode mode : ability.getModes().getSelectedModes()) {
for (Target target : mode.getTargets()) {
if (!target.isNotTarget() && target.getFirstTarget().equals(source.getSourceId())) {
usedTarget = target.copy();
usedTarget.clearChosen();
break setUsedTarget;
}
}
}
}
@ -175,7 +182,7 @@ class ZadaHedronGrinderEffect extends OneShotEffect {
}
for (Permanent creature : game.getState().getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
if (!creature.getId().equals(source.getSourceId()) && usedTarget.canTarget(source.getControllerId(), creature.getId(), source, game)) {
Spell copy = spell.copySpell();
Spell copy = spell.copySpell(source.getControllerId());
setTarget:
for (Mode mode : spell.getSpellAbility().getModes().getSelectedModes()) {
for (Target target : mode.getTargets()) {
@ -188,8 +195,6 @@ class ZadaHedronGrinderEffect extends OneShotEffect {
}
}
}
copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true);
game.getStack().push(copy);
String activateMessage = copy.getActivatedMessage(game);
if (activateMessage.startsWith(" casts ")) {

View file

@ -116,9 +116,7 @@ class RikuOfTwoReflectionsCopyEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
Spell copy = spell.copySpell();
copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(source.getControllerId());;
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
Player player = game.getPlayer(source.getControllerId());

View file

@ -60,7 +60,6 @@ public class WildRicochet extends CardImpl {
super(ownerId, 139, "Wild Ricochet", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{2}{R}{R}");
this.expansionSetCode = "CMD";
// You may choose new targets for target instant or sorcery spell. Then copy that spell. You may choose new targets for the copy.
this.getSpellAbility().addEffect(new WildRicochetEffect());
this.getSpellAbility().addTarget(new TargetStackObject(filter));
@ -96,9 +95,7 @@ class WildRicochetEffect extends OneShotEffect {
spell.chooseNewTargets(game, you.getId());
}
if (spell != null) {
Spell copy = spell.copySpell();
copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(source.getControllerId());;
game.getStack().push(copy);
if (you != null && you.chooseUse(Outcome.Benefit, "Do you wish to choose new targets for the copied " + spell.getName() + "?", source, game)) {
return copy.chooseNewTargets(game, you.getId());

View file

@ -30,18 +30,14 @@ package mage.sets.commander2014;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility;
import mage.abilities.condition.LockedInCondition;
import mage.abilities.condition.common.MorbidCondition;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CastSourceTriggeredAbility;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent;
@ -49,7 +45,6 @@ import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
@ -69,7 +64,6 @@ public class MaliciousAffliction extends CardImpl {
super(ownerId, 25, "Malicious Affliction", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{B}{B}");
this.expansionSetCode = "C14";
// Morbid - When you cast Malicious Affliction, if a creature died this turn, you may copy Malicious Affliction and may choose a new target for the copy.
Ability ability = new ConditionalTriggeredAbility(
new CastSourceTriggeredAbility(new CopySourceSpellEffect(), true),
@ -112,9 +106,7 @@ class CopySourceSpellEffect extends OneShotEffect {
if (controller != null) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
Spell spellCopy = spell.copySpell();
spellCopy.setCopiedSpell(true);
spellCopy.setControllerId(source.getControllerId());
Spell spellCopy = spell.copySpell(source.getControllerId());;
game.getStack().push(spellCopy);
spellCopy.chooseNewTargets(game, controller.getId());
String activateMessage = spellCopy.getActivatedMessage(game);
@ -132,4 +124,4 @@ class CopySourceSpellEffect extends OneShotEffect {
public CopySourceSpellEffect copy() {
return new CopySourceSpellEffect(this);
}
}
}

View file

@ -28,9 +28,6 @@
package mage.sets.darkascension;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.TriggeredAbilityImpl;
@ -38,7 +35,9 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
@ -63,7 +62,6 @@ public class CurseOfEchoes extends CardImpl {
this.subtype.add("Aura");
this.subtype.add("Curse");
// Enchant player
TargetPlayer auraTarget = new TargetPlayer();
this.getSpellAbility().addTarget(auraTarget);
@ -149,13 +147,11 @@ class CurseOfEchoesEffect extends OneShotEffect {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
String chooseMessage = "Copy target spell? You may choose new targets for the copy.";
for (UUID playerId: game.getPlayerList()) {
for (UUID playerId : game.getPlayerList()) {
if (!playerId.equals(spell.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player.chooseUse(Outcome.Copy, chooseMessage, source, game)) {
Spell copy = spell.copySpell();
copy.setControllerId(playerId);
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(source.getControllerId());;
game.getStack().push(copy);
copy.chooseNewTargets(game, playerId);
}
@ -171,7 +167,7 @@ class CurseOfEchoesEffect extends OneShotEffect {
return new CurseOfEchoesEffect(this);
}
@Override
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
sb.append("Copy target ").append(mode.getTargets().get(0).getTargetName()).append(". You may choose new targets for the copy");

View file

@ -28,13 +28,12 @@
package mage.sets.darkascension;
import java.util.UUID;
import mage.constants.*;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -64,7 +63,6 @@ public class IncreasingVengeance extends CardImpl {
super(ownerId, 95, "Increasing Vengeance", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{R}{R}");
this.expansionSetCode = "DKA";
// Copy target instant or sorcery spell you control. If Increasing Vengeance was cast from a graveyard, copy that spell twice instead. You may choose new targets for the copies.
this.getSpellAbility().addEffect(new IncreasingVengeanceEffect());
Target target = new TargetSpell(filter);
@ -101,18 +99,14 @@ class IncreasingVengeanceEffect extends OneShotEffect {
if (controller != null) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
Spell copy = spell.copySpell();
copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
game.informPlayers(new StringBuilder(controller.getLogName()).append(copy.getActivatedMessage(game)).toString());
Spell sourceSpell = (Spell) game.getStack().getStackObject(source.getSourceId());
if (sourceSpell != null) {
if (sourceSpell.getFromZone() == Zone.GRAVEYARD) {
copy = spell.copySpell();
copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true);
copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
game.informPlayers(new StringBuilder(controller.getLogName()).append(copy.getActivatedMessage(game)).toString());

View file

@ -52,11 +52,12 @@ import mage.target.TargetSpell;
/**
*
* @author jeffwadsworth
*
*/
public class MirrorSheen extends CardImpl {
private static final FilterSpell filter = new FilterSpell();
static {
filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT), new CardTypePredicate(CardType.SORCERY)));
filter.add(new TargetYouPredicate());
@ -66,12 +67,11 @@ public class MirrorSheen extends CardImpl {
super(ownerId, 105, "Mirror Sheen", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{U/R}{U/R}");
this.expansionSetCode = "EVE";
// {1}{UR}{UR}: Copy target instant or sorcery spell that targets you. You may choose new targets for the copy.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MirrorSheenEffect(), new ManaCostsImpl("{1}{U/R}{U/R}"));
ability.addTarget(new TargetSpell(filter));
this.addAbility(ability);
}
public MirrorSheen(final MirrorSheen card) {
@ -99,9 +99,7 @@ class MirrorSheenEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(source.getFirstTarget());
if (spell != null) {
Spell copy = spell.copySpell();
copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
Player player = game.getPlayer(source.getControllerId());
@ -144,4 +142,4 @@ class TargetYouPredicate implements ObjectPlayerPredicate<ObjectPlayer<StackObje
public String toString() {
return "spell that targets you";
}
}
}

View file

@ -52,7 +52,6 @@ public class ChainLightning extends CardImpl {
super(ownerId, 137, "Chain Lightning", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{R}");
this.expansionSetCode = "LEG";
// Chain Lightning deals 3 damage to target creature or player. Then that player or that creature's controller may pay {R}{R}. If the player does, he or she may copy this spell and may choose a new target for that copy.
this.getSpellAbility().addEffect(new ChainLightningEffect());
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
@ -69,21 +68,21 @@ public class ChainLightning extends CardImpl {
}
class ChainLightningEffect extends OneShotEffect {
ChainLightningEffect() {
super(Outcome.Damage);
this.staticText = "Chain Lightning deals 3 damage to target creature or player. Then that player or that creature's controller may pay {R}{R}. If the player does, he or she may copy this spell and may choose a new target for that copy.";
}
ChainLightningEffect(final ChainLightningEffect effect) {
super(effect);
}
@Override
public ChainLightningEffect copy() {
return new ChainLightningEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -94,8 +93,7 @@ class ChainLightningEffect extends OneShotEffect {
if (player != null) {
player.damage(3, source.getSourceId(), game, false, true);
affectedPlayer = player;
}
else {
} else {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanent.damage(3, source.getSourceId(), game, false, true);
@ -108,9 +106,7 @@ class ChainLightningEffect extends OneShotEffect {
if (cost.pay(source, game, source.getSourceId(), affectedPlayer.getId(), false, null)) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
Spell copy = spell.copySpell();
copy.setControllerId(affectedPlayer.getId());
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(affectedPlayer.getId());
game.getStack().push(copy);
copy.chooseNewTargets(game, affectedPlayer.getId());
game.informPlayers(affectedPlayer.getLogName() + " copies " + copy.getName() + ".");

View file

@ -92,10 +92,8 @@ class ForkEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
Spell copy = spell.copySpell();
Spell copy = spell.copySpell(source.getControllerId());
copy.getColor(game).setRed(true);
copy.setControllerId(controller.getId());
copy.setCopiedSpell(true);
game.getStack().push(copy);
copy.chooseNewTargets(game, controller.getId());
return true;

View file

@ -135,9 +135,7 @@ class HiveMindEffect extends OneShotEffect {
if (spell != null && player != null) {
for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) {
if (!playerId.equals(spell.getControllerId())) {
Spell copy = spell.copySpell();
copy.setControllerId(playerId);
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(playerId);
game.getStack().push(copy);
copy.chooseNewTargets(game, playerId);
}

View file

@ -111,9 +111,7 @@ class PsychicRebuttalEffect extends OneShotEffect {
if (SpellMasteryCondition.getInstance().apply(game, source)
&& controller.chooseUse(Outcome.PlayForFree, "Copy " + stackObject.getName() + " (you may choose new targets for the copy)?", source, game)) {
Spell copy = ((Spell) stackObject).copySpell();
copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true);
Spell copy = ((Spell) stackObject).copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
Player player = game.getPlayer(source.getControllerId());

View file

@ -94,7 +94,7 @@ class ChainOfVaporEffect extends OneShotEffect {
}
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
controller.moveCards(permanent, null, Zone.HAND, source, game);
controller.moveCards(permanent, Zone.HAND, source, game);
Player player = game.getPlayer(permanent.getControllerId());
TargetControlledPermanent target = new TargetControlledPermanent(0, 1, new FilterControlledLandPermanent("a land to sacrifice (to be able to copy " + sourceObject.getName() + ")"), true);
if (player.chooseTarget(Outcome.Sacrifice, target, source, game)) {
@ -103,9 +103,7 @@ class ChainOfVaporEffect extends OneShotEffect {
if (player.chooseUse(outcome, "Copy the spell?", source, game)) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
Spell copy = spell.copySpell();
copy.setControllerId(player.getId());
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(player.getId());
game.getStack().push(copy);
copy.chooseNewTargets(game, player.getId());
String activateMessage = copy.getActivatedMessage(game);

View file

@ -28,10 +28,6 @@
package mage.sets.riseoftheeldrazi;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -43,8 +39,11 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyTargetSpellEffect;
import mage.abilities.keyword.LevelUpAbility;
import mage.abilities.keyword.LevelerCardBuilder;
import mage.cards.CardImpl;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -132,9 +131,7 @@ class EchoMageEffect extends OneShotEffect {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
for (int i = 0; i < 2; i++) {
Spell copy = spell.copySpell();
copy.setControllerId(source.getControllerId());
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
}

View file

@ -55,6 +55,7 @@ import mage.target.TargetSpell;
public class MeletisCharlatan extends CardImpl {
private static final FilterSpell filter = new FilterSpell("instant or sorcery spell");
static {
filter.add(Predicates.or(
new CardTypePredicate(CardType.INSTANT),
@ -103,9 +104,7 @@ class MeletisCharlatanCopyTargetSpellEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
Spell copy = spell.copySpell();
copy.setControllerId(spell.getControllerId());
copy.setCopiedSpell(true);
Spell copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, spell.getControllerId());
Player player = game.getPlayer(spell.getControllerId());