* Mogg Infestation - Fixed a problem with counting also commanders noz gong to graveyard.

This commit is contained in:
LevelX2 2017-05-16 17:40:43 +02:00
parent 351095a904
commit 0185bcb37e
4 changed files with 52 additions and 18 deletions

View file

@ -36,6 +36,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorPredicate;
@ -50,7 +51,7 @@ import mage.players.Player;
public class Hellfire extends CardImpl {
public Hellfire(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{B}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{B}{B}{B}");
// Destroy all nonblack creatures. Hellfire deals X plus 3 damage to you, where X is the number of creatures that died this way.
this.getSpellAbility().addEffect(new HellfireEffect());
@ -89,8 +90,9 @@ class HellfireEffect extends OneShotEffect {
int destroyedCreature = 0;
FilterCreaturePermanent filter = new FilterCreaturePermanent("all nonblack creatures");
filter.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK)));
for(Permanent creature: game.getState().getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
if (creature.destroy(source.getSourceId(), game, false)) {
for (Permanent creature : game.getState().getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
if (creature.destroy(source.getSourceId(), game, false)
&& game.getState().getZone(creature.getId()).equals(Zone.GRAVEYARD)) { // If a commander is replaced to command zone, the creature does not die) {
destroyedCreature++;
}
}

View file

@ -36,6 +36,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -50,7 +51,7 @@ import mage.target.TargetPlayer;
public class MoggInfestation extends CardImpl {
public MoggInfestation(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{R}{R}");
// Destroy all creatures target player controls. For each creature that died this way, create two 1/1 red Goblin creature tokens under that player's control.
getSpellAbility().addTarget(new TargetPlayer());
@ -90,9 +91,11 @@ class MoggInfestationEffect extends OneShotEffect {
if (controller != null && getTargetPointer().getFirst(game, source) != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), getTargetPointer().getFirst(game, source), game)) {
if (permanent.destroy(source.getSourceId(), game, false)) {
Effect effect = new CreateTokenTargetEffect(new GoblinToken(), 2);
effect.setTargetPointer(getTargetPointer());
effect.apply(game, source);
if (game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) { // If a commander is replaced to command zone, the creature does not die
Effect effect = new CreateTokenTargetEffect(new GoblinToken(), 2);
effect.setTargetPointer(getTargetPointer());
effect.apply(game, source);
}
}
}
return true;

View file

@ -47,6 +47,7 @@ public class CastBRGCommanderTest extends CardTestCommanderDuelBase {
// When you cast Prossh, Skyraider of Kher, put X 0/1 red Kobold creature tokens named Kobolds of Kher Keep onto the battlefield, where X is the amount of mana spent to cast Prossh.
// Sacrifice another creature: Prossh gets +1/+0 until end of turn.
setDecknamePlayerA("Power Hungry.dck"); // Commander = Prosssh, Skyrider of Kher {3}{B}{R}{G}
setDecknamePlayerB("CommanderDuel_UW.dck"); // Daxos of Meletis {1}{W}{U}
return super.createNewGameAndPlayers();
}
@ -96,7 +97,36 @@ public class CastBRGCommanderTest extends CardTestCommanderDuelBase {
assertGraveyardCount(playerA, "Karn Liberated", 0);
assertPermanentCount(playerA, "Silvercoat Lion", 2);
assertCommandZoneCount(playerA, "Prossh, Skyraider of Kher", 1);
assertCommandZoneCount(playerB, "Ob Nixilis of the Black Oath", 1);
assertCommandZoneCount(playerB, "Daxos of Meletis", 1);
}
/**
* Mogg infestation creates tokens "for each creature that died this way".
* When a commander is moved to a command zone, it doesn't "die", and thus
* should not create tokens.
*/
@Test
public void castMoggInfestation() {
// Destroy all creatures target player controls. For each creature that died this way, create two 1/1 red Goblin creature tokens under that player's control.
addCard(Zone.HAND, playerA, "Mogg Infestation", 1); // Sorcery {3}{R}{R}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
addCard(Zone.BATTLEFIELD, playerB, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerB, "Island", 1);
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Daxos of Meletis");
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Mogg Infestation");
setStopAt(3, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Mogg Infestation", 1);
assertCommandZoneCount(playerB, "Daxos of Meletis", 1);
assertPermanentCount(playerB, "Goblin", 0);
}
}

View file

@ -39,22 +39,21 @@ import org.mage.test.serverside.base.impl.CardTestPlayerAPIImpl;
*
* @author LevelX2
*/
public abstract class CardTestCommanderDuelBase extends CardTestPlayerAPIImpl {
public CardTestCommanderDuelBase() {
super();
this.deckNameA = "CommanderDuel.dck";
this.deckNameB = "CommanderDuel.dck";
this.deckNameA = "CommanderDuel.dck"; // Commander Ob Nixilis of the Black Oath
this.deckNameB = "CommanderDuel.dck"; // Commander Ob Nixilis of the Black Oath
}
@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
Game game = new CommanderDuel(MultiplayerAttackOption.LEFT, RangeOfInfluence.ONE, 0, 40);
playerA = createPlayer(game, playerA, "PlayerA",deckNameA);
playerB = createPlayer(game, playerB, "PlayerB",deckNameB);
playerA = createPlayer(game, playerA, "PlayerA", deckNameA);
playerB = createPlayer(game, playerB, "PlayerB", deckNameB);
return game;
}
}
}
}