@Override
 public boolean apply(Game game, Ability source) {
   ExileZone exile = game.getExile().getExileZone(exileId);
   Player controller = game.getPlayer(source.getControllerId());
   if (controller != null && exile != null) {
     if (zone == Zone.GRAVEYARD) {
       controller.moveCards(exile, zone, Zone.EXILED, source, game);
     } else {
       exile = exile.copy();
       for (UUID cardId : exile) {
         Card card = game.getCard(cardId);
         Player owner = game.getPlayer(card.getOwnerId());
         if (owner != null) {
           switch (zone) {
             case BATTLEFIELD:
               card.moveToZone(zone, source.getSourceId(), game, tapped);
               if (!game.isSimulation()) {
                 game.informPlayers(
                     controller.getLogName()
                         + " moves "
                         + card.getLogName()
                         + " to "
                         + zone.toString().toLowerCase());
               }
               break;
             case HAND:
               controller.moveCards(card, Zone.EXILED, Zone.HAND, source, game);
               break;
             case LIBRARY:
               controller.moveCardToLibraryWithInfo(
                   card, source.getSourceId(), game, Zone.EXILED, true, true);
               break;
             case GRAVEYARD:
               controller.moveCards(card, Zone.EXILED, Zone.GRAVEYARD, source, game);
               break;
             default:
               card.moveToZone(zone, source.getSourceId(), game, tapped);
               if (!game.isSimulation()) {
                 game.informPlayers(
                     controller.getLogName()
                         + " moves "
                         + card.getLogName()
                         + " to "
                         + zone.toString().toLowerCase());
               }
           }
         }
       }
       game.getExile().getExileZone(exileId).clear();
     }
     return true;
   }
   return false;
 }
Exemple #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.getLibrary().size() > 0) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card == null) {
          return false;
        }
        controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
        if (card.getCardType().contains(CardType.CREATURE)) {
          FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
          boolean found = false;
          for (Permanent permanent :
              game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
            if (CardUtil.shareSubtypes(card, permanent, game)) {
              found = true;
              break;
            }
          }
          if (found) {
            game.informPlayers(
                sourceObject.getLogName()
                    + ": Found a creature that shares a creature type with the revealed card.");
            if (controller.chooseUse(Outcome.Benefit, "Cast the card?", source, game)) {
              controller.cast(card.getSpellAbility(), game, true);
            } else {
              game.informPlayers(
                  sourceObject.getLogName()
                      + ": "
                      + controller.getLogName()
                      + " canceled casting the card.");
              controller.getLibrary().putOnBottom(card, game);
            }
          } else {
            game.informPlayers(
                sourceObject.getLogName()
                    + ": No creature that shares a creature type with the revealed card.");
            controller.getLibrary().putOnBottom(card, game);
          }
        } else {
          game.informPlayers(
              sourceObject.getLogName() + ": Put " + card.getLogName() + " on the bottom.");
          controller.getLibrary().putOnBottom(card, game);
        }

        return true;
      }
    }
    return false;
  }
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   if (controller != null) {
     Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
     if (card != null) {
       if (controller.chooseUse(outcome, "Cast " + card.getLogName() + "?", source, game)) {
         if (controller.cast(card.getSpellAbility(), game, true)) {
           ContinuousEffect effect = new TorrentialGearhulkReplacementEffect(card.getId());
           effect.setTargetPointer(
               new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
           game.addEffect(effect, source);
         }
       }
     }
     return true;
   }
   return false;
 }
Exemple #4
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   Card molten = game.getCard(source.getSourceId());
   if (controller != null) {
     ElementalToken token = new ElementalToken();
     token.putOntoBattlefield(2, game, source.getSourceId(), source.getControllerId());
     if (controller.flipCoin(game)) {
       molten.moveToZone(Zone.HAND, source.getSourceId(), game, true);
       game.informPlayers(
           controller.getLogName()
               + " won the flip.  "
               + molten.getLogName()
               + " is returned to "
               + controller.getLogName()
               + "'s hand.");
     }
     return true;
   }
   return false;
 }