From e509a35795eca77ead6a6422d931501d3f129573 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 20 Jun 2015 01:07:35 +0200 Subject: [PATCH] Fixed a bug that existing continuous effects were not applied before state based effects were checked. --- .../java/mage/player/ai/ComputerPlayer.java | 5 +- .../mage/sets/magic2011/SerraAscendant.java | 3 + .../cards/continuous/SerraAscendantTest.java | 94 +++++++++++++++++++ Mage/src/mage/game/GameImpl.java | 1 + 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/continuous/SerraAscendantTest.java diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 1ba65e80b4..dda37ca177 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -311,8 +311,9 @@ public class ComputerPlayer extends PlayerImpl implements Player { if (card != null) { cards.add(card); } - } - while(!target.isChosen() && !cards.isEmpty()) { + } + while((outcome.isGood() ? target.getTargets().size() < target.getMaxNumberOfTargets() : !target.isChosen()) + && !cards.isEmpty()) { Card pick = pickTarget(cards, outcome, target, null, game); if (pick != null) { target.addTarget(pick.getId(), null, game); diff --git a/Mage.Sets/src/mage/sets/magic2011/SerraAscendant.java b/Mage.Sets/src/mage/sets/magic2011/SerraAscendant.java index a631cbf839..6249ea6ee6 100644 --- a/Mage.Sets/src/mage/sets/magic2011/SerraAscendant.java +++ b/Mage.Sets/src/mage/sets/magic2011/SerraAscendant.java @@ -62,7 +62,10 @@ public class SerraAscendant extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(1); + // Lifelink (Damage dealt by this creature also causes you to gain that much life.) this.addAbility(LifelinkAbility.getInstance()); + + // As long as you have 30 or more life, Serra Ascendant gets +5/+5 and has flying. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SerraAscendantEffect())); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/SerraAscendantTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/SerraAscendantTest.java new file mode 100644 index 0000000000..3e5cd7ae3c --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/SerraAscendantTest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package org.mage.test.cards.continuous; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ + +public class SerraAscendantTest extends CardTestPlayerBase { + + /** + * The game goes on; he plays his Serra Ascendant on turn one, passes the + * turn, you play your newly unbanned Wild Nacatl with a Stomping Ground and + * also pass the turn. On turn 2, he casts a Martyr of Sands and sacrifices + * it, revealing 3 white cards to gain 9 life and end up at 29. He goes to + * the combat phase, declares Serra as an attacker, and you happily block + * him, thinking that this is such a bad move from him. After the damage is + * dealt, the Serra is still there, bigger than ever. + */ + @Test + public void testSilence() { + addCard(Zone.HAND, playerA, "Plains", 2); + // As long as you have 30 or more life, Serra Ascendant gets +5/+5 and has flying. + addCard(Zone.HAND, playerA, "Serra Ascendant"); + // {1}, Reveal X white cards from your hand, Sacrifice Martyr of Sands: You gain three times X life. + addCard(Zone.HAND, playerA, "Martyr of Sands"); + addCard(Zone.HAND, playerA, "Silvercoat Lion",3); + + addCard(Zone.HAND, playerB, "Stomping Ground", 1); + addCard(Zone.HAND, playerB, "Wild Nacatl", 1); + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Plains"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Serra Ascendant"); + + playLand(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Stomping Ground"); + setChoice(playerB, "Yes"); + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Wild Nacatl"); + + playLand(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Plains"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Martyr of Sands"); + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{1},You may reveal X white cards from your hand"); + setChoice(playerA,"X=3"); + + attack(3, playerA, "Serra Ascendant"); + block(3, playerB, "Wild Nacatl", "Serra Ascendant"); + + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + + execute(); + + assertGraveyardCount(playerA, "Martyr of Sands", 1); + + assertLife(playerB, 18); + assertLife(playerA, 30); + + assertPermanentCount(playerB, "Wild Nacatl", 1); + + assertPermanentCount(playerA, "Serra Ascendant", 1); + assertPowerToughness(playerA, "Serra Ascendant", 6, 6); + + } + +} \ No newline at end of file diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 505bfa8c0f..28383956d0 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -1144,6 +1144,7 @@ public abstract class GameImpl implements Game, Serializable { int bookmark = 0; clearAllBookmarks(); try { + applyEffects(); while (!isPaused() && !gameOver(null) && !this.getTurn().isEndTurnRequested()) { if (!resuming) { state.getPlayers().resetPassed();