コード例 #1
0
ファイル: RandomPlayer.java プロジェクト: kholdfuzion/mage
 @Override
 public boolean choose(Outcome outcome, Choice choice, Game game) {
   Iterator<String> it = choice.getChoices().iterator();
   String sChoice = it.next();
   int choiceNum = rnd.nextInt(choice.getChoices().size());
   for (int i = 0; i < choiceNum; i++) {
     sChoice = it.next();
   }
   choice.setChoice(sChoice);
   return true;
 }
コード例 #2
0
ファイル: PrimalPlasma.java プロジェクト: nigelzor/mage
    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
      Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
      if (permanent != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose what " + permanent.getIdName() + " becomes to");
        choice.getChoices().add(choice33);
        choice.getChoices().add(choice22);
        choice.getChoices().add(choice16);
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
          while (!choice.isChosen()) {
            controller.choose(Outcome.Neutral, choice, game);
            if (!controller.canRespond()) {
              return false;
            }
          }
        }
        int power = 0;
        int toughness = 0;
        switch (choice.getChoice()) {
          case choice33:
            power = 3;
            toughness = 3;
            break;
          case choice22:
            power = 2;
            toughness = 2;
            game.addEffect(
                new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.Custom), source);
            break;
          case choice16:
            power = 1;
            toughness = 6;
            game.addEffect(
                new GainAbilitySourceEffect(DefenderAbility.getInstance(), Duration.Custom),
                source);
            break;
        }
        permanent.getPower().modifyBaseValue(power);
        permanent.getToughness().modifyBaseValue(toughness);
        // game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom,
        // SubLayer.SetPT_7b), source);

      }
      return false;
    }
コード例 #3
0
ファイル: ChromeMox.java プロジェクト: rudyards/mage
  @java.lang.Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (permanent != null && player != null) {
      List<UUID> imprinted = permanent.getImprinted();
      if (imprinted.size() > 0) {
        Card imprintedCard = game.getCard(imprinted.get(0));
        if (imprintedCard != null) {
          Choice choice = new ChoiceImpl(true);
          choice.setMessage("Pick a mana color");
          ObjectColor color = imprintedCard.getColor(game);
          if (color.isBlack()) {
            choice.getChoices().add("Black");
          }
          if (color.isRed()) {
            choice.getChoices().add("Red");
          }
          if (color.isBlue()) {
            choice.getChoices().add("Blue");
          }
          if (color.isGreen()) {
            choice.getChoices().add("Green");
          }
          if (color.isWhite()) {
            choice.getChoices().add("White");
          }

          if (choice.getChoices().size() > 0) {
            Mana mana = new Mana();
            if (choice.getChoices().size() == 1) {
              choice.setChoice(choice.getChoices().iterator().next());
            } else {
              player.choose(outcome, choice, game);
            }
            if (choice.getChoice().equals("Black")) {
              player.getManaPool().addMana(Mana.BlackMana, game, source);
            } else if (choice.getChoice().equals("Blue")) {
              player.getManaPool().addMana(Mana.BlueMana, game, source);
            } else if (choice.getChoice().equals("Red")) {
              player.getManaPool().addMana(Mana.RedMana, game, source);
            } else if (choice.getChoice().equals("Green")) {
              player.getManaPool().addMana(Mana.GreenMana, game, source);
            } else if (choice.getChoice().equals("White")) {
              player.getManaPool().addMana(Mana.WhiteMana, game, source);
            } else if (choice.getChoice().equals("Colorless")) {
              player.getManaPool().addMana(Mana.ColorlessMana, game, source);
            }
            checkToFirePossibleEvents(mana, game, source);
            player.getManaPool().addMana(mana, game, source);
          }
        }
      }
    }
    return true;
  }
コード例 #4
0
ファイル: ConvokeAbility.java プロジェクト: bradens/mage
 private Choice buildChoice(ManaCosts manaCosts, ManaCosts manaCostsSpell) {
   Choice choice = new ChoiceImpl();
   String creatureCosts = manaCosts.getText();
   String spellCosts = manaCostsSpell.getText();
   if (creatureCosts.contains("B") && spellCosts.contains("B")) {
     choice.getChoices().add("Black");
   }
   if (creatureCosts.contains("U") && spellCosts.contains("U")) {
     choice.getChoices().add("Blue");
   }
   if (creatureCosts.contains("G") && spellCosts.contains("G")) {
     choice.getChoices().add("Green");
   }
   if (creatureCosts.contains("R") && spellCosts.contains("R")) {
     choice.getChoices().add("Red");
   }
   if (creatureCosts.contains("W") && spellCosts.contains("W")) {
     choice.getChoices().add("White");
   }
   return choice;
 }
