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,6 +39,7 @@ import mage.util.GameLog;
import mage.util.ThreadLocalStringBuilder;
import mage.watchers.Watcher;
import org.apache.log4j.Logger;
import org.checkerframework.checker.units.qual.C;
import java.util.*;
@ -1356,6 +1357,15 @@ public abstract class AbilityImpl implements Ability {
return null;
}
@Override
public Card getSourceCardIfItStillExists(Game game) {
MageObject mageObject = getSourceObjectIfItStillExists(game);
if (mageObject instanceof Card) {
return (Card) mageObject;
}
return null;
}
@Override
public Permanent getSourcePermanentIfItStillExists(Game game) {
MageObject mageObject = getSourceObjectIfItStillExists(game);