Ejemplo n.º 1
0
 @Override
 protected void init(UUID choosingPlayerId) {
   Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
   // Move commander to command zone
   for (UUID playerId : state.getPlayerList(startingPlayerId)) {
     Player player = getPlayer(playerId);
     if (player != null) {
       if (player.getSideboard().size() > 0) {
         Card commander = getCard((UUID) player.getSideboard().toArray()[0]);
         if (commander != null) {
           player.setCommanderId(commander.getId());
           commander.moveToZone(Zone.COMMAND, null, this, true);
           commander.getAbilities().setControllerId(player.getId());
           ability.addEffect(
               new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary));
           ability.addEffect(new CommanderCostModification(commander.getId()));
           ability.addEffect(
               new CommanderManaReplacementEffect(
                   player.getId(), CardUtil.getColorIdentity(commander)));
           getState().setValue(commander.getId() + "_castCount", 0);
           CommanderInfoWatcher watcher =
               new CommanderInfoWatcher(commander.getId(), CHECK_COMMANDER_DAMAGE);
           getState().getWatchers().add(watcher);
           watcher.addCardInfoToCommander(this);
         }
       }
     }
   }
   this.getState().addAbility(ability, null);
   super.init(choosingPlayerId);
   if (startingPlayerSkipsDraw) {
     state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW));
   }
 }
Ejemplo n.º 2
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
      if (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) {
        Set<Card> sideboard = controller.getSideboard().getCards(filter, game);
        List<Card> exile = game.getExile().getAllCards(game);
        Cards filteredCards = new CardsImpl();
        Card card = null;

        for (Card sideboardCard : sideboard) {
          filteredCards.add(sideboardCard.getId());
        }
        for (Card exileCard : exile) {
          if (exileCard.getOwnerId().equals(source.getControllerId())
              && exileCard.hasSubtype("Eldrazi")) {
            filteredCards.add(exileCard);
          }
        }

        if (filteredCards.isEmpty()) {
          game.informPlayer(
              controller,
              "You have no "
                  + filter.getMessage()
                  + " outside the game (your sideboard) or in exile.");
        } else {
          TargetCard target = new TargetCard(Zone.OUTSIDE, filter);
          target.setNotTarget(true);
          if (controller.choose(outcome, filteredCards, target, game)) {
            card = controller.getSideboard().get(target.getFirstTarget(), game);
            if (card == null) {
              card = game.getCard(target.getFirstTarget());
            }
          }
        }

        if (card != null) {
          card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
          controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
        }
      }
      return true;
    }
    return false;
  }