* SetPowerToughnessSourceEffect - Set the correct sublayer to use (fixes #1354).

This commit is contained in:
LevelX2 2015-11-04 22:31:35 +01:00
parent af18f95bba
commit 1139495fd7
24 changed files with 238 additions and 121 deletions

View file

@ -40,6 +40,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.common.FilterLandCard;
import mage.game.Game;
@ -100,13 +101,13 @@ class TrenchGorgerEffect extends OneShotEffect {
TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, new FilterLandCard("any number of land cards"));
target.choose(outcome, controller.getId(), controller.getId(), game);
int count = 0;
for (UUID cardId: target.getTargets()) {
for (UUID cardId : target.getTargets()) {
Card card = game.getCard(cardId);
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
count++;
}
controller.shuffleLibrary(game);
game.addEffect(new SetPowerToughnessSourceEffect(count, count, Duration.EndOfGame), source);
game.addEffect(new SetPowerToughnessSourceEffect(count, count, Duration.EndOfGame, SubLayer.SetPT_7b), source);
return true;
}
return false;

View file

@ -43,6 +43,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
@ -83,9 +84,9 @@ class GigantoplasmApplyToPermanent extends ApplyToPermanent {
@Override
public Boolean apply(Game game, Permanent permanent) {
DynamicValue variableMana = new ManacostVariableValue();
Effect effect = new SetPowerToughnessSourceEffect(variableMana, Duration.WhileOnBattlefield);
Effect effect = new SetPowerToughnessSourceEffect(variableMana, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
effect.setText("This creature has base power and toughness X/X");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,effect, new ManaCostsImpl("{X}"));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}"));
permanent.getAbilities().add(ability);
return true;
}
@ -93,11 +94,11 @@ class GigantoplasmApplyToPermanent extends ApplyToPermanent {
@Override
public Boolean apply(Game game, MageObject mageObject) {
DynamicValue variableMana = new ManacostVariableValue();
Effect effect = new SetPowerToughnessSourceEffect(variableMana, Duration.WhileOnBattlefield);
Effect effect = new SetPowerToughnessSourceEffect(variableMana, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
effect.setText("This creature has base power and toughness X/X");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,effect, new ManaCostsImpl("{X}"));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}"));
mageObject.getAbilities().add(ability);
return true;
}
}
}

View file

@ -39,6 +39,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate;
@ -47,14 +48,14 @@ import mage.filter.predicate.mageobject.ColorPredicate;
* @author jeffwadsworth
*/
public class BattlegateMimic extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a spell that's both red and white");
static {
filter.add(new ColorPredicate(ObjectColor.RED));
filter.add(new ColorPredicate(ObjectColor.WHITE));
}
private String rule = "Whenever you cast a spell that's both red and white, {this} has base power and toughness 4/2 and gains first strike until end of turn.";
public BattlegateMimic(UUID ownerId) {
@ -66,10 +67,10 @@ public class BattlegateMimic extends CardImpl {
this.toughness = new MageInt(1);
// Whenever you cast a spell that's both red and white, Battlegate Mimic has base power and toughness 4/2 and gains first strike until end of turn.
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(4, 2, Duration.EndOfTurn), filter, false, rule);
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(4, 2, Duration.EndOfTurn, SubLayer.SetPT_7b), filter, false, rule);
ability.addEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, false, true));
this.addAbility(ability);
}
public BattlegateMimic(final BattlegateMimic card) {

View file

@ -39,18 +39,19 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate;
/**
*
* @author jeffwadsworth
*
*/
public class NightskyMimic extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a spell that's both black and green");
static {
filter.add(new ColorPredicate(ObjectColor.WHITE));
filter.add(new ColorPredicate(ObjectColor.BLACK));
@ -69,7 +70,7 @@ public class NightskyMimic extends CardImpl {
this.toughness = new MageInt(1);
// Whenever you cast a spell that's both white and black, Nightsky Mimic has base power and toughness 4/4 until end of turn and gains flying until end of turn.
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(4, 4, Duration.EndOfTurn), filter, false, rule);
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(4, 4, Duration.EndOfTurn, SubLayer.SetPT_7b), filter, false, rule);
ability.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn, false, true));
this.addAbility(ability);
}

View file

