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

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

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

Ability.activate介绍

[英]Activates this ability prompting the controller to pay any mandatory
[中]激活此功能,提示控制器支付任何强制费用

代码示例

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

@Override
public boolean activate(Game game, boolean noMana) {
  return ability.activate(game, noMana);
}

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

if (ability.activate(game, false)) {
  game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
  actionCount++;
if (ability.activate(game, false)) {
  ability.resolve(game);
  actionCount++;

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

protected void addAbilityNode(SimulationNode parent, Ability ability, Game game) {
  Game sim = game.copy();
  sim.getStack().push(new StackAbility(ability, playerId));
  ability.activate(sim, false);
  if (ability.activate(sim, false) && ability.isUsesStack()) {
    game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
  }
  sim.applyEffects();
  SimulationNode newNode = new SimulationNode(parent, sim, playerId);
  logger.debug(indent(newNode.getDepth()) + "simulating -- node #:" + SimulationNode.getCount() + " triggered ability option");
  for (Target target: ability.getTargets()) {
    for (UUID targetId: target.getTargets()) {
      newNode.getTargets().add(targetId);
    }
  }
  parent.children.add(newNode);
}

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

protected void addAbilityNode(SimulationNode2 parent, Ability ability, int depth, Game game) {
  Game sim = game.copy();
  sim.getStack().push(new StackAbility(ability, playerId));
  if (ability.activate(sim, false) && ability.isUsesStack()) {
    game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
  }
  sim.applyEffects();
  SimulationNode2 newNode = new SimulationNode2(parent, sim, depth, playerId);
  logger.debug("simulating -- node #:" + SimulationNode2.getCount() + " triggered ability option");
  for (Target target : ability.getTargets()) {
    for (UUID targetId : target.getTargets()) {
      newNode.getTargets().add(targetId);
    }
  }
  parent.children.add(newNode);
}

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

@Override
public boolean triggerAbility(TriggeredAbility source, Game game) {
  Ability ability = source.copy();
  List<Ability> options = getPlayableOptions(ability, game);
  if (options.isEmpty()) {
    if (logger.isDebugEnabled())
      logger.debug("simulating -- triggered ability:" + ability);
    game.getStack().push(new StackAbility(ability, playerId));
    if (ability.activate(game, false) && ability.isUsesStack()) {
      game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
    }
    game.applyEffects();
    game.getPlayers().resetPassed();
  }
  else {
    SimulationNode parent = (SimulationNode) game.getCustomData();
    if (parent.getDepth() == maxDepth) return true;
    logger.debug(indent(parent.getDepth()) + "simulating -- triggered ability - adding children:" + options.size());
    for (Ability option: options) {
      addAbilityNode(parent, option, game);
    }
  }
  return true;
}

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

@Override
public boolean triggerAbility(TriggeredAbility source, Game game) {
  Ability ability = source.copy();
  List<Ability> options = getPlayableOptions(ability, game);
  if (options.isEmpty()) {
    logger.debug("simulating -- triggered ability:" + ability);
    game.getStack().push(new StackAbility(ability, playerId));
    if (ability.activate(game, false) && ability.isUsesStack()) {
      game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
    }
    game.applyEffects();
    game.getPlayers().resetPassed();
  } else {
    SimulationNode2 parent = (SimulationNode2) game.getCustomData();
    int depth = parent.getDepth() - 1;
    if (depth == 0) {
      return true;
    }
    logger.debug("simulating -- triggered ability - adding children:" + options.size());
    for (Ability option : options) {
      addAbilityNode(parent, option, depth, game);
    }
  }
  return true;
}

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

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
  if (optional) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject object = game.getObject(source.getSourceId());
    if (controller == null || object == null) {
      return false;
    }
    if (!controller.chooseUse(outcome, "Use effect of " + object.getIdName() + "?", source, game)) {
      return false;
    }
  }
  for (Effect effect : baseEffects) {
    if (source.activate(game, false)) {
      if (effect instanceof ContinuousEffect) {
        game.addEffect((ContinuousEffect) effect, source);
      } else {
        effect.apply(game, source);
      }
    }
  }
  return false;
}

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

manaAbiltiy.setSourceObjectZoneChangeCounter(getState().getZoneChangeCounter(ability.getSourceId()));
  manaAbiltiy.activate(this, false);
  manaAbiltiy.resolve(this);
} else {

相关文章