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

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

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

Ability.getSourceId介绍

[英]Gets the id of the object which put this ability in motion.
[中]获取使此功能处于运动状态的对象的id。

代码示例

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

@Override
  public boolean apply(Game game, Ability source) {
    Object tribute = game.getState().getValue("tributeValue" + source.getSourceId());
    if (tribute != null) {
      return ((String) tribute).equals("no");
    }
    return false;
  }
}

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

@Override
public void adjustTargets(Ability ability, Game game) {
  Card card = game.getCard(ability.getSourceId());
  if (card != null) {
    card.adjustTargets(ability, game);
  }
}

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

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
  Permanent sourcePermanent = game.getPermanent(sourceAbility.getSourceId());
  if (sourcePermanent == null) {
    sourcePermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD);
  }
  if (sourcePermanent != null) {
    return sourcePermanent.getToughness().getValue();
  }
  return 0;
}

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

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
  MageObject mageObject = game.getObject(source.getSourceId());
  if (mageObject != null) {
    return "You can't cast creature spells this turn (" + mageObject.getIdName() + ").";
  }
  return null;
}

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

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
  MageObject sourceObject = game.getObject(source.getSourceId());
  if (sourceObject != null) {
    return "This spell can't be countered because mana from " + sourceObject.getName() + " was spent to cast it.";
  }
  return null;
}

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

@Override
  public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getSourceId());
    if (card != null) {
      return card.getAbilities().stream()
          .filter(ab -> ab instanceof EvokeAbility)
          .anyMatch(evoke -> ((EvokeAbility) evoke).isActivated(source, game));
    }
    return false;
  }
}

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

@Override
public boolean apply(Game game, Ability source) {
  Permanent permanent = game.getPermanentEntering(source.getSourceId());
  if (permanent != null) {
    // except only takes place if something was copied
    if (permanent.isCopy()) {
      return super.apply(game, source);
    }
  }
  return false;
}

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

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
  int value = game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
  if (multiplier != null) {
    value *= multiplier;
  }
  return value;
}

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

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
  if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getSourceId().equals(source.getSourceId())) {
    CombatDamageStepStartedWatcher watcher = game.getState().getWatcher(CombatDamageStepStartedWatcher.class);
    return watcher == null || watcher.conditionMet();
  }
  return false;
}

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

@Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
      permanent.addCounters(CounterType.CHARGE.createInstance((Integer) this.getValue("damageAmount")), source, game);
    }
    return true;
  }
}

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

@Override
  public boolean apply(Game game, Ability source) {
    Permanent attachment = game.getPermanent(source.getSourceId());
    if (attachment == null || attachment.getAttachedTo() == null) {
      return false;
    }
    Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
    return (attachedTo != null);
  }
}

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

@Override
  public boolean apply(Game game, Ability source) {
    for (UUID opponentId : game.getOpponents(source.getControllerId())) {
      Token token = new SoldierToken();
      token.putOntoBattlefield(1, game, source.getSourceId(), opponentId);
    }
    return true;
  }
}

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

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
  Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
  return creature != null && creature.isControlledBy(source.getControllerId())
      && creature.isCreature()
      && creature.hasSubtype(SubType.WARRIOR, game)
      && !event.getTargetId().equals(source.getSourceId());
}

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

@Override
  public boolean apply(Game game, Ability source) {
    Permanent target = game.getBattlefield().getPermanent(source.getFirstTarget());
    if (target != null) {
      if (filter.match(target, source.getSourceId(), source.getControllerId(), game)) {
        return true;
      }
    }
    return false;
  }
}

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

@Override
public int calculate(Game game, Ability source, Effect effect) {
  Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
  Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
  return enchanted.getToughness().getValue();
}

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

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
  MageObject mageObject = game.getObject(source.getSourceId());
  Permanent permanentToUntap = game.getPermanent((event.getTargetId()));
  if (permanentToUntap != null && mageObject != null) {
    return permanentToUntap.getLogName() + " doesn't untap (" + mageObject.getLogName() + ')';
  }
  return null;
}

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

@Override
public boolean apply(Game game, Ability source) {
  int damage = 0;
  for (UUID opponentId: game.getOpponents(source.getControllerId())) {
    damage += game.getPlayer(opponentId).damage(3, source.getSourceId(), game, false, true);
  }
  game.getPlayer(source.getControllerId()).gainLife(damage, game, source);
  return true;
}

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

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
  ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, sourceAbility.getSourceId(), sourceAbility.getSourceObjectZoneChangeCounter()));
  if (exileZone != null) {
    Card exiledCard = exileZone.getRandom(game);
    if (exiledCard != null) {
      return exiledCard.getPower().getValue();
    }
  }
  return 0;
}

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

@Override
public boolean apply(Game game, Ability source) {
  SpecialAction newAction = (SpecialAction) action.copy();
  newAction.setSourceId(source.getSourceId());
  newAction.setControllerId(source.getControllerId());
  newAction.getTargets().addAll(source.getTargets());
  game.getState().getSpecialActions().add(newAction);
  return true;
}

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

@Override
  public boolean apply(Game game, Ability source) {
    FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Eldrazi Spawn");
    filter.add(new SubtypePredicate(SubType.ELDRAZI));
    filter.add(new SubtypePredicate(SubType.SPAWN));

    EldraziSpawnToken token = new EldraziSpawnToken();
    int count = game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0 ? 3 : 1;
    token.putOntoBattlefield(count, game, source.getSourceId(), source.getControllerId());
    return true;
  }
}

相关文章