mage.abilities.Ability.getSourceObjectIfItStillExists()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中mage.abilities.Ability.getSourceObjectIfItStillExists()方法的一些代码示例,展示了Ability.getSourceObjectIfItStillExists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ability.getSourceObjectIfItStillExists()方法的具体详情如下:
包路径:mage.abilities.Ability
类名称:Ability
方法名:getSourceObjectIfItStillExists

Ability.getSourceObjectIfItStillExists介绍

[英]Returns the object that actually existed while a ability triggerd or an ability was activated only if it has not changed zone meanwhile. If not set yet, the current object will be retrieved from the game.
[中]返回激活异能触发或激活异能时实际存在的对象,前提是该对象未更改。如果尚未设置,将从游戏中检索当前对象。

代码示例

代码示例来源:origin: magefree/mage

@Override
public MageObject getSourceObjectIfItStillExists(Game game) {
  return this.ability.getSourceObjectIfItStillExists(game);
}

代码示例来源:origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
  if (permanent != null) {
    return permanent.changeControllerId(source.getFirstTarget(), game);
  } else {
    discard();
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    if (permanent != null) {
      return permanent.changeControllerId(source.getFirstTarget(), game);
    } else {
      discard();
    }
    return false;
  }
}

代码示例来源:origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
  if (permanent != null) {
    return permanent.changeControllerId(source.getFirstTarget(), game);
  } else {
    discard();
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    if (permanent != null) {
      return permanent.changeControllerId(source.getFirstTarget(), game);
    } else {
      discard();
    }
    return false;
  }
}

代码示例来源:origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
  if (permanent != null) {
    return permanent.changeControllerId(source.getFirstTarget(), game);
  } else {
    discard();
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
  if (permanent != null) {
    return permanent.changeControllerId(source.getFirstTarget(), game);
  } else {
    discard();
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
  if (permanent != null) {
    return permanent.changeControllerId(source.getFirstTarget(), game);
  } else {
    discard();
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
      return false;
    }
    Card card = (Card) source.getSourceObjectIfItStillExists(game);
    if (card != null) {
      controller.putCardOnTopXOfLibrary(card, game, source, 3);
    }
    return true;
  }
}

代码示例来源:origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  MageObject permanent = source.getSourceObjectIfItStillExists(game); // it can also return Card object
  Player targetOpponent = game.getPlayer(source.getFirstTarget());
  if ((permanent instanceof Permanent)
      && targetOpponent != null) {
    return ((Permanent) permanent).changeControllerId(targetOpponent.getId(), game);
  } else {
    discard();
  }
  return false;
}

代码示例来源:origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
  if (sourceObject instanceof Permanent) {
    //create delayed triggered ability
    Effect effect = new TransformTargetEffect(false);
    effect.setTargetPointer(new FixedTarget((Permanent) sourceObject, game));
    AtTheBeginOfNextUpkeepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(effect);
    game.addDelayedTriggeredAbility(delayedAbility, source);
  }
  return true;
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
    if (controller != null && (sourceObject instanceof Card)) {
      return controller.moveCards((Card) sourceObject, Zone.BATTLEFIELD, source, game, false,
          controller.chooseUse(Outcome.Detriment, "Return " + sourceObject.getLogName() + " face down to battlefield (otherwise face up)?", source, game),
          false, null);
    }
    return false;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Player targetOpponent = game.getPlayer(source.getFirstTarget());
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    if (permanent != null && targetOpponent != null) {
        permanent.changeControllerId(targetOpponent.getId(), game);
    } else {
      // no valid target exists, effect can be discarded
      discard();
    }
    return true;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    // If Banisher Priest leaves the battlefield before its triggered ability resolves,
    // the target creature won't be exiled.
    if (permanent != null) {
      return new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), permanent.getIdName()).apply(game, source);
    }
    return false;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    // If Fairsgrounds Warden leaves the battlefield before its triggered ability resolves,
    // the target creature won't be exiled.
    if (permanent != null) {
      return new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), permanent.getIdName()).apply(game, source);
    }
    return false;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    // If this leaves the battlefield before its triggered ability resolves,
    // the target creature won't be exiled.
    if (permanent != null) {
      return new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), permanent.getIdName()).apply(game, source);
    }
    return false;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    if (permanent != null) {
      if (permanent.sacrifice(source.getSourceId(), game)) {
        Effect effect = new DestroyTargetEffect();
        effect.setTargetPointer(this.getTargetPointer());
        return effect.apply(game, source);
      }
    }
    return false;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    if (permanent != null) {
      if (permanent.sacrifice(source.getSourceId(), game)) {
        Effect effect = new DamageTargetEffect(4).setText("{this} deals 4 damage to it");
        effect.setTargetPointer(this.getTargetPointer());
        return effect.apply(game, source);
      }
    }
    return false;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (player != null && permanent != null) {
      ContinuousEffect effect = new FruitcakeElementalControlSourceEffect();
      game.addEffect(effect, source);
      game.informPlayers(permanent.getName() + " is now controlled by " + player.getLogName());
      return true;
    }
    return false;
  }
}

代码示例来源:origin: magefree/mage

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    // If Prison Warden leaves the battlefield before its triggered ability resolves,
    // the target creature won't be exiled.
    if (permanent != null) {
      Effect effect = new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), permanent.getIdName());
      effect.setTargetPointer(getTargetPointer());
      return effect.apply(game, source);
    }
    return false;
  }
}

相关文章