private Mana getManaTypes(Game game, Ability source) {
   List<Permanent> lands =
       game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
   Mana types = new Mana();
   for (Permanent land : lands) {
     Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
     for (ManaAbility ability : mana) {
       if (!ability.equals(source) && ability.definesMana()) {
         for (Mana netMana : ability.getNetMana(game)) {
           types.add(netMana);
         }
       }
     }
   }
   return types;
 }
示例#2
0
 @Override
 public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
   for (Permanent land :
       game.getState()
           .getBattlefield()
           .getAllActivePermanents(new FilterLandPermanent(), source.getControllerId(), game)) {
     if (land != null) {
       switch (layer) {
         case AbilityAddingRemovingEffects_6:
           Mana mana = new Mana();
           for (Ability ability : land.getAbilities()) {
             if (ability instanceof BasicManaAbility) {
               for (Mana netMana : ((BasicManaAbility) ability).getNetMana(game)) {
                 mana.add(netMana);
               }
             }
           }
           if (mana.getGreen() == 0 && landTypes.contains("Forest")) {
             land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
           }
           if (mana.getRed() == 0 && landTypes.contains("Mountain")) {
             land.addAbility(new RedManaAbility(), source.getSourceId(), game);
           }
           if (mana.getBlue() == 0 && landTypes.contains("Island")) {
             land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
           }
           if (mana.getWhite() == 0 && landTypes.contains("Plains")) {
             land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
           }
           if (mana.getBlack() == 0 && landTypes.contains("Swamp")) {
             land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
           }
           break;
         case TypeChangingEffects_4:
           for (String subtype : landTypes) {
             if (!land.getSubtype().contains(subtype)) {
               land.getSubtype().add(subtype);
             }
           }
           break;
       }
     }
   }
   return true;
 }