* Chandra's Phoenix - Fixed check for source object doing damage to opponents.

This commit is contained in:
LevelX2 2015-12-03 16:36:30 +01:00
parent fc719699a3
commit 0af5ed4e7b
7 changed files with 148 additions and 17 deletions

View file

@ -39,7 +39,6 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.PowerPredicate;
@ -48,18 +47,18 @@ import mage.filter.predicate.permanent.TappedPredicate;
/**
*
* @author BursegSardaukar
*
*/
public class GoblinMutant extends CardImpl {
static final private FilterCreaturePermanent filter = new FilterCreaturePermanent("untapped creature with power 3 or greater");
static final private FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creatures with power 3 or greater");
static {
filter.add(Predicates.and(new PowerPredicate(Filter.ComparisonType.GreaterThan, 2), Predicates.not(new TappedPredicate())));
filter2.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 2));
}
public GoblinMutant(UUID ownerId) {
super(ownerId, 188, "Goblin Mutant", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{R}{R}");
this.expansionSetCode = "ICE";
@ -71,12 +70,12 @@ public class GoblinMutant extends CardImpl {
//Trample
this.addAbility(TrampleAbility.getInstance());
// Goblin Mutant can't attack if defending player controls an untapped creature with power 3 or greater.
Effect effect = new CantAttackIfDefenderControlsPermanent(filter);
effect.setText("{this} can't attack if defending player controls an untapped creature with power 3 or greater.");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
//Goblin Mutant can't block creatures with power 3 or greater.
Effect effectBlock = new CantBlockCreaturesSourceEffect(filter2);
effectBlock.setText("{this} can't block creatures with power 3 or greater.");

View file

@ -29,11 +29,11 @@ package mage.sets.magic2012;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.ReturnToHandSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
@ -41,6 +41,8 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.StackAbility;
import mage.game.stack.StackObject;
/**
*
@ -56,8 +58,11 @@ public class ChandrasPhoenix extends CardImpl {
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Haste (This creature can attack and as soon as it comes under your control.)
this.addAbility(HasteAbility.getInstance());
// Whenever an opponent is dealt damage by a red instant or sorcery spell you control or by a red planeswalker you control, return Chandra's Phoenix from your graveyard to your hand.
this.addAbility(new ChandrasPhoenixTriggeredAbility());
}
@ -72,6 +77,7 @@ public class ChandrasPhoenix extends CardImpl {
}
class ChandrasPhoenixTriggeredAbility extends TriggeredAbilityImpl {
ChandrasPhoenixTriggeredAbility() {
super(Zone.GRAVEYARD, new ReturnToHandSourceEffect());
}
@ -93,10 +99,21 @@ class ChandrasPhoenixTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
Card c = game.getCard(event.getSourceId());
if (c != null) {
if (c.getColor(game).isRed() && (c.getCardType().contains(CardType.PLANESWALKER) || c.getCardType().contains(CardType.INSTANT) || c.getCardType().contains(CardType.SORCERY))) {
return true;
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (stackObject != null) {
MageObject sourceObjectDamage;
if (stackObject instanceof StackAbility) {
sourceObjectDamage = ((StackAbility) stackObject).getSourceObject(game);
} else {
sourceObjectDamage = stackObject;
}
if (sourceObjectDamage != null) {
if (sourceObjectDamage.getColor(game).isRed()
&& (sourceObjectDamage.getCardType().contains(CardType.PLANESWALKER)
|| sourceObjectDamage.getCardType().contains(CardType.INSTANT)
|| sourceObjectDamage.getCardType().contains(CardType.SORCERY))) {
return true;
}
}
}
}

View file

@ -1,19 +1,46 @@
/*
* 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.sets.mediainserts;
import java.util.UUID;
public class ChandrasPhoenix extends mage.sets.magic2012.ChandrasPhoenix {
public ChandrasPhoenix(UUID ownerId) {
super(ownerId);
this.cardNumber = 37;
this.expansionSetCode = "MBP";
}
public ChandrasPhoenix(final ChandrasPhoenix card) {
super(card);
}
@Override
public ChandrasPhoenix copy() {
return new ChandrasPhoenix(this);

View file

@ -0,0 +1,88 @@
/*
* 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.damage;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class ChandrasPhoenixTest extends CardTestPlayerBase {
@Test
public void testReturnByInstantSpell() {
// Flying
// Haste (This creature can attack and as soon as it comes under your control.)
// Whenever an opponent is dealt damage by a red instant or sorcery spell you control or by a red planeswalker you control, return Chandra's Phoenix from your graveyard to your hand.
addCard(Zone.GRAVEYARD, playerA, "Chandra's Phoenix", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.HAND, playerA, "Lightning Bolt", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertLife(playerA, 20);
assertLife(playerB, 17);
assertHandCount(playerA, "Chandra's Phoenix", 1);
}
@Test
public void testReturnByPlaneswalkerDamage() {
// Flying
// Haste (This creature can attack and as soon as it comes under your control.)
// Whenever an opponent is dealt damage by a red instant or sorcery spell you control or by a red planeswalker you control, return Chandra's Phoenix from your graveyard to your hand.
addCard(Zone.GRAVEYARD, playerA, "Chandra's Phoenix", 1);
// +1: Chandra Nalaar deals 1 damage to target player.
// -X: Chandra Nalaar deals X damage to target creature.
// -8: Chandra Nalaar deals 10 damage to target player and each creature he or she controls.
addCard(Zone.BATTLEFIELD, playerA, "Chandra Nalaar", 1);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1", playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 19);
assertHandCount(playerA, "Chandra's Phoenix", 1);
}
}

View file

@ -25,7 +25,7 @@
* 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.combat.damage;
package org.mage.test.cards.triggers.damage;
import mage.constants.PhaseStep;
import mage.constants.Zone;

View file

@ -25,7 +25,7 @@
* 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.combat.damage;
package org.mage.test.cards.triggers.damage;
import mage.constants.PhaseStep;
import mage.constants.Zone;

View file

@ -1,4 +1,4 @@
package org.mage.test.cards.triggers.combat.damage;
package org.mage.test.cards.triggers.damage;
import mage.constants.PhaseStep;
import mage.constants.Zone;