mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
- Fixed #8548
This commit is contained in:
parent
1810c2c778
commit
26e12b55c8
1 changed files with 18 additions and 5 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -6,8 +5,11 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CreateTokenTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
|
@ -62,16 +64,27 @@ class MoggInfestationEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && getTargetPointer().getFirst(game, source) != null) {
|
||||
Cards creaturesDied = new CardsImpl();
|
||||
if (controller != null
|
||||
&& getTargetPointer().getFirst(game, source) != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) {
|
||||
if (permanent.destroy(source, game, false)) {
|
||||
if (game.getState().getZone(permanent.getId()) == 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);
|
||||
creaturesDied.add(permanent);
|
||||
}
|
||||
}
|
||||
}
|
||||
game.getState().processAction(game); // Bug #8548
|
||||
if (creaturesDied.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (Card c : creaturesDied.getCards(game)) {
|
||||
if (game.getState().getZone(c.getId()) == Zone.GRAVEYARD) {
|
||||
Effect effect = new CreateTokenTargetEffect(new GoblinToken(), 2);
|
||||
effect.setTargetPointer(getTargetPointer());
|
||||
effect.apply(game, source);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue