avoid casting to Card with dedicated method getSourceCardIfItStillExists

This commit is contained in:
xenohedron 2024-06-02 19:39:58 -04:00
parent a90f226053
commit d226b30592
40 changed files with 150 additions and 178 deletions

View file

@ -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);
}
}