Example #1
0
 @Override
 public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
   Player controller = game.getPlayer(source.getControllerId());
   if (controller != null) {
     controller.getAlternativeSourceCosts().add(alternativeCastingCostAbility);
     return true;
   }
   return false;
 }
Example #2
0
 @Override
 public boolean activateAlternateOrAdditionalCosts(
     MageObject sourceObject, boolean noMana, Player controller, Game game) {
   boolean alternativeCostisUsed = false;
   if (sourceObject != null
       && !(sourceObject instanceof Permanent)
       && !(this instanceof FlashbackAbility)) {
     Abilities<Ability> abilities = null;
     if (sourceObject instanceof Card) {
       abilities = ((Card) sourceObject).getAbilities(game);
     } else {
       sourceObject.getAbilities();
     }
     if (abilities != null) {
       for (Ability ability : abilities) {
         // if cast for noMana no Alternative costs are allowed
         if (!noMana && ability instanceof AlternativeSourceCosts) {
           AlternativeSourceCosts alternativeSpellCosts = (AlternativeSourceCosts) ability;
           if (alternativeSpellCosts.isAvailable(this, game)) {
             if (alternativeSpellCosts.askToActivateAlternativeCosts(this, game)) {
               // only one alternative costs may be activated
               alternativeCostisUsed = true;
               break;
             }
           }
         }
         if (ability instanceof OptionalAdditionalSourceCosts) {
           ((OptionalAdditionalSourceCosts) ability).addOptionalAdditionalCosts(this, game);
         }
       }
     }
     // controller specific alternate spell costs
     if (!noMana && !alternativeCostisUsed) {
       if (this.getAbilityType().equals(AbilityType.SPELL)
           // 117.9a Only one alternative cost can be applied to any one spell as it’s being cast.
           // So an alternate spell ability can't be paid with Omniscience
           && !((SpellAbility) this)
               .getSpellAbilityType()
               .equals(SpellAbilityType.BASE_ALTERNATE)) {
         for (AlternativeSourceCosts alternativeSourceCosts :
             controller.getAlternativeSourceCosts()) {
           if (alternativeSourceCosts.isAvailable(this, game)) {
             if (alternativeSourceCosts.askToActivateAlternativeCosts(this, game)) {
               // only one alternative costs may be activated
               alternativeCostisUsed = true;
               break;
             }
           }
         }
       }
     }
   }
   return alternativeCostisUsed;
 }