mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
Fix for Lazav, Dimir Mastermind. Added two additional tests for Lazav.
This commit is contained in:
parent
9bda45ae29
commit
0edc794c6a
2 changed files with 114 additions and 24 deletions
|
@ -27,10 +27,10 @@
|
|||
*/
|
||||
package mage.sets.gatecrash;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
|
@ -38,6 +38,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.HexproofAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -107,9 +108,8 @@ class CreatureCardPutOpponentGraveyardTriggeredAbility extends TriggeredAbilityI
|
|||
}
|
||||
if (game.getOpponents(controllerId).contains(event.getPlayerId())
|
||||
&& card.getCardType().contains(CardType.CREATURE)) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
}
|
||||
// store the card id to copy
|
||||
game.getState().setValue(new StringBuilder("CardToCopy").append(getSourceId().toString()).toString(), card.getId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -124,12 +124,17 @@ class CreatureCardPutOpponentGraveyardTriggeredAbility extends TriggeredAbilityI
|
|||
|
||||
class LazavDimirEffect extends ContinuousEffectImpl<LazavDimirEffect> {
|
||||
|
||||
protected UUID IdOfCopiedCard;
|
||||
protected Card cardToCopy;
|
||||
|
||||
public LazavDimirEffect() {
|
||||
super(Constants.Duration.WhileOnBattlefield, Constants.Layer.CopyEffects_1, Constants.SubLayer.NA, Constants.Outcome.BecomeCreature);
|
||||
}
|
||||
|
||||
public LazavDimirEffect(final LazavDimirEffect effect) {
|
||||
super(effect);
|
||||
this.cardToCopy = effect.cardToCopy;
|
||||
this.IdOfCopiedCard = effect.IdOfCopiedCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,47 +144,53 @@ class LazavDimirEffect extends ContinuousEffectImpl<LazavDimirEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(targetPointer.getFirst(game, source));
|
||||
Object object = game.getState().getValue(new StringBuilder("CardToCopy").append(source.getSourceId().toString()).toString());
|
||||
Card card = null;
|
||||
if (object instanceof UUID) {
|
||||
card = game.getCard((UUID) object);
|
||||
}
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (card == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
permanent.getPower().setValue(card.getPower().getValue());
|
||||
permanent.getToughness().setValue(card.getToughness().getValue());
|
||||
permanent.getColor().setColor(card.getColor());
|
||||
if (IdOfCopiedCard == null || !IdOfCopiedCard.equals((UUID) object)) {
|
||||
IdOfCopiedCard = (UUID) object;
|
||||
cardToCopy = card.copy();
|
||||
cardToCopy.assignNewId();
|
||||
}
|
||||
permanent.getPower().setValue(cardToCopy.getPower().getValue());
|
||||
permanent.getToughness().setValue(cardToCopy.getToughness().getValue());
|
||||
permanent.getColor().setColor(cardToCopy.getColor());
|
||||
permanent.getManaCost().clear();
|
||||
permanent.getManaCost().add(card.getManaCost());
|
||||
permanent.getManaCost().add(cardToCopy.getManaCost());
|
||||
permanent.getCardType().clear();
|
||||
for (CardType type : card.getCardType()) {
|
||||
for (CardType type : cardToCopy.getCardType()) {
|
||||
if (!permanent.getCardType().contains(type)) {
|
||||
permanent.getCardType().add(type);
|
||||
}
|
||||
}
|
||||
permanent.getSubtype().clear();
|
||||
for (String type : card.getSubtype()) {
|
||||
for (String type : cardToCopy.getSubtype()) {
|
||||
if (!permanent.getSubtype().contains(type)) {
|
||||
permanent.getSubtype().add(type);
|
||||
}
|
||||
}
|
||||
permanent.getSupertype().clear();
|
||||
permanent.getSupertype().add("Legendary");
|
||||
for (String type : card.getSupertype()) {
|
||||
for (String type : cardToCopy.getSupertype()) {
|
||||
if (!permanent.getSupertype().contains(type)) {
|
||||
permanent.getSupertype().add(type);
|
||||
}
|
||||
}
|
||||
permanent.setExpansionSetCode(card.getExpansionSetCode());
|
||||
for (Iterator<Ability> it = permanent.getAbilities().iterator();it.hasNext();) {
|
||||
Ability ability = it.next();
|
||||
if (!(ability instanceof HexproofAbility) && !(ability instanceof CreatureCardPutOpponentGraveyardTriggeredAbility)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
permanent.addAbility(HexproofAbility.getInstance(), source.getSourceId(), game);
|
||||
permanent.addAbility(new CreatureCardPutOpponentGraveyardTriggeredAbility(), source.getSourceId(), game);
|
||||
|
||||
for (Ability ability : cardToCopy.getAbilities()) {
|
||||
if (!permanent.getAbilities().contains(ability)) {
|
||||
permanent.addAbility(ability, source.getId(), game);
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,16 @@ import org.junit.Test;
|
|||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* Lazav, Dimir Mastermind
|
||||
*
|
||||
* Legendary Creature — Shapeshifter 3/3, UUBB
|
||||
* Hexproof
|
||||
* Whenever a creature card is put into an opponent's graveyard from anywhere, you may have
|
||||
* Lazav, Dimir Mastermind become a copy of that card except its name is still
|
||||
* Lazav, Dimir Mastermind, it's legendary in addition to its other types, and
|
||||
* it gains hexproof and this ability.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class LazavDimirMastermindTest extends CardTestPlayerBase {
|
||||
|
@ -23,7 +33,7 @@ public class LazavDimirMastermindTest extends CardTestPlayerBase {
|
|||
|
||||
addCard(Constants.Zone.LIBRARY, playerB, "Assault Griffin",5);
|
||||
skipInitShuffling();
|
||||
|
||||
|
||||
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Target player puts the top card of his or her library into his or her graveyard.", playerB);
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.END_TURN);
|
||||
|
@ -38,7 +48,7 @@ public class LazavDimirMastermindTest extends CardTestPlayerBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests copy simple creature
|
||||
* Tests copy card with static abilitiy gaining ability to other permanents
|
||||
*/
|
||||
@Test
|
||||
public void testRatsHaveDeathtouch() {
|
||||
|
@ -66,4 +76,73 @@ public class LazavDimirMastermindTest extends CardTestPlayerBase {
|
|||
Assert.assertTrue("Gutter Skulk should have deathtouch but hasn't", gutterSkulk.getAbilities().contains(DeathtouchAbility.getInstance()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests copy Nightveil Specter
|
||||
*
|
||||
* Nightveil Specter
|
||||
* Creature — Specter 2/3, {U/B}{U/B}{U/B}
|
||||
* Flying
|
||||
* Whenever Nightveil Specter deals combat damage to a player, that player exiles the top card of his or her library.
|
||||
* You may play cards exiled with Nightveil Specter.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testCopyNightveilSpecter() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains", 2);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Lazav, Dimir Mastermind", 1);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Codex Shredder", 1);
|
||||
|
||||
addCard(Constants.Zone.LIBRARY, playerB, "Silvercoat Lion",2);
|
||||
addCard(Constants.Zone.LIBRARY, playerB, "Nightveil Specter",1);
|
||||
skipInitShuffling();
|
||||
|
||||
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Target player puts the top card of his or her library into his or her graveyard.", playerB);
|
||||
|
||||
attack(3, playerA, "Lazav, Dimir Mastermind");
|
||||
|
||||
castSpell(3, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Silvercoat Lion");
|
||||
|
||||
setStopAt(3, Constants.PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Lazav, Dimir Mastermind", 1);
|
||||
assertPowerToughness(playerA, "Lazav, Dimir Mastermind", 2, 3);
|
||||
|
||||
Permanent lazav = getPermanent("Lazav, Dimir Mastermind", playerA.getId());
|
||||
Assert.assertTrue(lazav.getAbilities().contains(FlyingAbility.getInstance()));
|
||||
Assert.assertTrue(lazav.getSubtype().contains("Specter"));
|
||||
Assert.assertTrue(lazav.getSupertype().contains("Legendary"));
|
||||
|
||||
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||
assertPowerToughness(playerA, "Silvercoat Lion", 2, 2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyMultipleTimes() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Lazav, Dimir Mastermind", 1);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Codex Shredder", 1);
|
||||
|
||||
addCard(Constants.Zone.LIBRARY, playerB, "Silvercoat Lion",2);
|
||||
addCard(Constants.Zone.LIBRARY, playerB, "Nightveil Specter",1);
|
||||
skipInitShuffling();
|
||||
|
||||
// Lazav becomes a Nightveil Specter
|
||||
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Target player puts the top card of his or her library into his or her graveyard.", playerB);
|
||||
|
||||
// Lazav becomes a Silvercoat Lion
|
||||
activateAbility(3, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Target player puts the top card of his or her library into his or her graveyard.", playerB);
|
||||
|
||||
setStopAt(3, Constants.PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Lazav, Dimir Mastermind", 1);
|
||||
assertPowerToughness(playerA, "Lazav, Dimir Mastermind", 2, 2);
|
||||
|
||||
Permanent lazav = getPermanent("Lazav, Dimir Mastermind", playerA.getId());
|
||||
Assert.assertTrue(lazav.getSubtype().contains("Cat"));
|
||||
Assert.assertTrue(lazav.getSupertype().contains("Legendary"));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue