コード例 #1
0
 @Override
 public boolean apply(Game game, Ability source, Ability abilityToModify) {
   if (manaCostsToReduce != null) {
     CardUtil.adjustCost((SpellAbility) abilityToModify, manaCostsToReduce, false);
   } else {
     if (upTo) {
       Mana mana = abilityToModify.getManaCostsToPay().getMana();
       int reduceMax = mana.getColorless();
       if (reduceMax > 2) {
         reduceMax = 2;
       }
       if (reduceMax > 0) {
         Player controller = game.getPlayer(abilityToModify.getControllerId());
         if (controller == null) {
           return false;
         }
         ChoiceImpl choice = new ChoiceImpl(true);
         Set<String> set = new LinkedHashSet<>();
         for (int i = 0; i <= reduceMax; i++) {
           set.add(String.valueOf(i));
         }
         choice.setChoices(set);
         choice.setMessage("Reduce cost of " + filter);
         if (controller.choose(Outcome.Benefit, choice, game)) {
           int reduce = Integer.parseInt(choice.getChoice());
           CardUtil.reduceCost(abilityToModify, reduce);
         }
       }
     } else {
       CardUtil.reduceCost(abilityToModify, this.amount);
     }
   }
   return true;
 }
コード例 #2
0
ファイル: Realmwright.java プロジェクト: TumbleMagnet/mage
 @Override
 public boolean apply(Game game, Ability source) {
   Player you = game.getPlayer(source.getControllerId());
   if (you != null) {
     ChoiceImpl choices = new ChoiceImpl(true);
     choices.setMessage("Choose basic land type");
     choices.isRequired();
     choices.getChoices().add("Forest");
     choices.getChoices().add("Plains");
     choices.getChoices().add("Mountain");
     choices.getChoices().add("Island");
     choices.getChoices().add("Swamp");
     if (you.choose(Outcome.Neutral, choices, game)) {
       game.informPlayers(
           new StringBuilder("Realmwright: ")
               .append(" Chosen basic land type is ")
               .append(choices.getChoice())
               .toString());
       game.getState()
           .setValue(source.getSourceId().toString() + "_Realmwright", choices.getChoice());
       return true;
     }
   }
   return false;
 }
コード例 #3
0
ファイル: CarpetOfFlowers.java プロジェクト: p3trichor/mage
 @Override
 public boolean apply(Game game, Ability source) {
   ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
   Player player = game.getPlayer(source.getControllerId());
   if (player != null) {
     int countMax =
         game.getBattlefield()
             .count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
     ChoiceImpl choiceCount = new ChoiceImpl(true);
     LinkedHashSet<String> set = new LinkedHashSet<String>();
     for (int i = 0; i <= countMax; i++) {
       set.add(Integer.toString(i));
     }
     choiceCount.setChoices(set);
     choiceCount.setMessage("Choose number of mana");
     player.choose(Outcome.PutManaInPool, choiceCount, game);
     int count = Integer.parseInt(choiceCount.getChoice());
     if (choice.getColor().isBlack()) {
       player.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0), game, source);
       return true;
     } else if (choice.getColor().isBlue()) {
       player.getManaPool().addMana(new Mana(0, 0, count, 0, 0, 0, 0), game, source);
       return true;
     } else if (choice.getColor().isRed()) {
       player.getManaPool().addMana(new Mana(count, 0, 0, 0, 0, 0, 0), game, source);
       return true;
     } else if (choice.getColor().isGreen()) {
       player.getManaPool().addMana(new Mana(0, count, 0, 0, 0, 0, 0), game, source);
       return true;
     } else if (choice.getColor().isWhite()) {
       player.getManaPool().addMana(new Mana(0, 0, 0, count, 0, 0, 0), game, source);
       return true;
     }
   }
   return false;
 }
コード例 #4
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   MageObject sourceObject = source.getSourceObject(game);
   if (sourceObject != null && controller != null) {
     ChoiceImpl choices = new ChoiceImpl(true);
     choices.setMessage("Choose token type");
     choices.getChoices().add("White Citizen");
     choices.getChoices().add("Blue Camarid");
     choices.getChoices().add("Black Thrull");
     choices.getChoices().add("Red Goblin");
     choices.getChoices().add("Green Saproling");
     if (controller.choose(Outcome.Neutral, choices, game)) {
       game.informPlayers(
           sourceObject.getLogName() + ": chosen token type is " + choices.getChoice());
       game.getState()
           .setValue(
               source.getSourceId().toString() + "_SarpadianEmpiresVolVii", choices.getChoice());
       return true;
     }
   }
   return false;
 }