* 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

@ -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;
}