Refactor: fixed wrong usage of getSourceObjectIfItStillExists (fixed error "cannot be cast to Permanent");

This commit is contained in:
Oleg Agafonov 2023-03-26 13:10:00 +04:00
parent bfba179bdf
commit b632d89caa
24 changed files with 26 additions and 26 deletions

View file

@ -66,7 +66,7 @@ class LicidEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent licid = (Permanent) source.getSourceObjectIfItStillExists(game);
Permanent licid = source.getSourcePermanentIfItStillExists(game);
if (licid != null) {
UUID messageId = UUID.randomUUID();
LicidContinuousEffect effect = new LicidContinuousEffect(messageId);
@ -103,7 +103,7 @@ class LicidContinuousEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent licid = (Permanent) source.getSourceObjectIfItStillExists(game);
Permanent licid = source.getSourcePermanentIfItStillExists(game);
if (licid != null) {
switch (layer) {
case TypeChangingEffects_4:

View file

@ -34,7 +34,7 @@ public class MustBeBlockedByTargetSourceEffect extends RequirementEffect {
if (permanent.getId().equals(this.getTargetPointer().getFirst(game, source))) {
Permanent blocker = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (blocker != null && blocker.canBlock(source.getSourceId(), game)) {
Permanent attacker = (Permanent) source.getSourceObjectIfItStillExists(game);
Permanent attacker = source.getSourcePermanentIfItStillExists(game);
if (attacker != null) {
BlockedAttackerWatcher blockedAttackerWatcher = game.getState().getWatcher(BlockedAttackerWatcher.class);
if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attacker, blocker, game)) {