* Fixed a problem where for copies of cards/permanent the included spell ability was not correctly copied and the copied card had the spell ability twice. That could cause in some rare cases problems with spell ids of copies (this fixes #6824) or did allow on the other side some unproper handling of things (Animate Dead).

This commit is contained in:
LevelX2 2020-07-14 21:28:45 +02:00
parent 9f92377eef
commit eecaa232f5
12 changed files with 300 additions and 149 deletions

View file

@ -1,6 +1,6 @@
package mage.cards.u;
import java.util.UUID;
import mage.abilities.effects.common.ShuffleIntoLibraryTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -8,8 +8,6 @@ import mage.constants.CardType;
import mage.filter.StaticFilters;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author LevelX2
@ -17,7 +15,7 @@ import java.util.UUID;
public final class UnravelTheAether extends CardImpl {
public UnravelTheAether(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}");
// Choose target artifact or enchantment. Its owner shuffles it into their library.
this.getSpellAbility().addEffect(new ShuffleIntoLibraryTargetEffect());

View file

@ -17,7 +17,7 @@ public class CursesTest extends CardTestPlayerBase {
Enchant player
At the beginning of enchanted player's upkeep, that player sacrifices a creature or planeswalker. If the player can't, they lose 5 life.
*/
private String cReality = "Cruel Reality";
private final String cReality = "Cruel Reality";
@Test
public void testCurseOfBloodletting() {
@ -29,7 +29,6 @@ public class CursesTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerA);
setStopAt(1, PhaseStep.END_TURN);
execute();
@ -71,7 +70,6 @@ public class CursesTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
setStopAt(1, PhaseStep.END_TURN);
execute();
@ -90,7 +88,6 @@ public class CursesTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
setStopAt(1, PhaseStep.END_TURN);
execute();
@ -115,7 +112,6 @@ public class CursesTest extends CardTestPlayerBase {
addCard(Zone.HAND, playerB, "Copy Enchantment", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curse of Exhaustion", playerB);
castSpell(4, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
@ -125,8 +121,6 @@ public class CursesTest extends CardTestPlayerBase {
setChoice(playerB, "targetPlayer=PlayerA");
castSpell(4, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
setStopAt(4, PhaseStep.END_TURN);
execute();
@ -156,11 +150,9 @@ public class CursesTest extends CardTestPlayerBase {
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Obzedat's Aid", "Curse of Exhaustion");
setChoice(playerB, "PlayerA");
castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
setStopAt(2, PhaseStep.END_TURN);
execute();
@ -243,7 +235,6 @@ public class CursesTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Curse of Bloodletting", 1);
}
@Test
public void testCurseOfDeathsHold() {
// Creatures enchanted player controls get -1/-1.
@ -299,8 +290,6 @@ public class CursesTest extends CardTestPlayerBase {
assertPowerToughness(playerB, "Silvercoat Lion", 1, 1);
}
@Test
public void cruelRealityHasBothCreatureAndPwChoosePw() {

View file

@ -2,7 +2,6 @@ package org.mage.test.cards.abilities.oneshot.counterspell;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -99,4 +98,76 @@ public class CounterspellTest extends CardTestPlayerBase {
assertLife(playerA, 20);
assertLife(playerB, 17);
}
@Test
public void testCopyCounterToCounterGraveyard() {
// Lightning Bolt deals 3 damage to any target.
addCard(Zone.HAND, playerA, "Lightning Bolt");
// Copy target instant or sorcery spell. You may choose new targets for the copy.
addCard(Zone.HAND, playerA, "Twincast");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
// Counter target spell
addCard(Zone.HAND, playerB, "Counterspell"); // Instant {1}{U}
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Counterspell", "Lightning Bolt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Twincast", "Counterspell");
setChoice(playerA, "Yes"); // change the target
addTarget(playerA, "Counterspell");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertGraveyardCount(playerA, "Twincast", 1);
assertGraveyardCount(playerB, "Counterspell", 1);
assertLife(playerA, 20);
assertLife(playerB, 17);
}
@Test
public void testCopyCounterToCounterExile() {
// Lightning Bolt deals 3 damage to any target.
addCard(Zone.HAND, playerA, "Lightning Bolt");
// Copy target instant or sorcery spell. You may choose new targets for the copy.
addCard(Zone.HAND, playerA, "Twincast");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
addCard(Zone.BATTLEFIELD, playerB, "Island", 3);
// CCounter target spell. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.
addCard(Zone.HAND, playerB, "Dissipate"); // Instant {1}{U}
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Dissipate", "Lightning Bolt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Twincast", "Dissipate");
setChoice(playerA, "Yes"); // change the target
addTarget(playerA, "Dissipate");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertGraveyardCount(playerA, "Twincast", 1);
assertExileCount(playerB, "Dissipate", 1);
assertLife(playerA, 20);
assertLife(playerB, 17);
}
}

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.enchantments;
import mage.constants.PhaseStep;
@ -119,7 +118,7 @@ public class AnimateDeadTest extends CardTestPlayerBase {
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Cruel Edict", playerA);
setStopAt(2, PhaseStep.BEGIN_COMBAT);
setStopAt(2, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerB, "Cruel Edict", 1);
@ -168,6 +167,8 @@ public class AnimateDeadTest extends CardTestPlayerBase {
*/
@Test
public void testAnimateAndDragonlordAtarkaWithNoTargets() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
// Enchant creature card in a graveyard
@ -188,6 +189,11 @@ public class AnimateDeadTest extends CardTestPlayerBase {
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Animate Dead", 1);
assertPermanentCount(playerA, "Dragonlord Atarka", 1);
}

View file

@ -67,6 +67,8 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
*/
@Test
public void testWithAnimateDead() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
// When Worldgorger Dragon enters the battlefield, exile all other permanents you control.
@ -79,6 +81,7 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
// Enchanted creature gets -1/-0.
addCard(Zone.HAND, playerA, "Animate Dead");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
// Instant {X}{R}{R}
// Volcanic Geyser deals X damage to any target.
addCard(Zone.HAND, playerA, "Volcanic Geyser", 1);
@ -86,44 +89,61 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerA, "Staunch Defenders", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Animate Dead", "Worldgorger Dragon");
setChoice(playerA, "Worldgorger Dragon");
setChoice(playerA, "When {this} enters the battlefield, if it's");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
setChoice(playerA, "Worldgorger Dragon");
setChoice(playerA, "When {this} enters the battlefield, if it's");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
setChoice(playerA, "Worldgorger Dragon");
setChoice(playerA, "When {this} enters the battlefield, if it's");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
setChoice(playerA, "Worldgorger Dragon");
setChoice(playerA, "When {this} enters the battlefield, if it's");
setChoice(playerA, "No");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
setChoice(playerA, "Worldgorger Dragon");
setChoice(playerA, "When {this} enters the battlefield, if it's");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
setChoice(playerA, "Worldgorger Dragon");
setChoice(playerA, "When {this} enters the battlefield, if it's");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
setChoice(playerA, "Worldgorger Dragon");
setChoice(playerA, "When {this} enters the battlefield, if it's");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB, 22);
setChoice(playerA, "X=20");
// not an infinite loop resulting in a draw
for (int i = 0; i < 6; ++i)
{
setChoice(playerA, "No");
setChoice(playerB, "No");
}
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertLife(playerA, 44);
assertLife(playerB, 0);
@ -132,7 +152,7 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
}
/**
* v9: Worldgorger Dragon + Animate Dead is still acting up (yey complex
* v9: Worldgorger Dragon + Animate Dead is still acting up (yet complex
* rules interactions!). The first time you return Animate Dead from
* Worldgorger's exile, it works like it's supposed to. You have to pick a
* creature, and it brings it back. But if you pick Worldgorger Dragon
@ -149,6 +169,8 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
*/
@Test
public void testWithAnimateDeadDifferentTargets() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
// When Worldgorger Dragon enters the battlefield, exile all other permanents you control.
@ -161,9 +183,9 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
// under your control and attach Animate Dead to it. When Animate Dead leaves the battlefield, that creature's controller sacrifices it.
addCard(Zone.HAND, playerA, "Animate Dead");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
// Instant {X}{R}{R}
// Volcanic Geyser deals X damage to any target.
addCard(Zone.HAND, playerA, "Volcanic Geyser", 1);
addCard(Zone.HAND, playerA, "Volcanic Geyser", 1);// Instant {X}{R}{R}
// When Staunch Defenders enters the battlefield, you gain 4 life.
addCard(Zone.BATTLEFIELD, playerA, "Staunch Defenders", 1);
@ -176,13 +198,15 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
setChoice(playerA, "Worldgorger Dragon");
setChoice(playerA, "When {this} enters the battlefield, if it's");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
setChoice(playerA, "Silvercoat Lion");
setChoice(playerA, "When {this} enters the battlefield, if it's");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
@ -193,6 +217,8 @@ public class WorldgorgerDragonTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Volcanic Geyser", 1);
assertGraveyardCount(playerA, "Worldgorger Dragon", 1);
assertPermanentCount(playerA, "Silvercoat Lion", 1);

View file

@ -1,4 +1,3 @@
package org.mage.test.turnmod;
import mage.constants.PhaseStep;
@ -97,4 +96,50 @@ public class ExtraTurnsTest extends CardTestPlayerBase {
Assert.assertEquals("For turn " + currentGame.getTurnNum() + ", playerB has to be the active player but active player is: "
+ currentGame.getPlayer(currentGame.getActivePlayerId()).getName(), currentGame.getActivePlayerId(), playerB.getId());
}
/**
* https://github.com/magefree/mage/issues/6824
*
* When you cast miracled Temporal Mastery with God-Eternal Kefnet on the
* battlefield and copy it with it's ability you get only 1 extra turn. It
* should be 2, since you cast Temporal Mastery with it's miracle ability +
* you get a copy from Kefnet's ability. Still after first extra turn game
* proceeds to next player.
*/
@Test
public void testCopyMiracledTemporalMastery4TwoExtraTurns() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerB, "Island", 7);
// Flying
// You may reveal the first card you draw each turn as you draw it. Whenever you reveal an instant or sorcery card this way,
// copy that card and you may cast the copy. That copy costs {2} less to cast.
// When God-Eternal Kefnet dies or is put into exile from the battlefield, you may put it into its owners library third from the top.
addCard(Zone.BATTLEFIELD, playerB, "God-Eternal Kefnet", 1);
// Take an extra turn after this one. Exile Temporal Mastery.
// Miracle {1}{U} (You may cast this card for its miracle cost when you draw it if it's the first card you drew this turn.)
addCard(Zone.LIBRARY, playerB, "Temporal Mastery", 1); // Sorcery {5}{U}{U}
skipInitShuffling();
setChoice(playerB, "Yes"); // Would you like to reveal first drawn card (Temporal Mastery, you can copy it and cast {2} less)?
setChoice(playerB, "Yes"); // Would you like to copy Temporal Mastery and cast it {2} less?
setChoice(playerB, "Yes"); // Reveal Temporal Mastery to be able to use Miracle?
setChoice(playerB, "Yes"); // Miracle {1}{U} (You may cast this card for its miracle cost when you draw it if it's the first card you drew this turn.)
setChoice(playerB, "No"); // Would you like to reveal first drawn card? (Turn 3)
setChoice(playerB, "No"); // Would you like to reveal first drawn card? (Turn 4)
// Turn 3 + 4 are extra turns
setStopAt(4, PhaseStep.PRECOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertExileCount(playerB, "Temporal Mastery", 1);
Assert.assertTrue("Turn 4 is an extra turn ", currentGame.getState().isExtraTurn());
Assert.assertEquals("For turn " + currentGame.getTurnNum() + ", playerB has to be the active player but active player is: "
+ currentGame.getPlayer(currentGame.getActivePlayerId()).getName(), currentGame.getActivePlayerId(), playerB.getId());
}
}

View file

@ -1,22 +1,20 @@
package mage.abilities.effects;
import java.util.ArrayList;
import java.util.Arrays;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.constants.Outcome;
import mage.target.targetpointer.TargetPointer;
import mage.util.CardUtil;
import java.util.ArrayList;
/**
* @author BetaSteward_at_googlemail.com
*/
public class Effects extends ArrayList<Effect> {
public Effects(Effect... effects) {
for (Effect effect : effects) {
this.add(effect);
}
this.addAll(Arrays.asList(effects));
}
public Effects(final Effects effects) {
@ -67,10 +65,10 @@ public class Effects extends ArrayList<Effect> {
// nextRule determined to be a new sentence, now check ending of lastRule
} else if (lastRule != null && lastRule.length() > 3) {
//check if lastRule already has appropriate punctuation, if so, add a space.
if (lastRule.endsWith(".\"") ||
lastRule.endsWith(".)") ||
lastRule.endsWith(".)</i>") ||
lastRule.endsWith(".")){
if (lastRule.endsWith(".\"")
|| lastRule.endsWith(".)")
|| lastRule.endsWith(".)</i>")
|| lastRule.endsWith(".")) {
endString = " ";
// if lastRule does not have appropriate punctuation, add the default ". "
} else if (!lastRule.endsWith(".") && !lastRule.endsWith("<br>")) {

View file

@ -1,4 +1,3 @@
package mage.abilities.keyword;
import mage.MageObjectReference;
@ -102,9 +101,7 @@ public class MiracleAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(getSourceId())) {
// Refer to the card at the zone it is now (hand)
FixedTarget fixedTarget = new FixedTarget(event.getSourceId());
fixedTarget.init(game, this);
getEffects().get(0).setTargetPointer(fixedTarget);
getEffects().setTargetPointer(new FixedTarget(game.getCard(event.getSourceId()), game));
return true;
}
return false;

View file

@ -1,6 +1,12 @@
package mage.cards;
import com.google.common.collect.ImmutableList;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectImpl;
import mage.Mana;
@ -27,13 +33,6 @@ import mage.util.SubTypeList;
import mage.watchers.Watcher;
import org.apache.log4j.Logger;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public abstract class CardImpl extends MageObjectImpl implements Card {
private static final long serialVersionUID = 1L;
@ -137,7 +136,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
nightCard = card.nightCard;
}
if (card.spellAbility != null) {
spellAbility = card.getSpellAbility().copy();
spellAbility = (SpellAbility) abilities.get(0);
} else {
spellAbility = null;
}
@ -397,10 +396,15 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
}
/**
* Dynamic cost modification for card (process only own abilities).
* Example: if it need stack related info (like real targets) then must check two states (game.inCheckPlayableState):
* 1. In playable state it must check all possible use cases (e.g. allow to reduce on any available target and modes)
* 2. In real cast state it must check current use case (e.g. real selected targets and modes)
* Dynamic cost modification for card (process only own abilities). Example:
* if it need stack related info (like real targets) then must check two
* states (game.inCheckPlayableState):
*
* 1. In playable state it must check all possible use cases (e.g. allow to
* reduce on any available target and modes)
*
* 2. In real cast state it must check current use case (e.g. real selected
* targets and modes)
*
* @param ability
* @param game

View file

@ -1,8 +1,12 @@
package mage.game.permanent;
import java.util.UUID;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import mage.MageObject;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.keyword.TransformAbility;
@ -11,11 +15,10 @@ import mage.cards.LevelerCard;
import mage.game.Game;
import mage.game.events.ZoneChangeEvent;
import java.util.UUID;
/**
* @author BetaSteward_at_googlemail.com
*/
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class PermanentCard extends PermanentImpl {
protected int maxLevelCounters;
@ -86,6 +89,9 @@ public class PermanentCard extends PermanentImpl {
}
} else {
this.abilities = card.getAbilities().copy();
if (this.spellAbility != null) {
this.spellAbility = (SpellAbility) this.abilities.get(0);
}
}
// adventure cards must show adventure spell info on battlefield too
/*

View file

@ -1,5 +1,6 @@
package mage.game.stack;
import java.util.*;
import mage.MageInt;
import mage.MageObject;
import mage.Mana;
@ -13,7 +14,6 @@ import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.ActivationManaAbilityStep;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.keyword.BestowAbility;
import mage.abilities.keyword.MorphAbility;
import mage.abilities.text.TextPart;
import mage.cards.*;
@ -32,8 +32,6 @@ import mage.players.Player;
import mage.util.GameLog;
import mage.util.SubTypeList;
import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -326,7 +324,7 @@ public class Spell extends StackObjImpl implements Card {
*/
private boolean spellAbilityCheckTargetsAndDeactivateModes(SpellAbility spellAbility, Game game) {
boolean legalModes = false;
for (Iterator<UUID> iterator = spellAbility.getModes().getSelectedModes().iterator(); iterator.hasNext(); ) {
for (Iterator<UUID> iterator = spellAbility.getModes().getSelectedModes().iterator(); iterator.hasNext();) {
UUID nextSelectedModeId = iterator.next();
Mode mode = spellAbility.getModes().get(nextSelectedModeId);
if (!mode.getTargets().isEmpty()) {

View file

@ -1,6 +1,10 @@
package mage.players;
import com.google.common.collect.ImmutableMap;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import mage.ConditionalMana;
import mage.MageObject;
import mage.MageObjectReference;
@ -66,11 +70,6 @@ import mage.util.GameLog;
import mage.util.RandomUtil;
import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
public abstract class PlayerImpl implements Player, Serializable {
private static final Logger logger = Logger.getLogger(PlayerImpl.class);
@ -1145,6 +1144,14 @@ public abstract class PlayerImpl implements Player, Serializable {
return result;
}
/**
*
* @param originalAbility
* @param game
* @param noMana cast it without paying mana costs
* @param permittingObject which object permitted the cast
* @return
*/
@Override
public boolean cast(SpellAbility originalAbility, Game game, boolean noMana, MageObjectReference permittingObject) {
if (game == null || originalAbility == null) {
@ -1486,7 +1493,7 @@ public abstract class PlayerImpl implements Player, Serializable {
return true;
}
}
restoreState(bookmark, triggeredAbility.getRule(), game); // why restore is needed here? (to remove the triggered ability from the stack)
restoreState(bookmark, triggeredAbility.getRule(), game); // why restore is needed here? (to remove the triggered ability from the stack because of no possible targets)
return false;
}
@ -2861,8 +2868,9 @@ public abstract class PlayerImpl implements Player, Serializable {
}
/**
* Returns the mana options the player currently has. That means which combinations of
* mana are available to cast spells or activate abilities etc.
* Returns the mana options the player currently has. That means which
* combinations of mana are available to cast spells or activate abilities
* etc.
*
* @param game
* @return
@ -2919,10 +2927,13 @@ public abstract class PlayerImpl implements Player, Serializable {
}
/**
* Used during calculation of available mana to gather the amount of producable triggered mana caused by using mana sources.
* So the set value is only used during the calculation of the mana produced by one source and cleared thereafter
* Used during calculation of available mana to gather the amount of
* producable triggered mana caused by using mana sources. So the set value
* is only used during the calculation of the mana produced by one source
* and cleared thereafter
*
* @param netManaAvailable the net mana produced by the triggered mana abaility
* @param netManaAvailable the net mana produced by the triggered mana
* abaility
*/
@Override
public void addAvailableTriggeredMana(List<Mana> netManaAvailable) {
@ -2930,8 +2941,9 @@ public abstract class PlayerImpl implements Player, Serializable {
}
/**
* Used during calculation of available mana to get the amount of producable triggered mana caused by using mana sources.
* The list is cleared as soon the value is retrieved during available mana calculation.
* Used during calculation of available mana to get the amount of producable
* triggered mana caused by using mana sources. The list is cleared as soon
* the value is retrieved during available mana calculation.
*
* @return
*/
@ -2940,7 +2952,6 @@ public abstract class PlayerImpl implements Player, Serializable {
return availableTriggeredManaList;
}
// returns only mana producers that don't require mana payment
protected List<MageObject> getAvailableManaProducers(Game game) {
List<MageObject> result = new ArrayList<>();
@ -3364,8 +3375,10 @@ public abstract class PlayerImpl implements Player, Serializable {
* currently cast/activate with his available ressources
*
* @param game
* @param hidden also from hidden objects (e.g. turned face down cards ?)
* @param fromZone of objects from which zone (ALL = from all zones)
* @param hidden also from hidden objects (e.g. turned face
* down cards ?)
* @param fromZone of objects from which zone (ALL = from all
* zones)
* @param hideDuplicatedAbilities if equal abilities exist return only the
* first instance
* @return
@ -4084,7 +4097,7 @@ public abstract class PlayerImpl implements Player, Serializable {
// identify cards from one owner
Cards cards = new CardsImpl();
UUID ownerId = null;
for (Iterator<Card> it = allCards.iterator(); it.hasNext(); ) {
for (Iterator<Card> it = allCards.iterator(); it.hasNext();) {
Card card = it.next();
if (cards.isEmpty()) {
ownerId = card.getOwnerId();