@ -39,23 +39,24 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate;
/**
*
* @author jeffwadsworth
*
*/
public class RiverfallMimic extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a spell that's both blue and red");
static {
filter.add(new ColorPredicate(ObjectColor.BLUE));
filter.add(new ColorPredicate(ObjectColor.RED));
}
private String rule = "Whenever you cast a spell that's both blue and red, {this} has base power and toughness 3/3 until end of turn and can't be blocked this turn.";
public RiverfallMimic(UUID ownerId) {
@ -69,7 +70,7 @@ public class RiverfallMimic extends CardImpl {
this.toughness = new MageInt(1);
// Whenever you cast a spell that's both blue and red, Riverfall Mimic has base power and toughness 3/3 until end of turn and can't be blocked this turn.
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(3, 3, Duration.EndOfTurn), filter, false, rule);
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(3, 3, Duration.EndOfTurn, SubLayer.SetPT_7b), filter, false, rule);
ability.addEffect(new GainAbilitySourceEffect(new CantBeBlockedSourceAbility(), Duration.EndOfTurn, false, true));
this.addAbility(ability);
}

View file

@ -39,18 +39,19 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate;
/**
*
* @author jeffwadsworth
*
*/
public class ShorecrasherMimic extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a spell that's both green and blue");
static {
filter.add(new ColorPredicate(ObjectColor.GREEN));
filter.add(new ColorPredicate(ObjectColor.BLUE));
@ -69,10 +70,10 @@ public class ShorecrasherMimic extends CardImpl {
this.toughness = new MageInt(1);
// Whenever you cast a spell that's both green and blue, Shorecrasher Mimic has base power and toughness 5/3 until end of turn and gains trample until end of turn.
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(5, 3, Duration.EndOfTurn), filter, false, rule);
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(5, 3, Duration.EndOfTurn, SubLayer.SetPT_7b), filter, false, rule);
ability.addEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.EndOfTurn, false, true));
this.addAbility(ability);
}
public ShorecrasherMimic(final ShorecrasherMimic card) {

View file

@ -39,25 +39,26 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate;
/**
*
* @author jeffwadsworth
*
*/
public class WoodlurkerMimic extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a spell that's both black and green");
static {
filter.add(new ColorPredicate(ObjectColor.BLACK));
filter.add(new ColorPredicate(ObjectColor.GREEN));
}
private String rule = "Whenever you cast a spell that's both black and green, {this} has base power and toughness 4/5 until end of turn and gains wither until end of turn.";
public WoodlurkerMimic(UUID ownerId) {
super(ownerId, 130, "Woodlurker Mimic", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{B/G}");
this.expansionSetCode = "EVE";
@ -69,10 +70,10 @@ public class WoodlurkerMimic extends CardImpl {
this.toughness = new MageInt(1);
// Whenever you cast a spell that's both black and green, Woodlurker Mimic has base power and toughness 4/5 until end of turn and gains wither until end of turn.
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(4, 5, Duration.EndOfTurn), filter, false, rule);
Ability ability = new SpellCastControllerTriggeredAbility(new SetPowerToughnessSourceEffect(4, 5, Duration.EndOfTurn, SubLayer.SetPT_7b), filter, false, rule);
ability.addEffect(new GainAbilitySourceEffect(WitherAbility.getInstance(), Duration.EndOfTurn, false, true));
this.addAbility(ability);
}
public WoodlurkerMimic(final WoodlurkerMimic card) {

View file

@ -44,6 +44,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -70,7 +71,7 @@ public class EntropicSpecter extends CardImpl {
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponentEffect(Outcome.Detriment)));
// Entropic Specter's power and toughness are each equal to the number of cards in the chosen player's hand.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new CardsInTargetPlayerHandCount(), Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new CardsInTargetPlayerHandCount(), Duration.WhileOnBattlefield, SubLayer.SetPT_7b)));
// Whenever Entropic Specter deals damage to a player, that player discards a card.
this.addAbility(new DealsDamageToAPlayerTriggeredAbility(new DiscardTargetEffect(1, false), false, true));

View file

@ -43,6 +43,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
@ -151,7 +152,7 @@ class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
game.addEffect(new GainAbilitySourceEffect(DefenderAbility.getInstance(), Duration.Custom), source);
break;
}
game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom), source);
game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b), source);
}
return false;

View file

@ -28,17 +28,19 @@
package mage.sets.iceage;
import java.util.UUID;
import mage.constants.*;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.players.Player;
@ -71,17 +73,13 @@ public class Lhurgoyf extends CardImpl {
}
}
class LhurgoyfEffect extends ContinuousEffectImpl {
public LhurgoyfEffect() {
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature);
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, Outcome.BoostCreature);
staticText = "{this}'s power is equal to the number of creature cards in all graveyards and its toughness is equal to that number plus 1";
}
public LhurgoyfEffect(final LhurgoyfEffect effect) {
super(effect);
}

View file

