* Court Hussar, Azorius Herald fixed mana was spent condition for permanents. Batwing Brume - Fixed both triggered effects that did not work correctly.

This commit is contained in:
LevelX2 2014-06-20 19:26:15 +02:00
parent bcf620a459
commit d27540a502
7 changed files with 290 additions and 13 deletions

View file

@ -41,6 +41,7 @@ import mage.constants.ColoredManaSymbol;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.watchers.common.ManaSpentToCastWatcher;
/**
*
@ -66,6 +67,7 @@ public class CourtHussar extends CardImpl {
false));
// When Court Hussar enters the battlefield, sacrifice it unless {W} was spent to cast it.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeSourceUnlessConditionEffect(new ManaWasSpentCondition(ColoredManaSymbol.W)), false));
this.addWatcher(new ManaSpentToCastWatcher());
}
public CourtHussar(final CourtHussar card) {
@ -77,3 +79,4 @@ public class CourtHussar extends CardImpl {
return new CourtHussar(this);
}
}

View file

@ -38,6 +38,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Rarity;
import mage.watchers.common.ManaSpentToCastWatcher;
/**
*
@ -60,7 +61,7 @@ public class AzoriusHerald extends CardImpl {
this.addAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(4)));
// When Azorius Herald enters the battlefield, sacrifice it unless {U} was spent to cast it.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeSourceUnlessConditionEffect(new ManaWasSpentCondition(ColoredManaSymbol.U)), false));
this.addWatcher(new ManaSpentToCastWatcher());
}
public AzoriusHerald(final AzoriusHerald card) {

View file

@ -30,15 +30,15 @@ package mage.sets.eventide;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.common.ManaWasSpentCondition;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.decorator.ConditionalReplacementEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PreventAllDamageByAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Duration;
import mage.constants.ManaType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.common.FilterAttackingCreature;
@ -60,12 +60,13 @@ public class BatwingBrume extends CardImpl {
this.color.setWhite(true);
// Prevent all combat damage that would be dealt this turn if {W} was spent to cast Batwing Brume. Each player loses 1 life for each attacking creature he or she controls if {B} was spent to cast Batwing Brume.
this.getSpellAbility().addEffect(new ConditionalContinousEffect(
new PreventAllDamageByAllEffect(Duration.EndOfTurn, true),
new ManaWasSpentCondition(ColoredManaSymbol.W), "Prevent all combat damage that would be dealt this turn if {W} was spent to cast {this}", true));
Effect effect = new ConditionalReplacementEffect(new PreventAllDamageByAllEffect(Duration.EndOfTurn, true),
new ManaWasSpentCondition(ColoredManaSymbol.W), true);
effect.setText("Prevent all combat damage that would be dealt this turn if {W} was spent to cast {this}");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new BatwingBrumeEffect(),
new ManaWasSpentCondition(ColoredManaSymbol.W), "Each player loses 1 life for each attacking creature he or she controls if {B} was spent to cast {this}"));
new ManaWasSpentCondition(ColoredManaSymbol.B), "Each player loses 1 life for each attacking creature he or she controls if {B} was spent to cast {this}"));
this.addInfo("Info1", "<i>(Do both if {W}{B} was spent.)<i>");
}
@ -92,13 +93,20 @@ class BatwingBrumeEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
for (Player player : game.getPlayers().values()) {
if (player != null) {
final int amount = game.getBattlefield().getAllActivePermanents(new FilterAttackingCreature(), player.getId(), game).size();
player.loseLife(amount, game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : controller.getInRange()) {
final int amount = game.getBattlefield().getAllActivePermanents(new FilterAttackingCreature(), playerId, game).size();
if (amount > 0) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.loseLife(amount, game);
}
}
}
return true;
}
return true;
return false;
}
@Override

View file

@ -0,0 +1,80 @@
/*
* 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 CourtHussarTest extends CardTestPlayerBase {
// When Court Hussar enters the battlefield, sacrifice it unless {W} was spent to cast it.
@Test
public void testWhiteManaWasPaidCard() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerA, "Island");
addCard(Zone.HAND, playerA, "Court Hussar");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Court Hussar");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Court Hussar", 1);
}
@Test
public void testNoWhiteManaWasPaidCard() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
addCard(Zone.BATTLEFIELD, playerA, "Island");
addCard(Zone.HAND, playerA, "Court Hussar");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Court Hussar");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Court Hussar", 0);
}
}

View file

@ -0,0 +1,87 @@
/*
* 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.triggers;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class BatwingBrumeTest extends CardTestPlayerBase {
/**
* Batwing Brume
* Instant {B}{1}
* Prevent all combat damage that would be dealt this turn if {W} was spent to
* cast Batwing Brume. Each player loses 1 life for each attacking creature he
* or she controls if {B} was spent to cast Batwing Brume.
*
*/
@Test
public void testWhiteAndBlackManaWasPaidCard() {
addCard(Zone.BATTLEFIELD, playerA, "Plains");
addCard(Zone.BATTLEFIELD, playerA, "Swamp");
addCard(Zone.HAND, playerA, "Batwing Brume");
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
attack(2, playerB, "Silvercoat Lion");
castSpell(2, PhaseStep.DECLARE_BLOCKERS, playerA, "Batwing Brume");
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 20);
assertLife(playerB, 19);
}
@Test
public void testOnlyBlackManaWasPaidCard() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
addCard(Zone.HAND, playerA, "Batwing Brume");
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
attack(2, playerB, "Silvercoat Lion");
castSpell(2, PhaseStep.DECLARE_BLOCKERS, playerA, "Batwing Brume");
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 18);
assertLife(playerB, 19);
}
}

