From 71860b01683867841c5547edf392233f7887bbe6 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 3 Sep 2015 11:29:59 +0200 Subject: [PATCH] Adde AbilityWord "Rally" to rule text of AllyEntersBattlefieldTriggeredAbility. Added a test. --- .../abilities/oneshot/destroy/BoilTest.java | 66 +++++++++++++++++++ ...AllyEntersBattlefieldTriggeredAbility.java | 17 ++--- 2 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/destroy/BoilTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/destroy/BoilTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/destroy/BoilTest.java new file mode 100644 index 00000000000..c7eabd0ac60 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/destroy/BoilTest.java @@ -0,0 +1,66 @@ +/* + * 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.abilities.oneshot.destroy; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class BoilTest extends CardTestPlayerBase { + + @Test + public void testDestroy() { + addCard(Zone.BATTLEFIELD, playerA, "Island", 1); + addCard(Zone.BATTLEFIELD, playerA, "Breeding Pool"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + // Destroy all Islands. + addCard(Zone.HAND, playerA, "Boil"); // {3}{R} + + addCard(Zone.BATTLEFIELD, playerB, "Island", 1); + addCard(Zone.BATTLEFIELD, playerB, "Breeding Pool"); + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Boil"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Island", 0); + assertPermanentCount(playerA, "Breeding Pool", 0); + assertPermanentCount(playerA, "Mountain", 2); + + assertPermanentCount(playerB, "Island", 0); + assertPermanentCount(playerB, "Breeding Pool", 0); + assertPermanentCount(playerB, "Mountain", 2); + } +} diff --git a/Mage/src/mage/abilities/common/AllyEntersBattlefieldTriggeredAbility.java b/Mage/src/mage/abilities/common/AllyEntersBattlefieldTriggeredAbility.java index 341e1161952..9252d5d9e0d 100644 --- a/Mage/src/mage/abilities/common/AllyEntersBattlefieldTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/AllyEntersBattlefieldTriggeredAbility.java @@ -27,14 +27,12 @@ */ package mage.abilities.common; -import java.util.UUID; -import mage.constants.Zone; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; +import mage.constants.Zone; import mage.game.Game; +import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.game.permanent.Permanent; /** * @@ -57,11 +55,10 @@ public class AllyEntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl @Override public boolean checkTrigger(GameEvent event, Game game) { - UUID targetId = event.getTargetId(); - Permanent permanent = game.getPermanent(targetId); - if (permanent.getControllerId().equals(this.controllerId) - && (targetId.equals(this.getSourceId()) - || (permanent.hasSubtype("Ally") && !targetId.equals(this.getSourceId())))) { + EntersTheBattlefieldEvent ebe = (EntersTheBattlefieldEvent) event; + if (ebe.getTarget().getControllerId().equals(this.controllerId) + && (event.getTargetId().equals(this.getSourceId()) + || (ebe.getTarget().hasSubtype("Ally") && !event.getTargetId().equals(this.getSourceId())))) { return true; } return false; @@ -69,7 +66,7 @@ public class AllyEntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl @Override public String getRule() { - return "Whenever {this} or another Ally enters the battlefield under your control, " + super.getRule(); + return "Rally — Whenever {this} or another Ally enters the battlefield under your control, " + super.getRule(); } @Override