コード例 #5
0
ファイル: ConvokeAbility.java プロジェクト: bradens/mage
  @Override
  public void adjustCosts(Ability ability, Game game) {
    Player player = game.getPlayer(controllerId);
    if (player == null || !(ability instanceof SpellAbility)) {
      return;
    }
    Target target = new TargetControlledCreaturePermanent(1, Integer.MAX_VALUE, filter, true);
    target.setTargetName("creatures to convoke");
    if (!target.canChoose(sourceId, controllerId, game)) {
      return;
    }
    if (player.chooseUse(Outcome.Detriment, "Convoke creatures?", game)) {
      player.chooseTarget(Outcome.Tap, target, ability, game);
      if (target.getTargets().size() > 0) {
        int adjCost = 0;
        for (UUID creatureId : target.getTargets()) {
          Permanent perm = game.getPermanent(creatureId);
          if (perm == null) {
            continue;
          }
          ManaCosts manaCostsCreature = perm.getSpellAbility().getManaCosts();
          if (manaCostsCreature != null
              && manaCostsCreature.convertedManaCost() > 0
              && perm.tap(game)) {
            Choice chooseManaType = buildChoice(manaCostsCreature, ability.getManaCostsToPay());
            if (chooseManaType.getChoices().size() > 0) {
              if (chooseManaType.getChoices().size() > 1) {
                chooseManaType.getChoices().add("Colorless");
                chooseManaType.setMessage("Choose mana color to reduce from " + perm.getName());
                while (!chooseManaType.isChosen()) {
                  player.choose(Outcome.Benefit, chooseManaType, game);
                }
              } else {
                chooseManaType.setChoice(chooseManaType.getChoices().iterator().next());
              }

              ManaCosts manaCostsToReduce = new ManaCostsImpl();
              if (chooseManaType.getChoice().equals("Black")) {
                manaCostsToReduce.load("{B}");
              }
              if (chooseManaType.getChoice().equals("Blue")) {
                manaCostsToReduce.load("{U}");
              }
              if (chooseManaType.getChoice().equals("Green")) {
                manaCostsToReduce.load("{G}");
              }
              if (chooseManaType.getChoice().equals("White")) {
                manaCostsToReduce.load("{W}");
              }
              if (chooseManaType.getChoice().equals("Red")) {
                manaCostsToReduce.load("{R}");
              }
              if (chooseManaType.getChoice().equals("Colorless")) {
                ++adjCost;
              }
              CardUtil.adjustCost((SpellAbility) ability, manaCostsToReduce);
            } else {
              ++adjCost;
            }
          }
        }
        this.getTargets().add(target);
        CardUtil.adjustCost((SpellAbility) ability, adjCost);
      }
    }
  }
コード例 #6
0
ファイル: FactOrFiction.java プロジェクト: xdaft/mage
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }

    Cards cards = new CardsImpl(Zone.PICK);
    int count = Math.min(player.getLibrary().size(), 5);
    for (int i = 0; i < count; i++) {
      Card card = player.getLibrary().removeFromTop(game);
      if (card != null) {
        cards.add(card);
        game.setZone(card.getId(), Zone.PICK);
      }
    }
    player.revealCards("Fact or Fiction", cards, game);

    Set<UUID> opponents = game.getOpponents(source.getControllerId());
    if (!opponents.isEmpty()) {
      Player opponent = game.getPlayer(opponents.iterator().next());
      TargetCard target =
          new TargetCard(
              0, cards.size(), Zone.PICK, new FilterCard("cards to put in the first pile"));

      Cards pile1 = new CardsImpl();
      if (opponent.choose(Outcome.Neutral, cards, target, game)) {
        List<UUID> targets = target.getTargets();
        for (UUID targetId : targets) {
          Card card = cards.get(targetId, game);
          if (card != null) {
            pile1.add(card);
            cards.remove(card);
          }
        }
      }

      player.revealCards("Pile 1 (Fact or Fiction)", pile1, game);
      player.revealCards("Pile 2 (Fact or Fiction)", cards, game);

      Choice choice = new ChoiceImpl(true);
      choice.setMessage("Select a pile of cards to put into your hand:");

      StringBuilder sb = new StringBuilder("Pile 1: ");
      for (UUID cardId : pile1) {
        Card card = pile1.get(cardId, game);
        if (card != null) {
          sb.append(card.getName()).append("; ");
        }
      }
      sb.delete(sb.length() - 2, sb.length());
      choice.getChoices().add(sb.toString());

      sb = new StringBuilder("Pile 2: ");
      for (UUID cardId : cards) {
        Card card = cards.get(cardId, game);
        if (card != null) {
          sb.append(card.getName()).append("; ");
        }
      }
      sb.delete(sb.length() - 2, sb.length());
      choice.getChoices().add(sb.toString());

      Zone pile1Zone = Zone.GRAVEYARD;
      Zone pile2Zone = Zone.HAND;
      if (player.choose(Outcome.Neutral, choice, game)) {
        if (choice.getChoice().startsWith("Pile 1")) {
          pile1Zone = Zone.HAND;
          pile2Zone = Zone.GRAVEYARD;
        }
      }

      for (UUID cardUuid : pile1) {
        Card card = pile1.get(cardUuid, game);
        if (card != null) {
          card.moveToZone(pile1Zone, source.getId(), game, false);
        }
      }
      for (UUID cardUuid : cards) {
        Card card = cards.get(cardUuid, game);
        if (card != null) {
          card.moveToZone(pile2Zone, source.getId(), game, false);
        }
      }
    }

    return true;
  }
コード例 #7
0
 @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;
 }