View file

@ -28,12 +28,16 @@
package mage.abilities.condition.common;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.AbilityType;
import mage.constants.ColoredManaSymbol;
import mage.game.Game;
import mage.watchers.common.ManaSpentToCastWatcher;
/**
* Checks if the specific mana was spent to cast the spell
*
* @author LevelX2
*/
@ -49,7 +53,17 @@ public class ManaWasSpentCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
return (source.getManaCostsToPay().getPayment().getColor(coloredManaSymbol) > 0);
if (source.getAbilityType().equals(AbilityType.SPELL)) {
return (source.getManaCostsToPay().getPayment().getColor(coloredManaSymbol) > 0);
}
ManaSpentToCastWatcher watcher = (ManaSpentToCastWatcher) game.getState().getWatchers().get("ManaSpentToCast", source.getSourceId());
if (watcher != null) {
Mana payment = watcher.getAndResetLastPayment();
if (payment != null) {
return payment.getColor(coloredManaSymbol) > 0;
}
}
return false;
}
@Override

View file

@ -0,0 +1,84 @@
/*
* 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 mage.watchers.common;
import mage.Mana;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.watchers.Watcher;
/**
* Watcher saves the mana that was spent to cast a spell
*
*
* @author LevelX2
*/
public class ManaSpentToCastWatcher extends Watcher {
Mana payment = null;
public ManaSpentToCastWatcher() {
super("ManaSpentToCast", WatcherScope.CARD);
}
public ManaSpentToCastWatcher(final ManaSpentToCastWatcher watcher) {
super(watcher);
this.payment = watcher.payment;
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.HAND) {
Spell spell = (Spell) game.getObject(event.getTargetId());
if (this.getSourceId().equals(spell.getSourceId())) {
payment = spell.getSpellAbility().getManaCostsToPay().getPayment();
}
}
}
@Override
public ManaSpentToCastWatcher copy() {
return new ManaSpentToCastWatcher(this);
}
public Mana getAndResetLastPayment() {
Mana returnPayment = null;
if (payment != null) {
returnPayment = payment.copy();
// reset payment for next check
payment = null;
}
return returnPayment;
}
}