From 5a5722b248c8a2b57392fe21b05ec4849d7f6fe0 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 29 May 2015 00:18:51 +0200 Subject: [PATCH] * Skarrgan Firebird - Fixed that the condtion check of the activated ability was inverted. --- .../heroesvsmonsters/SkarrganFirebird.java | 2 +- .../src/mage/sets/mirrodin/Bonesplitter.java | 2 + .../activated/PutOntoBattlefieldTest.java | 98 +++++++++---------- .../abilities/activated/ReturnToHandTest.java | 78 +++++++++++++++ .../abilities/keyword/BloodthirstAbility.java | 2 +- Mage/src/mage/game/GameImpl.java | 19 ++-- Mage/src/mage/players/PlayerImpl.java | 2 +- ...fDamageAPlayerReceivedThisTurnWatcher.java | 4 +- .../common/SourceDidDamageWatcher.java | 2 +- 9 files changed, 145 insertions(+), 64 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/ReturnToHandTest.java diff --git a/Mage.Sets/src/mage/sets/heroesvsmonsters/SkarrganFirebird.java b/Mage.Sets/src/mage/sets/heroesvsmonsters/SkarrganFirebird.java index 029a6c6655d..9a170f2e022 100644 --- a/Mage.Sets/src/mage/sets/heroesvsmonsters/SkarrganFirebird.java +++ b/Mage.Sets/src/mage/sets/heroesvsmonsters/SkarrganFirebird.java @@ -88,7 +88,7 @@ class OpponentWasDealtDamageCondition implements Condition { @Override public boolean apply(Game game, Ability source) { BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId()); - return !watcher.conditionMet(); + return watcher.conditionMet(); } @Override diff --git a/Mage.Sets/src/mage/sets/mirrodin/Bonesplitter.java b/Mage.Sets/src/mage/sets/mirrodin/Bonesplitter.java index 7e0283aeb0c..ccf8f2c157c 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/Bonesplitter.java +++ b/Mage.Sets/src/mage/sets/mirrodin/Bonesplitter.java @@ -48,6 +48,8 @@ public class Bonesplitter extends CardImpl { super(ownerId, 146, "Bonesplitter", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{1}"); this.expansionSetCode = "MRD"; this.subtype.add("Equipment"); + + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(2, 0))); this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(1))); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/PutOntoBattlefieldTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/PutOntoBattlefieldTest.java index 1ab753078be..b89eb696780 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/PutOntoBattlefieldTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/PutOntoBattlefieldTest.java @@ -1,51 +1,49 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.mage.test.cards.abilities.activated; - -import mage.constants.PhaseStep; -import mage.constants.Zone; -import mage.game.permanent.Permanent; -import org.junit.Assert; -import org.junit.Test; -import org.mage.test.serverside.base.CardTestPlayerBase; - -/** - * - * @author LevelX2 - */ - -public class PutOntoBattlefieldTest extends CardTestPlayerBase { - - /** - * Tests to put a token onto the battlefield - */ - @Test - public void testOozeFlux() { - // Enchantment - // {1}{G}, Remove one or more +1/+1 counters from among creatures you control: Put an X/X green Ooze creature token onto the battlefield, where X is the number of +1/+1 counters removed this way. - addCard(Zone.BATTLEFIELD, playerA, "Ooze Flux"); - // Trample - // Kalonian Hydra enters the battlefield with four +1/+1 counters on it. - // Whenever Kalonian Hydra attacks, double the number of +1/+1 counters on each creature you control. - addCard(Zone.BATTLEFIELD, playerA, "Kalonian Hydra"); - addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); - - activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{G},"); - setChoice(playerA, "X=2"); // Remove how many - setChoice(playerA,"Kalonian Hydra"); - setChoice(playerA, "X=2"); // Remove from Hydra - - setStopAt(1, PhaseStep.BEGIN_COMBAT); - execute(); - - assertPowerToughness(playerA, "Kalonian Hydra", 2, 2); - assertPermanentCount(playerA, "Ooze", 1); - assertPowerToughness(playerA, "Ooze", 2, 2); - - } - - +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.mage.test.cards.abilities.activated; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ + +public class PutOntoBattlefieldTest extends CardTestPlayerBase { + + /** + * Tests to put a token onto the battlefield + */ + @Test + public void testOozeFlux() { + // Enchantment + // {1}{G}, Remove one or more +1/+1 counters from among creatures you control: Put an X/X green Ooze creature token onto the battlefield, where X is the number of +1/+1 counters removed this way. + addCard(Zone.BATTLEFIELD, playerA, "Ooze Flux"); + // Trample + // Kalonian Hydra enters the battlefield with four +1/+1 counters on it. + // Whenever Kalonian Hydra attacks, double the number of +1/+1 counters on each creature you control. + addCard(Zone.BATTLEFIELD, playerA, "Kalonian Hydra"); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{G},"); + setChoice(playerA, "X=2"); // Remove how many + setChoice(playerA,"Kalonian Hydra"); + setChoice(playerA, "X=2"); // Remove from Hydra + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPowerToughness(playerA, "Kalonian Hydra", 2, 2); + assertPermanentCount(playerA, "Ooze", 1); + assertPowerToughness(playerA, "Ooze", 2, 2); + + } + + } \ No newline at end of file diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/ReturnToHandTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/ReturnToHandTest.java new file mode 100644 index 00000000000..3b87ec843a1 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/ReturnToHandTest.java @@ -0,0 +1,78 @@ +/* + * 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.activated; + +import mage.abilities.keyword.BloodthirstAbility; +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ + +public class ReturnToHandTest extends CardTestPlayerBase { + + /** + * Tests to put a token onto the battlefield + */ + @Test + public void SkarrganFirebirdTest() { + addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox"); + // Bloodthirst 3 + // Flying + // {R}{R}{R}: Return Skarrgan Firebird from your graveyard to your hand. Activate this ability only if an opponent was dealt damage this turn. + addCard(Zone.BATTLEFIELD, playerB, "Skarrgan Firebird"); + addCard(Zone.BATTLEFIELD, playerB, "Swamp", 2); + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 3); + addCard(Zone.HAND, playerB, "Bone Splinters"); + + // As an additional cost to cast Bone Splinters, sacrifice a creature. + // Destroy target creature. + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Bone Splinters", "Pillarfield Ox"); + setChoice(playerB, "Skarrgan Firebird"); + + attack(2, playerB, "Silvercoat Lion"); + + activateAbility(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "{R}{R}{R}: Return"); + setStopAt(2, PhaseStep.END_TURN); + + execute(); + + assertPermanentCount(playerA, "Skarrgan Firebird", 0); + assertGraveyardCount(playerA, "Pillarfield Ox", 1); + assertGraveyardCount(playerB, "Bone Splinters", 1); + assertHandCount(playerB, "Skarrgan Firebird", 1); + + } + + +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/keyword/BloodthirstAbility.java b/Mage/src/mage/abilities/keyword/BloodthirstAbility.java index 2d768a1a903..f93ca9824d6 100644 --- a/Mage/src/mage/abilities/keyword/BloodthirstAbility.java +++ b/Mage/src/mage/abilities/keyword/BloodthirstAbility.java @@ -48,7 +48,7 @@ public class BloodthirstAbility extends EntersBattlefieldAbility { } class BloodthirstEffect extends OneShotEffect { - private int amount; + private final int amount; BloodthirstEffect(int amount) { super(Outcome.BoostCreature); diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 960ad22c8dd..8251d6e7adc 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -30,7 +30,6 @@ package mage.game; import java.io.IOException; import java.io.Serializable; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -118,7 +117,9 @@ import mage.target.Target; import mage.target.TargetPermanent; import mage.target.TargetPlayer; import mage.util.functions.ApplyToPermanent; +import mage.watchers.Watchers; import mage.watchers.common.BlockedAttackerWatcher; +import mage.watchers.common.BloodthirstWatcher; import mage.watchers.common.CastSpellLastTurnWatcher; import mage.watchers.common.MorbidWatcher; import mage.watchers.common.PlayerDamagedBySourceWatcher; @@ -884,15 +885,17 @@ public abstract class GameImpl implements Game, Serializable { saveState(false); } while (!mulliganPlayers.isEmpty()); getState().setChoosingPlayerId(null); - // add watchers + Watchers watchers = state.getWatchers(); + // add default watchers for (UUID playerId : state.getPlayerList(startingPlayerId)) { - state.getWatchers().add(new PlayerDamagedBySourceWatcher(playerId)); + watchers.add(new PlayerDamagedBySourceWatcher(playerId)); + watchers.add(new BloodthirstWatcher(playerId)); } - state.getWatchers().add(new MorbidWatcher()); - state.getWatchers().add(new CastSpellLastTurnWatcher()); - state.getWatchers().add(new SoulbondWatcher()); - state.getWatchers().add(new PlayerLostLifeWatcher()); - state.getWatchers().add(new BlockedAttackerWatcher()); + watchers.add(new MorbidWatcher()); + watchers.add(new CastSpellLastTurnWatcher()); + watchers.add(new SoulbondWatcher()); + watchers.add(new PlayerLostLifeWatcher()); + watchers.add(new BlockedAttackerWatcher()); //20100716 - 103.5 for (UUID playerId: state.getPlayerList(startingPlayerId)) { diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 63447e9681d..f5cc42cb979 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -444,7 +444,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.payManaMode = false; this.setLife(game.getLife(), game); this.setReachedNextTurnAfterLeaving(false); - game.getState().getWatchers().add(new BloodthirstWatcher(playerId)); + this.castSourceIdWithAlternateMana = null; this.castSourceIdManaCosts = null; } diff --git a/Mage/src/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java b/Mage/src/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java index 027063ccfaa..803239868ea 100644 --- a/Mage/src/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java +++ b/Mage/src/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java @@ -65,9 +65,9 @@ public class AmountOfDamageAPlayerReceivedThisTurnWatcher extends Watcher { if (playerId != null) { Integer amount = amountOfDamageReceivedThisTurn.get(playerId); if (amount == null) { - amount = Integer.valueOf(event.getAmount()); + amount = event.getAmount(); } else { - amount = Integer.valueOf(amount + event.getAmount()); + amount = amount + event.getAmount(); } amountOfDamageReceivedThisTurn.put(playerId, amount); } diff --git a/Mage/src/mage/watchers/common/SourceDidDamageWatcher.java b/Mage/src/mage/watchers/common/SourceDidDamageWatcher.java index 94072d1ddb4..cb873e23c8f 100644 --- a/Mage/src/mage/watchers/common/SourceDidDamageWatcher.java +++ b/Mage/src/mage/watchers/common/SourceDidDamageWatcher.java @@ -44,7 +44,7 @@ import java.util.UUID; */ public class SourceDidDamageWatcher extends Watcher { - public List damageSources = new ArrayList(); + public List damageSources = new ArrayList<>(); public SourceDidDamageWatcher() { super("SourceDidDamageWatcher", WatcherScope.GAME);