Пример #1
0
 @Override
 public boolean apply(Game game, Ability source) {
   boolean result = false;
   Player graveyardPlayer = null;
   for (UUID cardInGraveyard : targetPointer.getTargets(game, source)) {
     Card card = game.getCard(cardInGraveyard);
     if (card != null) {
       for (Player player : game.getPlayers().values()) {
         if (player.getGraveyard().contains(card.getId())) {
           graveyardPlayer = player;
           player.getGraveyard().remove(card);
           result |= card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
         }
       }
     }
   }
   Card card = game.getCard(source.getSourceId());
   result |= card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
   Player player = game.getPlayer(card.getOwnerId());
   if (player != null) {
     player.shuffleLibrary(game);
   }
   if (graveyardPlayer != null && !graveyardPlayer.equals(player)) {
     graveyardPlayer.shuffleLibrary(game);
   }
   return result;
 }
Пример #2
0
 @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;
 }
Пример #3
0
 @Override
 public boolean applies(UUID sourceId, Ability source, Game game) {
   Card card = game.getCard(sourceId);
   if (card != null) {
     if (card.getCardType().contains(CardType.SORCERY)
         && card.getOwnerId().equals(source.getControllerId())) {
       return true;
     }
   }
   return false;
 }
Пример #4
0
 @Override
 public boolean apply(Game game, Ability source) {
   Card card = game.getCard(targetPointer.getFirst(game, source));
   if (card != null) {
     Player player = game.getPlayer(card.getOwnerId());
     if (player != null) {
       if (player.getGraveyard().size() == 0) {
         return new FlipSourceEffect(new NighteyesTheDesecratorToken()).apply(game, source);
       }
     }
   }
   return false;
 }
Пример #5
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
   if (zEvent.getFromZone().equals(Zone.GRAVEYARD)) {
     Card card = game.getCard(zEvent.getTargetId());
     Player controller = game.getPlayer(getControllerId());
     return card != null
         && card.getCardType().contains(CardType.CREATURE)
         && controller != null
         && controller.hasOpponent(card.getOwnerId(), game);
   }
   return false;
 }
Пример #6
0
 @Override
 public boolean apply(Game game, Ability source) {
   Card card = game.getCard(targetPointer.getFirst(game, source));
   if (card != null) {
     // remove exiting suspend counters
     card.getCounters(game).clear();
     // move to exile
     card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
     game.getPlayer(card.getOwnerId()).shuffleLibrary(source, game);
     game.informPlayers(
         new StringBuilder("Riftsweeper: Choosen card was ").append(card.getName()).toString());
     return true;
   }
   return false;
 }
Пример #7
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   if (controller != null) {
     Card card = game.getCard(source.getSourceId());
     if (card != null) {
       Player owner = game.getPlayer(card.getOwnerId());
       if (owner != null && owner.getGraveyard().contains(card.getId())) {
         controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, true, false, null);
       }
     }
     return true;
   }
   return false;
 }
Пример #8
0
 public void addCard(Card card) {
   setZone(card.getId(), Zone.OUTSIDE);
   for (Watcher watcher : card.getWatchers()) {
     watcher.setControllerId(card.getOwnerId());
     watcher.setSourceId(card.getId());
     watchers.add(watcher);
   }
   for (Ability ability : card.getAbilities()) {
     addAbility(ability, card);
   }
   if (card.isSplitCard()) {
     addCard(((SplitCard) card).getLeftHalfCard());
     addCard(((SplitCard) card).getRightHalfCard());
   }
 }
Пример #9
0
 @Override
 public boolean apply(Game game, Ability source) {
   Card card = game.getCard(source.getSourceId());
   if (card != null) {
     ExileZone currentZone = game.getState().getExile().getExileZone(source.getSourceId());
     // return it only from the own exile zone
     if (currentZone != null && currentZone.size() > 0) {
       Player owner = game.getPlayer(card.getOwnerId());
       if (owner != null && owner.moveCards(card, Zone.BATTLEFIELD, source, game)) {
         return true;
       }
     }
   }
   return false;
 }
Пример #10
0
 @Override
 public boolean apply(Game game, Ability source) {
   UUID exileId = source.getSourceId();
   ExileZone exile = game.getExile().getExileZone(exileId);
   if (exile != null) {
     exile = exile.copy();
     for (UUID cardId : exile) {
       Card card = game.getCard(cardId);
       card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), card.getOwnerId());
     }
     game.getExile().getExileZone(exileId).clear();
     return true;
   }
   return false;
 }
Пример #11
0
 @Override
 public boolean apply(Game game, Ability source) {
   Card card = game.getCard(source.getSourceId());
   if (card != null) {
     Player player = game.getPlayer(card.getOwnerId());
     if (player != null) {
       Cards cards = new CardsImpl();
       cards.add(card);
       player.revealCards("Progenitus", cards, game);
       card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
       player.shuffleLibrary(game);
       return true;
     }
   }
   return false;
 }
Пример #12
0
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
   if (zEvent.getToZone().equals(Zone.GRAVEYARD)) {
     Card card = game.getCard(event.getTargetId());
     if (card != null) {
       Permanent enchantment = game.getPermanent(source.getSourceId());
       if (enchantment != null
           && enchantment.getAttachedTo() != null
           && card.getOwnerId().equals(enchantment.getAttachedTo())) {
         return true;
       }
     }
   }
   return false;
 }
Пример #13
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;
  }
