* P/T defining static abilities - Fixed that the P/T is also set for the card if it's not a permanent (e.g. fixes that targeting a Nighmare with Margue Burst did always no damage).

This commit is contained in:
LevelX2 2014-05-14 16:17:29 +02:00
parent d89970afde
commit ce01d8cf25
9 changed files with 92 additions and 21 deletions

View file

@ -61,7 +61,7 @@ public class MorgueBurst extends CardImpl<MorgueBurst> {
// Return target creature card from your graveyard to your hand. Morgue Burst deals damage to target creature or player equal to the power of the card returned this way.
this.getSpellAbility().addEffect(new MorgueBurstEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard")));
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer(true));
}
public MorgueBurst(final MorgueBurst card) {
@ -95,7 +95,7 @@ class MorgueBurstEffect extends OneShotEffect<MorgueBurstEffect> {
if (card != null) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.HAND);
int damage = card.getPower().getValue();
Permanent creature = game.getPermanent(source.getTargets().get(1).getTargets().get(0));
if (creature != null) {

View file

@ -116,7 +116,7 @@ class GutterGrimeTriggeredAbility extends TriggeredAbilityImpl<GutterGrimeTrigge
@Override
public String getRule() {
return "Whenever a nontoken creature you control dies, put a slime counter on Gutter Grime, then put a green Ooze creature token onto the battlefield with \"This creature's power and toughness are each equal to the number of slime counters on Gutter Grime.\"";
return "Whenever a nontoken creature you control dies, put a slime counter on {this}, then put a green Ooze creature token onto the battlefield with \"This creature's power and toughness are each equal to the number of slime counters on {this}.\"";
}
}
@ -160,7 +160,7 @@ class GutterGrimeToken extends Token {
class GutterGrimeCounters implements DynamicValue {
private UUID sourceId;
private final UUID sourceId;
public GutterGrimeCounters(UUID sourceId) {
this.sourceId = sourceId;

View file

@ -78,7 +78,7 @@ public class DauntlessDourbark extends CardImpl<DauntlessDourbark> {
// Dauntless Dourbark's power and toughness are each equal to the number of Forests you control plus the number of Treefolk you control.
DynamicValue amount = new PermanentsOnBattlefieldCount(filter);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SetPowerToughnessSourceEffect(amount, Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(amount, Duration.EndOfGame)));
// Dauntless Dourbark has trample as long as you control another Treefolk.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinousEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.WhileOnBattlefield), new ControlsPermanentCondition(filter2), rule)));

View file

@ -68,7 +68,7 @@ public class Cantivore extends CardImpl<Cantivore> {
this.addAbility(VigilanceAbility.getInstance());
// Cantivore's power and toughness are each equal to the number of enchantment cards in all graveyards.
DynamicValue value = (new CardsInAllGraveyardsCount(filter));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(value , Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(value , Duration.EndOfGame)));
}
public Cantivore(final Cantivore card) {

View file

@ -67,7 +67,7 @@ public class Cognivore extends CardImpl<Cognivore> {
this.addAbility(FlyingAbility.getInstance());
// Cognivore's power and toughness are each equal to the number of instant cards in all graveyards.
DynamicValue value = (new CardsInAllGraveyardsCount(filter));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(value, Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(value, Duration.EndOfGame)));
}
public Cognivore(final Cognivore card) {

View file

@ -62,7 +62,7 @@ public class SoullessOne extends CardImpl<SoullessOne> {
this.toughness = new MageInt(0);
// Soulless One's power and toughness are each equal to the number of Zombies on the battlefield plus the number of Zombie cards in all graveyards.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SetPowerToughnessSourceEffect(new SoullessOneDynamicCount(), Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new SoullessOneDynamicCount(), Duration.EndOfGame)));
}
public SoullessOne(final SoullessOne card) {

View file

@ -60,7 +60,11 @@ public class ChimericMass extends CardImpl<ChimericMass> {
public ChimericMass(UUID ownerId) {
super(ownerId, 141, "Chimeric Mass", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{X}");
this.expansionSetCode = "SOM";
// Chimeric Mass enters the battlefield with X charge counters on it.
this.addAbility(new EntersBattlefieldAbility(new ChimericMassEffect(), "{this} enters the battlefield with X charge counters on it"));
// {1}: Until end of turn, Chimeric Mass becomes a Construct artifact creature with "This creature's power and toughness are each equal to the number of charge counters on it."
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new ChimericMassToken(), "", Duration.EndOfTurn), new GenericManaCost(1)));
}

View file

@ -0,0 +1,48 @@
/*
* 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.single;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
/*
Morgue Burst {4}{B}{R}
Sorcery
Return target creature card from your graveyard to your hand. Morgue Burst deals damage to target creature or player equal to the power of the card returned this way.
*/
public class MorgueBurstTest extends CardTestPlayerBase {
// Character defining static abilities (defining P/T of Nightmare) work in all zones
@Test
public void testNightmare() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addCard(Zone.HAND, playerA, "Morgue Burst");
addCard(Zone.GRAVEYARD, playerA, "Nightmare");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Morgue Burst", "Nightmare^targetPlayer=PlayerB");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 20);
assertLife(playerB, 16);
assertGraveyardCount(playerA, "Morgue Burst", 1);
assertHandCount(playerA, 1);
}
}

View file

@ -35,6 +35,7 @@ import mage.constants.SubLayer;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.Card;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -75,24 +76,42 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl<SetPower
@Override
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getSourceId());
if (target != null) {
if (amount != null) {
int value = amount.calculate(game, source);
target.getPower().setValue(value);
target.getToughness().setValue(value);
return true;
Card targetCard = game.getCard(source.getSourceId()); // there are character definig abilities (e.g. P/T Nightmare) that have to work also for P/T of cards
Permanent targetPermanent = game.getPermanent(source.getSourceId());
if (targetCard == null && targetPermanent == null) {
return false;
}
if (amount != null) {
int value = amount.calculate(game, source);
if (targetPermanent != null) {
targetPermanent.getPower().setValue(value);
targetPermanent.getToughness().setValue(value);
} else if (targetCard != null) {
targetCard.getPower().setValue(value);
targetCard.getToughness().setValue(value);
}
else {
if (power != Integer.MIN_VALUE) {
target.getPower().setValue(power);
return true;
}
else {
if (power != Integer.MIN_VALUE) {
if (targetCard != null) {
targetCard.getPower().setValue(power);
}
if (toughness != Integer.MIN_VALUE) {
target.getToughness().setValue(toughness);
if (targetPermanent != null) {
targetPermanent.getPower().setValue(power);
}
}
if (toughness != Integer.MIN_VALUE) {
if (targetCard != null) {
targetCard.getToughness().setValue(toughness);
}
if (targetPermanent != null) {
targetPermanent.getToughness().setValue(toughness);
}
}
}
return false;
return true;
}
}