From 14b2760e99f24c9ddbcdf2cf5f31337bbf69ee92 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 14 Sep 2016 20:51:03 +0200 Subject: [PATCH] * Fixed a bug that prevented moving tokens to other zones in some cases. --- .../mage/sets/innistrad/GavonyTownship.java | 7 +- .../test/cards/single/EchoingTruthTest.java | 68 +++++++++++++++++++ Mage/src/main/java/mage/cards/CardsImpl.java | 6 +- 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/EchoingTruthTest.java diff --git a/Mage.Sets/src/mage/sets/innistrad/GavonyTownship.java b/Mage.Sets/src/mage/sets/innistrad/GavonyTownship.java index 0fecbaf4dd2..81e1ecd7921 100644 --- a/Mage.Sets/src/mage/sets/innistrad/GavonyTownship.java +++ b/Mage.Sets/src/mage/sets/innistrad/GavonyTownship.java @@ -1,5 +1,6 @@ package mage.sets.innistrad; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; @@ -13,14 +14,16 @@ import mage.constants.Zone; import mage.counters.CounterType; import mage.filter.common.FilterControlledCreaturePermanent; -import java.util.UUID; - public class GavonyTownship extends CardImpl { + public GavonyTownship(UUID ownerId) { super(ownerId, 239, "Gavony Township", Rarity.RARE, new CardType[]{CardType.LAND}, null); this.expansionSetCode = "ISD"; + // {T}: Add {1} to your mana pool. this.addAbility(new ColorlessManaAbility()); + + // {2}{G}{W}, {T}: Put a +1/+1 counter on each creature you control. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersAllEffect(CounterType.P1P1.createInstance(), new FilterControlledCreaturePermanent("creature you control")), new ManaCostsImpl("{2}{G}{W}")); ability.addCost(new TapSourceCost()); this.addAbility(ability); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/EchoingTruthTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/EchoingTruthTest.java new file mode 100644 index 00000000000..aecfb406e7f --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/EchoingTruthTest.java @@ -0,0 +1,68 @@ +/* + * 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.single; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class EchoingTruthTest extends CardTestPlayerBase { + + /** + * I played "Echoing Truth" targeting one of my opponent's spirit tokens + * from Spectral Processions and NONE OF THEM got bounced. + */ + @Test + public void testReturnTokens() { + addCard(Zone.BATTLEFIELD, playerA, "Plains", 3); + addCard(Zone.HAND, playerA, "Spectral Procession"); + + addCard(Zone.BATTLEFIELD, playerB, "Island", 2); + addCard(Zone.HAND, playerB, "Echoing Truth"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Spectral Procession"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Echoing Truth", "Spirit"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertGraveyardCount(playerA, "Spectral Procession", 1); + assertGraveyardCount(playerB, "Echoing Truth", 1); + assertPermanentCount(playerA, "Spirit", 0); + + } + +} diff --git a/Mage/src/main/java/mage/cards/CardsImpl.java b/Mage/src/main/java/mage/cards/CardsImpl.java index af2f3a2400c..55123325f38 100644 --- a/Mage/src/main/java/mage/cards/CardsImpl.java +++ b/Mage/src/main/java/mage/cards/CardsImpl.java @@ -182,9 +182,13 @@ public class CardsImpl extends LinkedHashSet implements Cards, Serializabl @Override public Set getCards(Game game) { Set cards = new LinkedHashSet<>(); - for (Iterator it = this.iterator(); it.hasNext();) { // Changed to iterator becuase of ConcurrentModificationException + for (Iterator it = this.iterator(); it.hasNext();) { // Changed to iterator because of ConcurrentModificationException UUID cardId = it.next(); + Card card = game.getCard(cardId); + if (card == null) { + card = game.getPermanent(cardId); // needed to get TokenCard objects + } if (card != null) { // this can happen during the cancelation (player concedes) of a game cards.add(card); }