Added a test.

This commit is contained in:
LevelX2 2015-09-01 23:54:56 +02:00
parent 774b7bdb0a
commit bb1839f79b
4 changed files with 108 additions and 45 deletions

View file

@ -28,11 +28,6 @@
package mage.sets.eventide; package mage.sets.eventide;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
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.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -42,6 +37,10 @@ import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.LifelinkAbility; import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -57,15 +56,19 @@ public class DivinityOfPride extends CardImpl {
this.subtype.add("Spirit"); this.subtype.add("Spirit");
this.subtype.add("Avatar"); this.subtype.add("Avatar");
this.power = new MageInt(4); this.power = new MageInt(4);
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// Lifelink
this.addAbility(LifelinkAbility.getInstance()); this.addAbility(LifelinkAbility.getInstance());
// Divinity of Pride gets +4/+4 as long as you have 25 or more life.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new ConditionalContinuousEffect(new BoostSourceEffect(4, 4, Duration.WhileOnBattlefield), new ConditionalContinuousEffect(new BoostSourceEffect(4, 4, Duration.WhileOnBattlefield),
new DivinityOfPrideCondition(), new DivinityOfPrideCondition(),
"Divinity of Pride gets +4/+4 as long as you have 25 or more life"))); "{this} gets +4/+4 as long as you have 25 or more life")));
} }
public DivinityOfPride(final DivinityOfPride card) { public DivinityOfPride(final DivinityOfPride card) {

View file

@ -25,17 +25,19 @@
* 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.sets.mirrodinbesieged; package mage.sets.mirrodinbesieged;
import mage.constants.CardType; import java.util.UUID;
import mage.constants.Rarity;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.*; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game; import mage.game.Game;
@ -43,12 +45,11 @@ import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.util.functions.ApplyToPermanent; import mage.util.functions.ApplyToPermanent;
import java.util.UUID;
/** /**
* @author Loki * @author Loki
*/ */
public class Cryptoplasm extends CardImpl { public class Cryptoplasm extends CardImpl {
final static FilterCreaturePermanent filter = new FilterCreaturePermanent(); final static FilterCreaturePermanent filter = new FilterCreaturePermanent();
static { static {
@ -64,7 +65,7 @@ public class Cryptoplasm extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// At the beginning of your upkeep, you may have Cryptoplasm become a copy of another target creature. If you do, Cryptoplasm gains this ability. // At the beginning of your upkeep, you may have Cryptoplasm become a copy of another target creature. If you do, Cryptoplasm gains this ability.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmTransformEffect(), TargetController.YOU, true); Ability ability = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmEffect(), TargetController.YOU, true);
ability.addTarget(new TargetCreaturePermanent(filter)); ability.addTarget(new TargetCreaturePermanent(filter));
this.addAbility(ability); this.addAbility(ability);
} }
@ -80,43 +81,39 @@ public class Cryptoplasm extends CardImpl {
} }
class CryptoplasmTransformEffect extends ContinuousEffectImpl { class CryptoplasmEffect extends OneShotEffect {
CryptoplasmTransformEffect() { public CryptoplasmEffect() {
super(Duration.WhileOnBattlefield, Layer.CopyEffects_1, SubLayer.NA, Outcome.Copy); super(Outcome.Copy);
staticText = "you may have {this} become a copy of another target creature. If you do, {this} gains this ability"; this.staticText = "you may have {this} become a copy of another target creature. If you do, {this} gains this ability";
} }
CryptoplasmTransformEffect(final CryptoplasmTransformEffect effect) { public CryptoplasmEffect(final CryptoplasmEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, final Ability source) { public CryptoplasmEffect copy() {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source)); return new CryptoplasmEffect(this);
Permanent permanent = game.getPermanent(source.getSourceId());
if (creature == null || permanent == null) {
return false;
}
game.copyPermanent(creature, permanent, source, new ApplyToPermanent() {
@Override
public Boolean apply(Game game, Permanent permanent) {
Ability upkeepAbility = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmTransformEffect(), TargetController.YOU, true);
upkeepAbility.addTarget(new TargetCreaturePermanent());
permanent.addAbility(upkeepAbility, source.getSourceId(), game);
return true;
}
});
return true;
} }
@Override @Override
public CryptoplasmTransformEffect copy() { public boolean apply(Game game, final Ability source) {
return new CryptoplasmTransformEffect(this); Permanent creatureToCopy = game.getPermanent(getTargetPointer().getFirst(game, source));
} if (creatureToCopy != null) {
CopyEffect effect = new CopyEffect(creatureToCopy, source.getSourceId());
effect.setApplier(new ApplyToPermanent() {
@Override
public Boolean apply(Game game, Permanent permanent) {
Ability upkeepAbility = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmEffect(), TargetController.YOU, true);
upkeepAbility.addTarget(new TargetCreaturePermanent());
permanent.addAbility(upkeepAbility, source.getSourceId(), game);
return true;
}
});
game.addEffect(effect, source);
}
return true;
}
} }

