* 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.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterLandCard; import mage.filter.common.FilterLandCard;
import mage.game.Game; import mage.game.Game;
@ -106,7 +107,7 @@ class TrenchGorgerEffect extends OneShotEffect {
count++; count++;
} }
controller.shuffleLibrary(game); 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 true;
} }
return false; return false;

View file

@ -43,6 +43,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game; import mage.game.Game;
@ -83,7 +84,7 @@ class GigantoplasmApplyToPermanent extends ApplyToPermanent {
@Override @Override
public Boolean apply(Game game, Permanent permanent) { public Boolean apply(Game game, Permanent permanent) {
DynamicValue variableMana = new ManacostVariableValue(); 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"); 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); permanent.getAbilities().add(ability);
@ -93,7 +94,7 @@ class GigantoplasmApplyToPermanent extends ApplyToPermanent {
@Override @Override
public Boolean apply(Game game, MageObject mageObject) { public Boolean apply(Game game, MageObject mageObject) {
DynamicValue variableMana = new ManacostVariableValue(); 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"); 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); mageObject.getAbilities().add(ability);

View file

@ -39,6 +39,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -66,7 +67,7 @@ public class BattlegateMimic extends CardImpl {
this.toughness = new MageInt(1); 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. // 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)); ability.addEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, false, true));
this.addAbility(ability); this.addAbility(ability);

View file

@ -39,13 +39,14 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
*
*/ */
public class NightskyMimic extends CardImpl { public class NightskyMimic extends CardImpl {
@ -69,7 +70,7 @@ public class NightskyMimic extends CardImpl {
this.toughness = new MageInt(1); 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. // 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)); ability.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn, false, true));
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -39,13 +39,14 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
*
*/ */
public class RiverfallMimic extends CardImpl { public class RiverfallMimic extends CardImpl {
@ -69,7 +70,7 @@ public class RiverfallMimic extends CardImpl {
this.toughness = new MageInt(1); 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. // 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)); ability.addEffect(new GainAbilitySourceEffect(new CantBeBlockedSourceAbility(), Duration.EndOfTurn, false, true));
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -39,13 +39,14 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
*
*/ */
public class ShorecrasherMimic extends CardImpl { public class ShorecrasherMimic extends CardImpl {
@ -69,7 +70,7 @@ public class ShorecrasherMimic extends CardImpl {
this.toughness = new MageInt(1); 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. // 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)); ability.addEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.EndOfTurn, false, true));
this.addAbility(ability); this.addAbility(ability);

View file

@ -39,13 +39,14 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
*
*/ */
public class WoodlurkerMimic extends CardImpl { public class WoodlurkerMimic extends CardImpl {
@ -69,7 +70,7 @@ public class WoodlurkerMimic extends CardImpl {
this.toughness = new MageInt(1); 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. // 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)); ability.addEffect(new GainAbilitySourceEffect(WitherAbility.getInstance(), Duration.EndOfTurn, false, true));
this.addAbility(ability); this.addAbility(ability);

View file

@ -44,6 +44,7 @@ import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -70,7 +71,7 @@ public class EntropicSpecter extends CardImpl {
this.addAbility(new AsEntersBattlefieldAbility(new ChooseOpponentEffect(Outcome.Detriment))); 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. // 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. // Whenever Entropic Specter deals damage to a player, that player discards a card.
this.addAbility(new DealsDamageToAPlayerTriggeredAbility(new DiscardTargetEffect(1, false), false, true)); 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.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.EntersTheBattlefieldEvent;
@ -151,7 +152,7 @@ class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
game.addEffect(new GainAbilitySourceEffect(DefenderAbility.getInstance(), Duration.Custom), source); game.addEffect(new GainAbilitySourceEffect(DefenderAbility.getInstance(), Duration.Custom), source);
break; break;
} }
game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom), source); game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b), source);
} }
return false; return false;

View file

@ -28,17 +28,19 @@
package mage.sets.iceage; package mage.sets.iceage;
import java.util.UUID; import java.util.UUID;
import mage.constants.*;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; 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.ContinuousEffectImpl;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.cards.CardImpl; 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.filter.common.FilterCreatureCard;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -71,17 +73,13 @@ public class Lhurgoyf extends CardImpl {
} }
} }
class LhurgoyfEffect extends ContinuousEffectImpl { class LhurgoyfEffect extends ContinuousEffectImpl {
public LhurgoyfEffect() { 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"; 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) { public LhurgoyfEffect(final LhurgoyfEffect effect) {
super(effect); super(effect);
} }

View file

@ -28,11 +28,6 @@
package mage.sets.innistrad; package mage.sets.innistrad;
import java.util.UUID; 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.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -41,6 +36,12 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect; import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.abilities.keyword.DefenderAbility; import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl; 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.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -94,14 +95,17 @@ class TreeOfRedemptionEffect extends OneShotEffect {
if (perm != null) { if (perm != null) {
int amount = perm.getToughness().getValue(); int amount = perm.getToughness().getValue();
int life = player.getLife(); int life = player.getLife();
if (life == amount) if (life == amount) {
return false; return false;
if (life < amount && !player.isCanGainLife()) }
if (life < amount && !player.isCanGainLife()) {
return false; return false;
if (life > amount && !player.isCanLoseLife()) }
if (life > amount && !player.isCanLoseLife()) {
return false; return false;
}
player.setLife(amount, game); 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; return true;
} }
} }

View file

@ -41,6 +41,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
@ -54,6 +55,7 @@ import mage.target.common.TargetControlledPermanent;
public class MarshFlitter extends CardImpl { public class MarshFlitter extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("a Goblin"); private static final FilterControlledPermanent filter = new FilterControlledPermanent("a Goblin");
static { static {
filter.add(new SubtypePredicate("Goblin")); 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. // 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)); 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. // 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"); 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))); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new SacrificeTargetCost(new TargetControlledPermanent(filter)));
this.addAbility(ability); this.addAbility(ability);

View file

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

View file

@ -39,6 +39,7 @@ import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -61,7 +62,6 @@ public class ShapeStealer extends CardImpl {
// If multiple creatures block it, Shape Stealer's power and toughness will change for // 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, // 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. // 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. // 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));
} }
@ -98,7 +98,7 @@ class ShapeStealerEffect extends OneShotEffect {
if (controller != null) { if (controller != null) {
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (permanent != null) { 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); game.addEffect(effect, source);
return true; return true;
} }

View file

@ -44,6 +44,7 @@ import mage.constants.ColoredManaSymbol;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AnotherPredicate;
@ -141,7 +142,7 @@ class DracoplasmEffect extends ReplacementEffectImpl {
toughness += targetCreature.getToughness().getValue(); 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); game.addEffect(effect, source);
} }
} }

View file

@ -48,6 +48,7 @@ import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.NamePredicate; import mage.filter.predicate.mageobject.NamePredicate;
@ -100,7 +101,7 @@ class GigantiformAbility extends StaticAbility {
public GigantiformAbility() { public GigantiformAbility() {
super(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(TrampleAbility.getInstance(), AttachmentType.AURA)); 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)); this.addEffect(new GainAbilityAttachedEffect(ability, AttachmentType.AURA));
} }

View file

@ -0,0 +1,63 @@
/*
* 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.replacement;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class HumilityTest extends CardTestPlayerBase {
/**
* During a commander game both were on the battlefield, and Masumaro's P/T
* was not displaying as 1/1.
*/
@Test
public void testHumilityAndMasumaro() {
// Masumaro, First to Live's power and toughness are each equal to twice the number of cards in your hand.
addCard(Zone.BATTLEFIELD, playerB, "Masumaro, First to Live");
// Enchantment {2}{W}{W}
// All creatures lose all abilities and are 1/1.
addCard(Zone.BATTLEFIELD, playerA, "Humility");
addCard(Zone.HAND, playerB, "Plains", 3);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPowerToughness(playerB, "Masumaro, First to Live", 1, 1);
}
}

View file

@ -865,6 +865,24 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertEquals("(Graveyard " + player.getName() + ") Card counts are not equal (" + cardName + ")", count, actualCount); Assert.assertEquals("(Graveyard " + player.getName() + ") Card counts are not equal (" + cardName + ")", count, actualCount);
} }
/**
* Assert card count in player's library.
*
* @param player {@link Player} who's library should be counted.
* @param cardName Name of the cards that should be counted.
* @param count Expected count.
*/
public void assertLibraryCount(Player player, String cardName, int count) throws AssertionError {
int actualCount = 0;
for (Card card : player.getLibrary().getCards(currentGame)) {
if (card.getName().equals(cardName)) {
actualCount++;
}
}
Assert.assertEquals("(Library " + player.getName() + ") Card counts are not equal (" + cardName + ")", count, actualCount);
}
/** /**
* Asserts added actions count. Usefull to make sure that all actions were * Asserts added actions count. Usefull to make sure that all actions were
* executed. * executed.

View file

@ -7,6 +7,7 @@ import mage.constants.Zone;
* @author Loki * @author Loki
*/ */
public class PutIntoGraveFromAnywhereSourceTriggeredAbility extends ZoneChangeTriggeredAbility { public class PutIntoGraveFromAnywhereSourceTriggeredAbility extends ZoneChangeTriggeredAbility {
public PutIntoGraveFromAnywhereSourceTriggeredAbility(Effect effect, boolean optional) { public PutIntoGraveFromAnywhereSourceTriggeredAbility(Effect effect, boolean optional) {
super(Zone.GRAVEYARD, effect, "When {this} is put into a graveyard from anywhere, ", optional); super(Zone.GRAVEYARD, effect, "When {this} is put into a graveyard from anywhere, ", optional);
} }

View file

@ -48,13 +48,21 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl {
private int toughness; private int toughness;
public SetPowerToughnessSourceEffect(DynamicValue amount, Duration duration) { public SetPowerToughnessSourceEffect(DynamicValue amount, Duration duration) {
super(duration, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature); this(amount, duration, SubLayer.CharacteristicDefining_7a);
}
public SetPowerToughnessSourceEffect(DynamicValue amount, Duration duration, SubLayer subLayer) {
super(duration, Layer.PTChangingEffects_7, subLayer, Outcome.BoostCreature);
this.amount = amount; this.amount = amount;
staticText = "{this}'s power and toughness are each equal to the number of " + amount.getMessage(); staticText = "{this}'s power and toughness are each equal to the number of " + amount.getMessage();
} }
public SetPowerToughnessSourceEffect(int power, int toughness, Duration duration) { public SetPowerToughnessSourceEffect(int power, int toughness, Duration duration) {
super(duration, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature); this(power, toughness, duration, SubLayer.CharacteristicDefining_7a);
}
public SetPowerToughnessSourceEffect(int power, int toughness, Duration duration, SubLayer subLayer) {
super(duration, Layer.PTChangingEffects_7, subLayer, Outcome.BoostCreature);
this.power = power; this.power = power;
this.toughness = toughness; this.toughness = toughness;
staticText = "{this}'s power and toughness is " + power + "/" + toughness + " " + duration.toString(); staticText = "{this}'s power and toughness is " + power + "/" + toughness + " " + duration.toString();

View file

@ -25,10 +25,10 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.abilities.keyword; package mage.abilities.keyword;
import mage.constants.Zone; import java.util.ArrayList;
import java.util.List;
import mage.abilities.Abilities; import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl; import mage.abilities.AbilitiesImpl;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -39,18 +39,17 @@ import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect; import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.cards.Card;
import mage.cards.LevelerCard;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import java.util.ArrayList;
import java.util.List;
/** /**
* The implementation by BetaSteward was discarded as requires special handling in Mage.Core. * The implementation by BetaSteward was discarded as requires special handling
* in Mage.Core.
* *
* Instead it was replaced by conditional continuous effects and builder pattern. * Instead it was replaced by conditional continuous effects and builder
* pattern.
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
* @author noxx * @author noxx
@ -82,7 +81,7 @@ public class LevelerCardBuilder {
constructed.add(staticAbility); constructed.add(staticAbility);
} }
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.WhileOnBattlefield); ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
ConditionalContinuousEffect ptEffect = new ConditionalContinuousEffect(effect, condition, rule); ConditionalContinuousEffect ptEffect = new ConditionalContinuousEffect(effect, condition, rule);
constructed.add(new SimpleStaticAbility(Zone.BATTLEFIELD, ptEffect)); constructed.add(new SimpleStaticAbility(Zone.BATTLEFIELD, ptEffect));
@ -212,8 +211,7 @@ public class LevelerCardBuilder {
sb.append("<b>Level ").append(level1); sb.append("<b>Level ").append(level1);
if (level2 == -1) { if (level2 == -1) {
sb.append("+"); sb.append("+");
} } else {
else {
sb.append("-").append(level2); sb.append("-").append(level2);
} }
sb.append(":</b> ").append(power).append("/").append(toughness).append(" "); sb.append(":</b> ").append(power).append("/").append(toughness).append(" ");

View file

@ -328,8 +328,13 @@ public class Spell extends StackObjImpl implements Card {
@Override @Override
public void counter(UUID sourceId, Game game) { public void counter(UUID sourceId, Game game) {
this.counter(sourceId, game, true);
}
@Override
public void counter(UUID sourceId, Game game, boolean moveToGraveyard) {
this.countered = true; this.countered = true;
if (!isCopiedSpell()) { if (!isCopiedSpell() && moveToGraveyard) {
Player player = game.getPlayer(getControllerId()); Player player = game.getPlayer(getControllerId());
if (player != null) { if (player != null) {
Ability counteringAbility = null; Ability counteringAbility = null;
@ -337,7 +342,7 @@ public class Spell extends StackObjImpl implements Card {
if (counteringObject instanceof StackObject) { if (counteringObject instanceof StackObject) {
counteringAbility = ((StackObject) counteringObject).getStackAbility(); counteringAbility = ((StackObject) counteringObject).getStackAbility();
} }
player.moveCards(card, Zone.STACK, Zone.GRAVEYARD, counteringAbility, game); player.moveCards(card, Zone.GRAVEYARD, counteringAbility, game);
} }
} }
} }
@ -662,12 +667,8 @@ public class Spell extends StackObjImpl implements Card {
if (this.isCopiedSpell() && !zone.equals(Zone.STACK)) { if (this.isCopiedSpell() && !zone.equals(Zone.STACK)) {
return true; return true;
} }
Card card = game.getCard(getSourceId());
if (card != null) {
return card.moveToZone(zone, sourceId, game, flag, appliedEffects); return card.moveToZone(zone, sourceId, game, flag, appliedEffects);
} }
throw new UnsupportedOperationException("Unsupported operation");
}
@Override @Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game) { public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game) {

View file

@ -122,6 +122,11 @@ public class StackAbility extends StackObjImpl implements Ability {
@Override @Override
public void counter(UUID sourceId, Game game) { public void counter(UUID sourceId, Game game) {
this.counter(sourceId, game, true);
}
@Override
public void counter(UUID sourceId, Game game, boolean moveToGraveyard) {
//20100716 - 603.8 //20100716 - 603.8
if (ability instanceof StateTriggeredAbility) { if (ability instanceof StateTriggeredAbility) {
((StateTriggeredAbility) ability).counter(game); ((StateTriggeredAbility) ability).counter(game);

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.game.stack; package mage.game.stack;
import java.util.UUID; import java.util.UUID;
@ -38,11 +37,19 @@ import mage.game.Game;
public interface StackObject extends MageObject, Controllable { public interface StackObject extends MageObject, Controllable {
boolean resolve(Game game); boolean resolve(Game game);
UUID getSourceId(); UUID getSourceId();
void counter(UUID sourceId, Game game); void counter(UUID sourceId, Game game);
void counter(UUID sourceId, Game game, boolean moveToGraveyard);
Ability getStackAbility(); Ability getStackAbility();
int getConvertedManaCost(); int getConvertedManaCost();
boolean chooseNewTargets(Game game, UUID playerId, boolean forceChange, boolean onlyOneTarget, FilterPermanent filterNewTarget); boolean chooseNewTargets(Game game, UUID playerId, boolean forceChange, boolean onlyOneTarget, FilterPermanent filterNewTarget);
@Override @Override
StackObject copy(); StackObject copy();
} }