@ -28,11 +28,6 @@
package mage.sets.innistrad;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -41,6 +36,12 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -94,14 +95,17 @@ class TreeOfRedemptionEffect extends OneShotEffect {
if (perm != null) {
int amount = perm.getToughness().getValue();
int life = player.getLife();
if (life == amount)
if (life == amount) {
return false;
if (life < amount && !player.isCanGainLife())
}
if (life < amount && !player.isCanGainLife()) {
return false;
if (life > amount && !player.isCanLoseLife())
}
if (life > amount && !player.isCanLoseLife()) {
return false;
}
player.setLife(amount, game);
game.addEffect(new SetPowerToughnessSourceEffect(Integer.MIN_VALUE, life, Duration.WhileOnBattlefield), source);
game.addEffect(new SetPowerToughnessSourceEffect(Integer.MIN_VALUE, life, Duration.WhileOnBattlefield, SubLayer.SetPT_7b), source);
return true;
}
}
@ -113,4 +117,4 @@ class TreeOfRedemptionEffect extends OneShotEffect {
return new TreeOfRedemptionEffect(this);
}
}
}

View file

@ -41,6 +41,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -54,6 +55,7 @@ import mage.target.common.TargetControlledPermanent;
public class MarshFlitter extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("a Goblin");
static {
filter.add(new SubtypePredicate("Goblin"));
}
@ -72,7 +74,7 @@ public class MarshFlitter extends CardImpl {
// When Marsh Flitter enters the battlefield, put two 1/1 black Goblin Rogue creature tokens onto the battlefield.
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new GoblinRogueToken(), 2), false));
// Sacrifice a Goblin: Marsh Flitter has base power and toughness 3/3 until end of turn.
Effect effect = new SetPowerToughnessSourceEffect(3, 3, Duration.EndOfTurn);
Effect effect = new SetPowerToughnessSourceEffect(3, 3, Duration.EndOfTurn, SubLayer.SetPT_7b);
effect.setText("{this} has base power and toughness 3/3 until end of turn");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new SacrificeTargetCost(new TargetControlledPermanent(filter)));
this.addAbility(ability);

View file

@ -43,6 +43,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
@ -152,7 +153,7 @@ class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
game.addEffect(new GainAbilitySourceEffect(DefenderAbility.getInstance(), Duration.Custom), source);
break;
}
game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom), source);
game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b), source);
}
return false;

View file

@ -39,6 +39,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -56,14 +57,13 @@ public class ShapeStealer extends CardImpl {
this.subtype.add("Spirit");
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// This ability triggers once for each creature blocked by or blocking Shape Stealer.
// This ability triggers once for each creature blocked by or blocking Shape Stealer.
// If multiple creatures block it, Shape Stealer's power and toughness will change for
// each one in succession. The first trigger put on the stack will be the last to resolve,
// so that will set Shape Stealer's final power and toughness.
// Whenever Shape Stealer blocks or becomes blocked by a creature, change Shape Stealer's base power and toughness to that creature's power and toughness until end of turn.
this.addAbility(new BlocksOrBecomesBlockedByCreatureTriggeredAbility(new ShapeStealerEffect(), false));
this.addAbility(new BlocksOrBecomesBlockedByCreatureTriggeredAbility(new ShapeStealerEffect(), false));
}
public ShapeStealer(final ShapeStealer card) {
@ -77,28 +77,28 @@ public class ShapeStealer extends CardImpl {
}
class ShapeStealerEffect extends OneShotEffect {
public ShapeStealerEffect() {
super(Outcome.Detriment);
this.staticText = "change {this}'s base power and toughness to that creature's power and toughness until end of turn";
}
public ShapeStealerEffect(final ShapeStealerEffect effect) {
super(effect);
}
@Override
public ShapeStealerEffect copy() {
return new ShapeStealerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (permanent != null) {
ContinuousEffect effect = new SetPowerToughnessSourceEffect(permanent.getPower().getValue(), permanent.getToughness().getValue(), Duration.EndOfTurn);
ContinuousEffect effect = new SetPowerToughnessSourceEffect(permanent.getPower().getValue(), permanent.getToughness().getValue(), Duration.EndOfTurn, SubLayer.SetPT_7b);
game.addEffect(effect, source);
return true;
}

View file

@ -44,6 +44,7 @@ import mage.constants.ColoredManaSymbol;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
@ -141,7 +142,7 @@ class DracoplasmEffect extends ReplacementEffectImpl {
toughness += targetCreature.getToughness().getValue();
}
}
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom);
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b);
game.addEffect(effect, source);
}
}

View file

@ -48,6 +48,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.NamePredicate;
@ -100,7 +101,7 @@ class GigantiformAbility extends StaticAbility {
public GigantiformAbility() {
super(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(TrampleAbility.getInstance(), AttachmentType.AURA));
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new SetPowerToughnessSourceEffect(8, 8, Duration.WhileOnBattlefield));
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new SetPowerToughnessSourceEffect(8, 8, Duration.WhileOnBattlefield, SubLayer.SetPT_7b));
this.addEffect(new GainAbilityAttachedEffect(ability, AttachmentType.AURA));
}