View file

@ -52,6 +52,10 @@ public class CastCreaturesTest extends CardTestPlayerBaseAI {
assertPermanentCount(playerA, "Silvercoat Lion", 1); assertPermanentCount(playerA, "Silvercoat Lion", 1);
} }
/**
* This test fails sometimes, probably because two plains are tapped for the
* first creature
*/
@Test @Test
public void testSimpleCast2() { public void testSimpleCast2() {
addCard(Zone.HAND, playerA, "Silvercoat Lion"); addCard(Zone.HAND, playerA, "Silvercoat Lion");

View file

@ -55,4 +55,63 @@ public class CryptoplasmTest extends CardTestPlayerBase {
assertPermanentCount(playerB, "Cryptoplasm", 0); assertPermanentCount(playerB, "Cryptoplasm", 0);
assertPermanentCount(playerB, "Sigiled Paladin", 2); assertPermanentCount(playerB, "Sigiled Paladin", 2);
} }
/**
* I'm at 8 life, opponent (AI) is at 21. I have a Cryptoplasm currently
* copying my opponent's Divinity of Pride, the Crypto also has my Followed
* Footsteps attached to it. Additionally, I have another Cryptoplasm on the
* battlefield also copying the same Divinity, and a Clever Impersonator
* that ETB copying the first Cryptoplasm and is currently also a copy of
* the Divinity.
*
* Opponent attacks with his only Divinity of Pride (4/4) and a Serra
* Avenger (3/3). I block the Divinity with two of my Divinity copies (the
* Clever Impersonator and unenchanted Cryptoplasm) and the Avenger with the
* enchanted Divinity (originally a Cryptoplasm). My opponent's Divinity
* kills my two copies and dies, and then his Avenger dies and kills the
* Divinity blocking it, also sending my Followed Footsteps down with it.
*
* How does any of that add up? Not only should his Divinity only kill one
* of mine since it was a 4/4 and only becomes an 8/8 after dealing its
* damage (at which point it should be too late to go back and say the 4
* damage are now 8, since it was that exact damage that put him at 25
* life), but even more confusing is how the Serra Avenger, which is a 3/3,
* somehow kills my 4/4 that had suffered no other damage that turn.
*
* No other permanents in play at that moment had any influence in this
* either, they were only basic lands and a couple of creatures with no
* relevant abilities.
*
* I won't put aside me completely missing something here, but I really
* can't see any other explanation to this other than a game bug.
*/
@Test
public void testDamageLifelink() {
setLife(playerA, 21);
setLife(playerB, 8);
// First strike
// Exalted (Whenever a creature you control attacks alone, that creature gets +1/+1 until end of turn.)
addCard(Zone.BATTLEFIELD, playerA, "Divinity of Pride", 1); // {W}{W}
addCard(Zone.BATTLEFIELD, playerB, "Island", 5);
// At the beginning of your upkeep, you may have Cryptoplasm become a copy of another target creature. If you do, Cryptoplasm gains this ability.
addCard(Zone.BATTLEFIELD, playerB, "Cryptoplasm", 2); // {1}{U}{U}
addTarget(playerB, "Divinity of Pride");
addTarget(playerB, "Divinity of Pride");
attack(3, playerA, "Divinity of Pride");
block(3, playerB, "Divinity of Pride", "Divinity of Pride");
block(3, playerB, "Divinity of Pride", "Divinity of Pride");
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertPermanentCount(playerB, "Cryptoplasm", 0);
assertPermanentCount(playerA, "Divinity of Pride", 0);
assertPermanentCount(playerB, "Divinity of Pride", 1);
assertLife(playerB, 16);
assertLife(playerA, 25);
}
} }