Пример #1
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player you = game.getPlayer(source.getControllerId());
   if (you != null) {
     Mana mana = new Mana();
     for (Permanent permanent : game.getBattlefield().getAllActivePermanents(you.getId())) {
       if (mana.getBlack() == 0 && permanent.getColor().isBlack()) {
         mana.addBlack();
       }
       if (mana.getBlue() == 0 && permanent.getColor().isBlue()) {
         mana.addBlue();
       }
       if (mana.getRed() == 0 && permanent.getColor().isRed()) {
         mana.addRed();
       }
       if (mana.getGreen() == 0 && permanent.getColor().isGreen()) {
         mana.addGreen();
       }
       if (mana.getWhite() == 0 && permanent.getColor().isWhite()) {
         mana.addWhite();
       }
     }
     you.getManaPool().addMana(mana, game, source);
     return true;
   }
   return false;
 }
Пример #2
0
 @Override
 public boolean testPay(Mana testMana) {
   switch (mana) {
     case B:
       if (testMana.getBlack() > 0) {
         return true;
       }
     case U:
       if (testMana.getBlue() > 0) {
         return true;
       }
     case R:
       if (testMana.getRed() > 0) {
         return true;
       }
     case W:
       if (testMana.getWhite() > 0) {
         return true;
       }
     case G:
       if (testMana.getGreen() > 0) {
         return true;
       }
   }
   return testMana.count() > 0;
 }
Пример #3
0
 public List<Mana> getNetMana(Game game, Ability source) {
   List<Mana> netManas = new ArrayList<>();
   Mana types = getManaTypes(game, source);
   if (types.getAny() > 0) {
     netManas.add(new Mana(0, 0, 0, 0, 0, 0, 1, 0));
     return netManas;
   }
   if (types.getBlack() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.B));
   }
   if (types.getRed() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.R));
   }
   if (types.getBlue() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.U));
   }
   if (types.getGreen() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.G));
   }
   if (types.getWhite() > 0) {
     netManas.add(new Mana(ColoredManaSymbol.W));
   }
   if (types.getColorless() > 0) {
     netManas.add(Mana.ColorlessMana(1));
   }
   return netManas;
 }
 @Override
 public boolean apply(Game game, Ability source) {
   Mana types = getManaTypes(game, source);
   Choice choice = new ChoiceImpl(true);
   choice.setMessage("Pick a mana color");
   if (types.getBlack() > 0) {
     choice.getChoices().add("Black");
   }
   if (types.getRed() > 0) {
     choice.getChoices().add("Red");
   }
   if (types.getBlue() > 0) {
     choice.getChoices().add("Blue");
   }
   if (types.getGreen() > 0) {
     choice.getChoices().add("Green");
   }
   if (types.getWhite() > 0) {
     choice.getChoices().add("White");
   }
   if (types.getAny() > 0) {
     choice.getChoices().add("Black");
     choice.getChoices().add("Red");
     choice.getChoices().add("Blue");
     choice.getChoices().add("Green");
     choice.getChoices().add("White");
   }
   if (choice.getChoices().size() > 0) {
     Player player = game.getPlayer(source.getControllerId());
     if (choice.getChoices().size() == 1) {
       choice.setChoice(choice.getChoices().iterator().next());
     } else {
       player.choose(outcome, choice, game);
     }
     if (choice.getChoice() != null) {
       Mana mana = new Mana();
       switch (choice.getChoice()) {
         case "Black":
           mana.setBlack(1);
           break;
         case "Blue":
           mana.setBlue(1);
           break;
         case "Red":
           mana.setRed(1);
           break;
         case "Green":
           mana.setGreen(1);
           break;
         case "White":
           mana.setWhite(1);
           break;
       }
       checkToFirePossibleEvents(mana, game, source);
       player.getManaPool().addMana(mana, game, source);
     }
   }
   return true;
 }
Пример #5
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;
 }