Пример #14
0
 @Override
 public boolean apply(Game game, Ability source) {
   FaithsRewardWatcher watcher =
       (FaithsRewardWatcher) game.getState().getWatchers().get("FaithsRewardWatcher");
   if (watcher != null) {
     for (UUID id : watcher.cards) {
       Card c = game.getCard(id);
       if (c != null
           && c.getOwnerId().equals(source.getControllerId())
           && game.getState().getZone(id) == Constants.Zone.GRAVEYARD) {
         c.moveToZone(Constants.Zone.BATTLEFIELD, source.getSourceId(), game, false);
       }
     }
     return true;
   }
   return false;
 }
 @Override
 public boolean apply(Game game, Ability source) {
   Card sourceCard = game.getCard(source.getSourceId());
   MageObject sourceObject = game.getObject(source.getSourceId());
   if (sourceCard != null) {
     Player player = game.getPlayer(sourceCard.getOwnerId());
     if (player != null) {
       Zone fromZone = game.getState().getZone(sourceCard.getId());
       Cards cards = new CardsImpl();
       cards.add(sourceCard);
       player.revealCards(sourceObject.getLogName(), cards, game);
       player.moveCardToLibraryWithInfo(
           sourceCard, source.getSourceId(), game, fromZone, true, true);
       player.shuffleLibrary(game);
       return true;
     }
   }
   return false;
 }
Пример #16
0
 @Override
 public UUID getOwnerId() {
   return card.getOwnerId();
 }
Пример #17
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   if (controller != null) {
     List<Card> cards = new ArrayList<>();
     List<Permanent> permanents = new ArrayList<>();
     for (UUID targetId : targetPointer.getTargets(game, source)) {
       switch (game.getState().getZone(targetId)) {
         case BATTLEFIELD:
           Permanent permanent = game.getPermanent(targetId);
           if (permanent != null) {
             permanents.add(permanent);
           }
           break;
         case GRAVEYARD:
           Card card = game.getCard(targetId);
           if (card != null && game.getState().getZone(targetId).equals(Zone.GRAVEYARD)) {
             cards.add(card);
           }
           break;
       }
     }
     // Plow Under
     // 10/4/2004 	The owner decides the order the two lands are stacked there.
     while (!cards.isEmpty()) {
       Card card = cards.iterator().next();
       if (card != null) {
         Player owner = game.getPlayer(card.getOwnerId());
         Cards cardsPlayer = new CardsImpl();
         for (Iterator<Card> iterator = cards.iterator(); iterator.hasNext(); ) {
           Card next = iterator.next();
           if (next.getOwnerId().equals(owner.getId())) {
             cardsPlayer.add(next);
             iterator.remove();
           }
         }
         if (onTop) {
           owner.putCardsOnTopOfLibrary(cardsPlayer, game, source, true);
         } else {
           owner.putCardsOnBottomOfLibrary(cardsPlayer, game, source, true);
         }
       }
     }
     while (!permanents.isEmpty()) {
       Permanent permanent = permanents.iterator().next();
       if (permanent != null) {
         Player owner = game.getPlayer(permanent.getOwnerId());
         Cards cardsPlayer = new CardsImpl();
         for (Iterator<Permanent> iterator = permanents.iterator(); iterator.hasNext(); ) {
           Permanent next = iterator.next();
           if (next.getOwnerId().equals(owner.getId())) {
             cardsPlayer.add(next);
             iterator.remove();
           }
         }
         if (onTop) {
           owner.putCardsOnTopOfLibrary(cardsPlayer, game, source, true);
         } else {
           owner.putCardsOnBottomOfLibrary(cardsPlayer, game, source, true);
         }
       }
     }
     return true;
   }
   return false;
 }
Пример #18
0
  @Override
  public boolean apply(Game game, Ability source) {
    Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
    Permanent eyeOfTheStorm = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (spell != null && eyeOfTheStorm != null) {
      Player spellController = game.getPlayer(spell.getControllerId());
      Card card = spell.getCard();
      if (spellController == null || card == null || !instantOrSorceryfilter.match(card, game)) {
        return false;
      }

      UUID exileZoneId =
          CardUtil.getExileZoneId(
              game, source.getSourceId(), eyeOfTheStorm.getZoneChangeCounter(game));
      if (spellController.moveCardsToExile(
          spell, source, game, true, exileZoneId, eyeOfTheStorm.getIdName())) {
        eyeOfTheStorm.imprint(card.getId(), game);

        if (eyeOfTheStorm.getImprinted() != null && eyeOfTheStorm.getImprinted().size() > 0) {
          CardsImpl copiedCards = new CardsImpl();
          for (UUID uuid : eyeOfTheStorm.getImprinted()) {
            card = game.getCard(uuid);

            // Check if owner of card is still in game
            if (card != null && game.getPlayer(card.getOwnerId()) != null) {
              if (card.isSplitCard()) {
                copiedCards.add(((SplitCard) card).getLeftHalfCard());
                copiedCards.add(((SplitCard) card).getRightHalfCard());
              } else {
                copiedCards.add(card);
              }
            }
          }

          boolean continueCasting = true;
          while (continueCasting) {
            continueCasting =
                copiedCards.size() > 1
                    && spellController.chooseUse(
                        outcome,
                        "Cast one of the copied cards without paying its mana cost?",
                        source,
                        game);

            Card cardToCopy;
            if (copiedCards.size() == 1) {
              cardToCopy = copiedCards.getCards(game).iterator().next();
            } else {
              TargetCard target = new TargetCard(1, Zone.EXILED, new FilterCard("card to copy"));
              spellController.choose(Outcome.Copy, copiedCards, target, game);
              cardToCopy = copiedCards.get(target.getFirstTarget(), game);
              copiedCards.remove(cardToCopy);
            }
            if (cardToCopy != null) {
              Card copy = game.copyCard(cardToCopy, source, source.getControllerId());
              if (spellController.chooseUse(
                  outcome, "Cast the copied card without paying mana cost?", source, game)) {
                spellController.cast(copy.getSpellAbility(), game, true);
              }
            }
          }
          return true;
        }
      }
    }
    return false;
  }