Пример #1
0
 @Override
 public boolean apply(MageObject input, Game game) {
   return color != null && input.getColor(game).contains(color);
 }
Пример #2
0
  @Override
  public Token apply(Card source) {
    if (target == null) {
      throw new IllegalArgumentException("Target can't be null");
    }
    // A copy contains only the attributes of the basic card or basic Token that's the base of the
    // permanent
    // else gained abililies would be copied too.

    MageObject sourceObj = source;
    if (source instanceof PermanentToken) {
      sourceObj = ((PermanentToken) source).getToken();
      // to show the source image, the original values have to be used
      target.setOriginalExpansionSetCode(((Token) sourceObj).getOriginalExpansionSetCode());
      target.setOriginalCardNumber(((Token) sourceObj).getOriginalCardNumber());
      target.setCopySourceCard(((PermanentToken) source).getToken().getCopySourceCard());
    } else if (source instanceof PermanentCard) {
      if (((PermanentCard) source).isMorphed() || ((PermanentCard) source).isManifested()) {
        MorphAbility.setPermanentToFaceDownCreature(target);
        return target;
      } else {
        if (((PermanentCard) source).isTransformed() && source.getSecondCardFace() != null) {
          sourceObj = ((PermanentCard) source).getSecondCardFace();
        } else {
          sourceObj = ((PermanentCard) source).getCard();
        }

        target.setOriginalExpansionSetCode(source.getExpansionSetCode());
        target.setOriginalCardNumber(source.getCardNumber());
        target.setCopySourceCard((Card) sourceObj);
      }
    } else {
      target.setOriginalExpansionSetCode(source.getExpansionSetCode());
      target.setOriginalCardNumber(source.getCardNumber());
      if (source instanceof Card) {
        target.setCopySourceCard(source);
      }
    }

    target.setName(sourceObj.getName());
    target.getColor(null).setColor(sourceObj.getColor(null));
    target.getManaCost().clear();
    target.getManaCost().add(sourceObj.getManaCost());
    target.getCardType().clear();
    for (CardType type : sourceObj.getCardType()) {
      target.getCardType().add(type);
    }
    target.getSubtype().clear();
    for (String type : sourceObj.getSubtype()) {
      target.getSubtype().add(type);
    }
    target.getSupertype().clear();
    for (String type : sourceObj.getSupertype()) {
      target.getSupertype().add(type);
    }

    target.getAbilities().clear();

    for (Ability ability0 : sourceObj.getAbilities()) {
      Ability ability = ability0.copy();
      ability.newId();
      ability.setSourceId(target.getId());
      target.addAbility(ability);
    }

    target.getPower().modifyBaseValue(sourceObj.getPower().getBaseValueModified());
    target.getToughness().modifyBaseValue(sourceObj.getToughness().getBaseValueModified());

    return target;
  }