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

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

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

Ability.getId介绍

[英]Gets the globally unique id of the ability contained within the game.
[中]获取游戏中包含的技能的全局唯一id。

代码示例

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

@Override
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
  return game.getStack().stream()
      .filter(TargetActivatedOrTriggeredAbility::isActivatedOrTriggeredAbility)
      .map(stackObject -> stackObject.getStackAbility().getId())
      .collect(Collectors.toSet());
}

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

private void activateConspire(Ability ability, Game game) {
  Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId());
  if (activations == null) {
    activations = new HashSet<>();
    game.getState().setValue(CONSPIRE_ACTIVATION_KEY + ability.getId(), activations);
  }
  activations.add(getConspireId());
}

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

@Override
public boolean isInactive(Ability source, Game game) {
  return game.getState().getZoneChangeCounter(source.getId()) != zoneChangeCounter;
}

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

public boolean isActivated(Ability ability, Game game) {
  Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId());
  if (activations != null) {
    return activations.contains(getConspireId());
  }
  return false;
}

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

private void resetConspire(Ability ability, Game game) {
  Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId());
  if (activations != null) {
    activations.remove(getConspireId());
  }
}

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

@Override
public void init(Ability source, Game game) {
  super.init(source, game);
  zoneChangeCounter = game.getState().getZoneChangeCounter(source.getId());
}

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

private boolean abilityActive(Ability ability, Game game) {
  MageObject object = game.getObject(ability.getSourceId());
  return object != null && object.hasAbility(ability.getId(), game);
}

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

@Override
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
  Set<UUID> possibleTargets = new HashSet<>();
  for (StackObject stackObject : game.getStack()) {
    if (stackObject.getStackAbility() != null
        && stackObject.getStackAbility() instanceof TriggeredAbility
        && stackObject.getStackAbility().isControlledBy(sourceControllerId)) {
      possibleTargets.add(stackObject.getStackAbility().getId());
    }
  }
  return possibleTargets;
}

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

@Override
public boolean canTarget(UUID id, Ability source, Game game) {
  // rule 114.4. A spell or ability on the stack is an illegal target for itself.
  if (source == null || source.getId().equals(id)) {
    return false;
  }
  Spell spell = game.getStack().getSpell(id);
  return spell != null && filter.match(spell, source.getSourceId(), source.getControllerId(), game);
}

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

@Override
public boolean canTarget(UUID id, Ability source, Game game) {
  // rule 114.4. A spell or ability on the stack is an illegal target for itself.
  if (source != null && source.getId().equals(id)) {
    return false;
  }
  StackObject stackObject = game.getStack().getStackObject(id);
  return isActivatedOrTriggeredAbility(stackObject) && source != null && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game);
}

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

@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
  if ((abilityToModify instanceof SpellAbility)
      && abilityToModify.isControlledBy(source.getControllerId())) {
    Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
    return spell != null && StaticFilters.FILTER_SPELL_INSTANT_OR_SORCERY.match(spell, game);
  }
  return false;
}

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

@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
  if (abilityToModify instanceof SpellAbility) {
    if (abilityToModify.isControlledBy(source.getControllerId())) {
      Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
      if (spell != null) {
        return DashedCondition.instance.apply(game, abilityToModify);
      }
    }
  }
  return false;
}

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

@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
  if (abilityToModify instanceof SpellAbility) {
    if (abilityToModify.isControlledBy(source.getControllerId())) {
      Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
      if (spell != null) {
        return spell.isCreature();
      }
    }
  }
  return false;
}

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

@Override
public boolean apply(Game game, Ability source) {
  List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getId(), game);
  for (Permanent p : permanents) {
    p.sacrifice(source.getSourceId(), game);
  }
  return true;
}

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

@Override
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
  Set<UUID> possibleTargets = new HashSet<>();
  for (StackObject stackObject : game.getStack()) {
    if (stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED
        && game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getStackAbility().getControllerId())
        && filter.match(((StackAbility) stackObject), game)) {
      possibleTargets.add(stackObject.getStackAbility().getId());
    }
  }
  return possibleTargets;
}

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

@Override
public boolean apply(Game game, Ability source) {
  Permanent equipment = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source));
  if(equipment != null){
    Permanent creature = game.getPermanent(equipment.getAttachedTo());
    if(creature != null){
     creature.damage(2, source.getId(), game, false, true);
     return true;
    }
  }
  
  return false;
}

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

@Override
public boolean apply(Game game, Ability source) {
  Permanent target = game.getPermanent(targetPointer.getFirst(game, source));
  if (target != null) {
   Player player = game.getPlayer(target.getControllerId());
   if (player != null) {
    int power = target.getPower().getValue();
    player.damage(power, source.getId(), game, false, true);
   }
   
  }
  return false;
}

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

public CardsView(Collection<? extends Ability> abilities, GameState state) {
  for (Ability ability : abilities) {
    Card sourceCard = state.getPermanent(ability.getSourceId());
    if (sourceCard != null) {
      this.put(ability.getId(), new AbilityView(ability, sourceCard.getName(), new CardView(sourceCard)));
    }
  }
}

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

@Override
public boolean apply(Game game, Ability source) {
  MageObject sourceObject = game.getObject(source.getSourceId());
  Player firstPlayer = game.getPlayer(game.getActivePlayerId());
  Player secondPlayer = game.getPlayer(source.getFirstTarget());
  if (sourceObject == null || firstPlayer == null) {
    return false;
  }
  if (firstPlayer.chooseUse(outcome, "Deal one damage to " + secondPlayer.getLogName() + "?", source, game)) {
    secondPlayer.damage(1, source.getId(), game, false, true);
  }
  return true;
}

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

private void removeConditional(ManaType manaType, Ability ability, Game game, Cost costToPay, Mana usedManaToPay) {
  for (ConditionalMana mana : getConditionalMana()) {
    if (mana.get(manaType) > 0 && mana.apply(ability, game, mana.getManaProducerId(), costToPay)) {
      mana.set(manaType, mana.get(manaType) - 1);
      usedManaToPay.increase(manaType);
      GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAID, ability.getId(), mana.getManaProducerId(), ability.getControllerId(), 0, mana.getFlag());
      event.setData(mana.getManaProducerOriginalId().toString());
      game.fireEvent(event);
      break;
    }
  }
}

相关文章