forked from External/mage
refactor: introduce new helper method
to find permanent from card after moved to battlefield
This commit is contained in:
parent
8147ebe531
commit
692a843b86
4 changed files with 12 additions and 3 deletions
|
|
@ -192,7 +192,7 @@ class AnimateDeadPutOntoBattlefieldEffect extends OneShotEffect {
|
|||
player.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, false, null);
|
||||
game.processAction();
|
||||
|
||||
Permanent creature = game.getPermanent(CardUtil.getDefaultCardSideForBattlefield(game, card).getId());
|
||||
Permanent creature = CardUtil.getPermanentFromCardPutToBattlefield(card, game);
|
||||
if (creature == null) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class PutCardIntoPlayWithHasteAndSacrificeEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
player.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
Permanent permanent = game.getPermanent(CardUtil.getDefaultCardSideForBattlefield(game, card).getId());
|
||||
Permanent permanent = CardUtil.getPermanentFromCardPutToBattlefield(card, game);
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1315,6 +1315,15 @@ public final class CardUtil {
|
|||
return permCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a card object is moved to the battlefield, object id can be different (e.g. MDFC).
|
||||
* Use this method to get the permanent object from the card object after move to battlefield.
|
||||
* Can return null if not found on the battlefield.
|
||||
*/
|
||||
public static Permanent getPermanentFromCardPutToBattlefield(Card card, Game game) {
|
||||
return game.getPermanent(CardUtil.getDefaultCardSideForBattlefield(game, card).getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return card name for same name searching
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue