mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
avoid casting to Card with dedicated method getSourceCardIfItStillExists
This commit is contained in:
parent
a90f226053
commit
d226b30592
40 changed files with 150 additions and 178 deletions
|
|
@ -39,13 +39,13 @@ public class PutOnLibrarySourceEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
|
||||
if (player == null || !(sourceObject instanceof Card)) {
|
||||
Card card = source.getSourceCardIfItStillExists(game);
|
||||
if (player == null || card == null) {
|
||||
return false;
|
||||
}
|
||||
if (onTop) {
|
||||
return player.putCardsOnTopOfLibrary((Card) sourceObject, game, source, false);
|
||||
return player.putCardsOnTopOfLibrary(card, game, source, false);
|
||||
}
|
||||
return player.putCardsOnBottomOfLibrary((Card) sourceObject, game, source, false);
|
||||
return player.putCardsOnBottomOfLibrary(card, game, source, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue