本文整理了Java中mage.abilities.Ability.getSourceObject()
方法的一些代码示例,展示了Ability.getSourceObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ability.getSourceObject()
方法的具体详情如下:
包路径:mage.abilities.Ability
类名称:Ability
方法名:getSourceObject
[英]Returns the object that actually existed while a ability triggered or an ability was activated. If not set yet, the current object will be retrieved from the game.
[中]返回触发异能或激活异能时实际存在的对象。如果尚未设置,将从游戏中检索当前对象。
代码示例来源:origin: magefree/mage
public static void logMissingWatcher(Game game, Ability source, Class watcherClass, Class usingClass) {
MageObject sourceObject = source.getSourceObject(game);
Logger.getLogger(usingClass).error("Needed watcher is not started " + watcherClass.getSimpleName()
+ " - " + (sourceObject == null ? " no source object" : sourceObject.getName()));
}
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null) {
return new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), sourceObject.getIdName()).apply(game, source);
}
return false;
}
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
MageObject object = source.getSourceObject(game);
return object instanceof Spell && object.isCreature();
}
}
代码示例来源:origin: magefree/mage
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = source.getSourceObject(game);
if (mageObject != null) {
return "You can't cast noncreature spells this turn (you were dealt damage by " + mageObject.getLogName() + ')';
}
return null;
}
代码示例来源:origin: magefree/mage
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) {
MageObject sourceObject = abilityToModify.getSourceObject(game);
if (sourceObject != null && sourceObject.isArtifact()) {
return true;
}
}
return false;
}
代码示例来源:origin: magefree/mage
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
String namedCard = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
String playerName = game.getPlayer(source.getControllerId()).getName();
if (namedCard == null || playerName == null || source.getSourceObject(game) == null){
return super.getInfoMessage(source, event, game);
}
return "Until "+playerName+"'s next turn, spells named "+namedCard+" can't be cast and lands named "+namedCard+" can't be played ("+source.getSourceObject(game).getIdName()+").";
}
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) {
ExileZone exile = getExileIfPossible(game, source);
if (exile != null) {
return controller.moveCards(new LinkedHashSet<>(exile.getCards(game)), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
}
return false;
}
代码示例来源:origin: magefree/mage
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getPlayerId().equals(source.getControllerId())) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
return player.chooseUse(Outcome.Detriment, "Choose:", source.getSourceObject(game).getLogName(),
"land or nonland and reveal cards from the top", "normal card draw", source, game);
}
}
return false;
}
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null) {
if (sourceObject.getPower().getValue() >= 10) {
game.addEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.EndOfTurn), source);
}
return true;
}
return false;
}
}
代码示例来源:origin: magefree/mage
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent knightOfTheHolyNimbus = game.getPermanent(event.getTargetId());
if (knightOfTheHolyNimbus != null
&& event.getAmount() == 0) { // 1=noRegen
if (knightOfTheHolyNimbus.regenerate(source.getSourceId(), game)) {
game.informPlayers(source.getSourceObject(game).getName() + " has been regenerated.");
return true;
}
}
return false;
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && new MageObjectReference(permanent, game).refersTo(source.getSourceObject(game), game)) {
permanent.addAbility(ability, source.getSourceId(), game);
} else {
// the source permanent is no longer on the battlefield, effect can be discarded
discard();
}
return true;
}
代码示例来源:origin: magefree/mage
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent ClergyOfTheHolyNimbus = game.getPermanent(event.getTargetId());
if (ClergyOfTheHolyNimbus != null
&& event.getAmount() == 0) { // 1=noRegen
if (ClergyOfTheHolyNimbus.regenerate(source.getSourceId(), game)) {
game.informPlayers(source.getSourceObject(game).getName() + " has been regenerated.");
return true;
}
}
return false;
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card target = (Card) game.getObject(source.getFirstTarget());
if (controller != null && target != null) {
return controller.cast(target.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
}
return false;
}
代码示例来源:origin: magefree/mage
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Player controller = game.getPlayer(source.getControllerId());
String sourceName = source.getSourceObject(game).getLogName();
choseUse = controller.chooseUse(Outcome.Damage, "Have creatures you control deal combat damage this turn"
+ " as though they weren't blocked?", source, game);
game.informPlayers(choseUse ? controller.getName() + " chose to use " + sourceName + "'s effect"
: controller.getName() + " chose not to use " + sourceName + "'s effect.");
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
if (permanent != null && sourceObject instanceof Permanent) {
if (permanent.moveToExile(null, null, source.getSourceId(), game)
&& ((Permanent) sourceObject).imprint(permanent.getId(), game)) {
((Permanent) sourceObject).addInfo("imprint", "[Imprinted card - " + permanent.getName() + ']', game);
}
return true;
}
return false;
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (controller != null && card != null) {
if (controller.chooseUse(Outcome.PlayForFree, "Play " + card.getIdName() + " without paying its mana cost?", source, game)) {
controller.playCard(card, game, true, true, new MageObjectReference(source.getSourceObject(game), game));
}
return true;
}
return false;
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget());
MageObject sourceObject = source.getSourceObject(game);
if (permanent != null) {
permanent.moveToExile(null, null, source.getSourceId(), game);
if (sourceObject instanceof Permanent) {
((Permanent) sourceObject).imprint(permanent.getId(), game);
}
}
return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getFirstTarget());
if (controller == null || card == null) {
return false;
}
controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
game.addEffect(new WrexialReplacementEffect(card.getId()), source);
return true;
}
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.chooseUse(Outcome.Benefit, "Cast " + card.getName() + " without paying cost?", source, game)) {
player.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
}
}
return false;
}
}
代码示例来源:origin: magefree/mage
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
controller.cast(card.getSpellAbility(), game, false, new MageObjectReference(source.getSourceObject(game), game));
game.addEffect(new ToshiroUmezawaReplacementEffect(card.getId()), source);
}
}
return false;
}
}
内容来源于网络,如有侵权,请联系作者删除!