From e9560bb2b619162c45b9a012ba0c921140599e6a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 24 Aug 2014 18:33:50 +0200 Subject: [PATCH] Added apply effects to handle successive events without getting again priority (e.g. creature dies that boost other creature and so on). --- .../cards/continuous/ElvishArchdruidTest.java | 64 +++++++++++++++++++ .../base/impl/CardTestPlayerAPIImpl.java | 4 +- Mage/src/mage/game/GameImpl.java | 2 + Mage/src/mage/game/turn/Turn.java | 2 +- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/continuous/ElvishArchdruidTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ElvishArchdruidTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ElvishArchdruidTest.java new file mode 100644 index 0000000000..daddf04663 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/ElvishArchdruidTest.java @@ -0,0 +1,64 @@ +/* + * 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 ElvishArchdruidTest extends CardTestPlayerBase { + + /** + * Elvish Archdruid gives +1/+1 to Nettle Sentinel + * If Archdruid dies and Nettle Sentinel has got 2 damage + * Nettle Sentile must go to graveyard immedeately + */ + @Test + public void testBoostWithUndying() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.BATTLEFIELD, playerA, "Elvish Archdruid", 1); + addCard(Zone.BATTLEFIELD, playerA, "Nettle Sentinel", 1); + addCard(Zone.HAND, playerA, "Pyroclasm"); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Pyroclasm"); + + setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertGraveyardCount(playerA, "Pyroclasm", 1); + assertPermanentCount(playerA, "Elvish Archdruid", 0); + assertPermanentCount(playerA, "Nettle Sentinel", 0); + } + +} \ No newline at end of file diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index 32b7fb111d..4212d38167 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -224,7 +224,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement */ @Override public void setStopOnTurn(int turn) { - stopOnTurn = turn == -1 ? null : Integer.valueOf(turn); + stopOnTurn = turn == -1 ? null : turn; stopAtStep = PhaseStep.UNTAP; } @@ -236,7 +236,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement */ @Override public void setStopAt(int turn, PhaseStep step) { - stopOnTurn = turn == -1 ? null : Integer.valueOf(turn); + stopOnTurn = turn == -1 ? null : turn; stopAtStep = step; } diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 8567c2eefb..98b5471742 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -1278,6 +1278,7 @@ public abstract class GameImpl implements Game, Serializable { //20091005 - 115.5 while (!isPaused() && !gameOver(null)) { if (!checkStateBasedActions() ) { + // nothing happened so check triggers if (trigger) { state.handleSimultaneousEvent(this); } @@ -1285,6 +1286,7 @@ public abstract class GameImpl implements Game, Serializable { break; } } + applyEffects(); // needed e.g if boost effects end and cause creatures to die somethingHappened = true; } return somethingHappened; diff --git a/Mage/src/mage/game/turn/Turn.java b/Mage/src/mage/game/turn/Turn.java index 348f3fbc88..8101f69bd6 100644 --- a/Mage/src/mage/game/turn/Turn.java +++ b/Mage/src/mage/game/turn/Turn.java @@ -284,7 +284,7 @@ public class Turn implements Serializable { // 3) State-based actions are checked. No player gets priority, and no triggered abilities are put onto the stack. - game.checkStateAndTriggered(); // triggered effects don't go to steck because check of endTurnRequested + game.checkStateAndTriggered(); // triggered effects don't go to stack because check of endTurnRequested // 4) The current phase and/or step ends. // The game skips straight to the cleanup step. The cleanup step happens in its entirety.