From 63a9a505e105c70f893dffd88a833b6187bf5899 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sun, 23 Jun 2019 17:20:04 +0400 Subject: [PATCH] Fixed that alternative spell always selected to cast if available; --- .../cards/abilities/keywords/AwakenTest.java | 57 ++++++++++++++++++- .../common/CastCommanderAbility.java | 1 + .../mage/abilities/keyword/AwakenAbility.java | 1 + .../mage/abilities/keyword/EmergeAbility.java | 1 + .../abilities/keyword/JumpStartAbility.java | 1 + .../abilities/keyword/RetraceAbility.java | 1 + .../abilities/keyword/SpectacleAbility.java | 1 + .../mage/abilities/keyword/SurgeAbility.java | 1 + 8 files changed, 62 insertions(+), 2 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/AwakenTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/AwakenTest.java index 8492ca90ae..3628f283ac 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/AwakenTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/AwakenTest.java @@ -1,4 +1,3 @@ - package org.mage.test.cards.abilities.keywords; import mage.constants.PhaseStep; @@ -8,7 +7,6 @@ import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; /** - * * @author LevelX2 */ public class AwakenTest extends CardTestPlayerBase { @@ -122,4 +120,59 @@ public class AwakenTest extends CardTestPlayerBase { } + /** + * Select spell ability with different targets + */ + @Test + public void test_CastNormalSpell() { + // Counter target spell. + // Awaken 3—{4}{U}{U} (If you cast this spell for {4}{U}{U}, also put three +1/+1 counters on target land you control + // and it becomes a 0/0 Elemental creature with haste. It’s still a land.) + addCard(Zone.HAND, playerA, "Scatter to the Winds", 1); // {1}{U}{U} + addCard(Zone.BATTLEFIELD, playerA, "Island", 6); + // + addCard(Zone.HAND, playerA, "Lightning Bolt", 1); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + + // cast + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + + // counter by normal cast + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Scatter to the Winds", "Lightning Bolt"); + + checkLife("after", 1, PhaseStep.BEGIN_COMBAT, playerB, 20); + checkHandCardCount("after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Lightning Bolt", 0); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + } + + @Test + public void test_CastAwakenSpell() { + // Counter target spell. + // Awaken 3—{4}{U}{U} (If you cast this spell for {4}{U}{U}, also put three +1/+1 counters on target land you control + // and it becomes a 0/0 Elemental creature with haste. It’s still a land.) + addCard(Zone.HAND, playerA, "Scatter to the Winds", 1); // {1}{U}{U} + addCard(Zone.BATTLEFIELD, playerA, "Island", 6); + // + addCard(Zone.HAND, playerA, "Lightning Bolt", 1); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + + // cast + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + + // counter by normal cast + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Scatter to the Winds with awaken", "Lightning Bolt"); + addTarget(playerA, "Island"); + + checkLife("after", 1, PhaseStep.BEGIN_COMBAT, playerB, 20); + checkHandCardCount("after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Lightning Bolt", 0); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + } } diff --git a/Mage/src/main/java/mage/abilities/common/CastCommanderAbility.java b/Mage/src/main/java/mage/abilities/common/CastCommanderAbility.java index 7daff914a3..740fb3e21a 100644 --- a/Mage/src/main/java/mage/abilities/common/CastCommanderAbility.java +++ b/Mage/src/main/java/mage/abilities/common/CastCommanderAbility.java @@ -12,6 +12,7 @@ public class CastCommanderAbility extends SpellAbility { public CastCommanderAbility(Card card) { super(card.getSpellAbility()); + this.newId(); this.setCardName(cardName = card.getName()); zone = Zone.COMMAND; spellAbilityType = SpellAbilityType.BASE; diff --git a/Mage/src/main/java/mage/abilities/keyword/AwakenAbility.java b/Mage/src/main/java/mage/abilities/keyword/AwakenAbility.java index e315f41775..381f7c42a2 100644 --- a/Mage/src/main/java/mage/abilities/keyword/AwakenAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/AwakenAbility.java @@ -38,6 +38,7 @@ public class AwakenAbility extends SpellAbility { public AwakenAbility(Card card, int awakenValue, String awakenCosts) { super(card.getSpellAbility()); + this.newId(); this.setCardName(card.getName() + " with awaken"); zone = Zone.HAND; spellAbilityType = SpellAbilityType.BASE_ALTERNATE; diff --git a/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java b/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java index f8cfa44aba..24ade34422 100644 --- a/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java @@ -30,6 +30,7 @@ public class EmergeAbility extends SpellAbility { public EmergeAbility(Card card, ManaCosts emergeCost) { super(card.getSpellAbility()); + this.newId(); this.setCardName(card.getName() + " with emerge"); zone = Zone.HAND; spellAbilityType = SpellAbilityType.BASE_ALTERNATE; diff --git a/Mage/src/main/java/mage/abilities/keyword/JumpStartAbility.java b/Mage/src/main/java/mage/abilities/keyword/JumpStartAbility.java index 8293c1af73..5bccff1ddb 100644 --- a/Mage/src/main/java/mage/abilities/keyword/JumpStartAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/JumpStartAbility.java @@ -37,6 +37,7 @@ public class JumpStartAbility extends SpellAbility { public JumpStartAbility(Card card) { super(card.getSpellAbility()); + this.newId(); this.setCardName(card.getName() + " with jump-start"); zone = Zone.GRAVEYARD; spellAbilityType = SpellAbilityType.BASE_ALTERNATE; diff --git a/Mage/src/main/java/mage/abilities/keyword/RetraceAbility.java b/Mage/src/main/java/mage/abilities/keyword/RetraceAbility.java index deee4a1805..c48fb815e5 100644 --- a/Mage/src/main/java/mage/abilities/keyword/RetraceAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/RetraceAbility.java @@ -16,6 +16,7 @@ public class RetraceAbility extends SpellAbility { public RetraceAbility(Card card) { super(card.getSpellAbility()); + this.newId(); this.setCardName(card.getName() + " with retrace"); zone = Zone.GRAVEYARD; spellAbilityType = SpellAbilityType.BASE_ALTERNATE; diff --git a/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java b/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java index 10600c3f68..393da2251e 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java @@ -23,6 +23,7 @@ public class SpectacleAbility extends SpellAbility { public SpectacleAbility(Card card, ManaCost spectacleCosts) { super(card.getSpellAbility()); + this.newId(); this.setCardName(card.getName() + " with spectacle"); zone = Zone.HAND; spellAbilityType = SpellAbilityType.BASE_ALTERNATE; diff --git a/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java b/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java index 63030341c8..f1a335bf8e 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java @@ -23,6 +23,7 @@ public class SurgeAbility extends SpellAbility { public SurgeAbility(Card card, String surgeCosts) { super(card.getSpellAbility()); + this.newId(); this.setCardName(card.getName() + " with surge"); zone = Zone.HAND; spellAbilityType = SpellAbilityType.BASE_ALTERNATE;