@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));
   }
 }
  @Override
  public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card != null) {
      PutTokenOntoBattlefieldCopyTargetEffect effect =
          new PutTokenOntoBattlefieldCopyTargetEffect(
              source.getControllerId(), CardType.ARTIFACT, true);
      effect.setTargetPointer(
          new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
      effect.apply(game, source);
      for (Permanent addedToken : effect.getAddedPermanent()) {
        SacrificeTargetEffect sacrificeEffect =
            new SacrificeTargetEffect(
                "Sacrifice the token at the beginning of the next end step",
                source.getControllerId());
        sacrificeEffect.setTargetPointer(new FixedTarget(addedToken, game));
        DelayedTriggeredAbility delayedAbility =
            new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
        game.addDelayedTriggeredAbility(delayedAbility, source);
      }
      return true;
    }

    return false;
  }
Beispiel #3
0
 public SimpleCardsView(Collection<Card> cards) {
   for (Card card : cards) {
     this.put(
         card.getId(),
         new SimpleCardView(
             card.getId(),
             card.getExpansionSetCode(),
             card.getCardNumber(),
             card.isFaceDown(),
             card.getUsesVariousArt()));
   }
 }
Beispiel #4
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());
   }
 }
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   MageObject sourceObject = source.getSourceObject(game);
   if (controller != null && sourceObject != null) {
     Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
     UUID exileId =
         CardUtil.getExileZoneId(
             game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
     if (permanent != null) {
       return controller.moveCardToExileWithInfo(
           permanent,
           exileId,
           sourceObject.getIdName(),
           source.getSourceId(),
           game,
           Zone.BATTLEFIELD,
           true);
     } else {
       Card card = game.getCard(getTargetPointer().getFirst(game, source));
       if (card != null) {
         return controller.moveCardToExileWithInfo(
             card,
             exileId,
             sourceObject.getIdName(),
             source.getSourceId(),
             game,
             game.getState().getZone(card.getId()),
             true);
       }
     }
   }
   return false;
 }
Beispiel #6
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) {
     controller.shuffleLibrary(source, game);
     if (controller.getLibrary().size() > 0) {
       Card card = controller.getLibrary().removeFromTop(game);
       if (card != null) {
         controller.moveCardToExileWithInfo(
             card,
             source.getSourceId(),
             sourceObject.getIdName(),
             source.getSourceId(),
             game,
             Zone.LIBRARY,
             true);
         ContinuousEffect effect = new MindsDesireCastFromExileEffect();
         effect.setTargetPointer(new FixedTarget(card.getId()));
         game.addEffect(effect, source);
       }
     }
     return true;
   }
   return false;
 }
Beispiel #7
0
 private void updateLatestCardView(Game game, Card card, UUID stackId) {
   if (!card.canTransform()) {
     return;
   }
   Permanent permanent = game.getPermanent(card.getId());
   if (permanent == null) {
     permanent =
         (Permanent) game.getLastKnownInformation(card.getId(), Constants.Zone.BATTLEFIELD);
   }
   if (permanent != null) {
     if (permanent.isTransformed()) {
       StackAbilityView stackAbilityView = (StackAbilityView) stack.get(stackId);
       stackAbilityView.getSourceCard().setTransformed(true);
     }
   }
 }
 @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;
 }
Beispiel #9
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      Player damagedPlayer = game.getPlayer(targetPointer.getFirst(game, source));
      if (damagedPlayer == null) {
        return false;
      }
      FilterCard filter =
          new FilterCard(
              "target instant or sorcery card from " + damagedPlayer.getName() + "'s graveyard");
      filter.add(new OwnerIdPredicate(damagedPlayer.getId()));
      filter.add(
          Predicates.or(
              new CardTypePredicate(CardType.INSTANT), new CardTypePredicate(CardType.SORCERY)));

      Target target = new TargetCardInGraveyard(filter);
      if (controller.chooseTarget(Outcome.PlayForFree, target, source, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
          controller.cast(card.getSpellAbility(), game, true);
          game.addEffect(new WrexialReplacementEffect(card.getId()), source);
        }
      }
      return true;
    }
    return false;
  }
Beispiel #10
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   Permanent permanent = (Permanent) game.getLastKnownInformation(target, Zone.BATTLEFIELD);
   if (permanent != null && controller != null) {
     Player player = game.getPlayer(permanent.getOwnerId());
     if (player != null) {
       FilterCreatureCard filter =
           new FilterCreatureCard(
               new StringBuilder("a creature card from ")
                   .append(player.getLogName())
                   .append("'s graveyard")
                   .toString());
       filter.add(new OwnerIdPredicate(player.getId()));
       Target targetCreature = new TargetCardInGraveyard(filter);
       if (targetCreature.canChoose(source.getSourceId(), controller.getId(), game)
           && controller.chooseTarget(outcome, targetCreature, source, game)) {
         Card card = game.getCard(targetCreature.getFirstTarget());
         if (card != null && game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
           return card.putOntoBattlefield(
               game, Zone.GRAVEYARD, source.getSourceId(), player.getId());
         }
       }
       return true;
     }
   }
   return false;
 }
Beispiel #11
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }

    Card card = player.getLibrary().getFromTop(game);
    if (card != null) {
      Cards cards = new CardsImpl();
      cards.add(card);
      player.lookAtCards("Explorer's Scope", cards, game);
      if (card.getCardType().contains(CardType.LAND)) {
        String message = "Put " + card.getName() + " onto the battlefield tapped?";
        if (player.chooseUse(Outcome.PutLandInPlay, message, game)) {
          if (card.putOntoBattlefield(
              game, Zone.LIBRARY, source.getId(), source.getControllerId())) {
            Permanent permanent = game.getPermanent(card.getId());
            if (permanent != null) {
              permanent.setTapped(true);
            }
          }
        }
      }
    }
    return true;
  }
Beispiel #12
0
 @Override
 public boolean chooseTarget(
     Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
   if (cards.isEmpty()) return !target.isRequired();
   Card card = cards.getRandom(game);
   target.addTarget(card.getId(), source, game);
   return true;
 }
Beispiel #13
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Cards cards = new CardsImpl(Zone.PICK);
    int count = Math.min(player.getLibrary().size(), 4);
    for (int i = 0; i < count; i++) {
      Card card = player.getLibrary().removeFromTop(game);
      cards.add(card);
      game.setZone(card.getId(), Zone.PICK);
    }

    if (cards.size() == 0) {
      return false;
    }
    TargetCard target1 = new TargetCard(Zone.PICK, filter1);
    if (player.choose(Outcome.Detriment, cards, target1, game)) {
      Card card = cards.get(target1.getFirstTarget(), game);
      if (card != null) {
        cards.remove(card);
        card.moveToExile(getId(), "Clone Shell (Imprint)", source.getSourceId(), game);
        card.setFaceDown(true, game);
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (permanent != null) {
          permanent.imprint(card.getId(), game);
        }
      }
      target1.clearChosen();
    }

    if (cards.size() > 0) {
      TargetCard target2 = new TargetCard(Zone.PICK, filter2);
      while (player.canRespond() && cards.size() > 1) {
        player.choose(Outcome.Benefit, cards, target2, game);
        Card card = cards.get(target2.getFirstTarget(), game);
        if (card != null) {
          cards.remove(card);
          card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
        }
        target2.clearChosen();
      }
      Card card = cards.get(cards.iterator().next(), game);
      card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
    }

    return true;
  }
Beispiel #14
0
  Cards ProteanHulkSearch(Game game, Ability source) {
    Cards cardsPicked = new CardsImpl(Zone.PICK);
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
      GameEvent event =
          GameEvent.getEvent(
              GameEvent.EventType.SEARCH_LIBRARY,
              source.getControllerId(),
              source.getControllerId(),
              source.getControllerId(),
              Integer.MAX_VALUE);
      if (!game.replaceEvent(event)) {
        int manaCostLeftToFetch = 6;
        int librarySearchLimit = event.getAmount();

        FilterCard filter =
            new FilterCreatureCard(
                "number of creature cards with total converted mana cost 6 or less (6 CMC left)");
        filter.add(
            new ConvertedManaCostPredicate(ComparisonType.LessThan, manaCostLeftToFetch + 1));
        TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
        target.setCardLimit(librarySearchLimit);

        while (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
          target.choose(
              Outcome.PutCreatureInPlay, source.getControllerId(), source.getControllerId(), game);
          Card card = player.getLibrary().remove(target.getFirstTarget(), game);
          if (card == null) {
            break;
          }
          cardsPicked.add(card);
          game.setZone(card.getId(), Zone.PICK);
          game.getState().getLookedAt(source.getControllerId()).add("Protean Hulk", cardsPicked);

          librarySearchLimit--;
          if (librarySearchLimit == 0) {
            break;
          }
          manaCostLeftToFetch -= card.getManaCost().convertedManaCost();
          filter =
              new FilterCreatureCard(
                  "number of creature cards with total converted mana cost 6 or less ("
                      + manaCostLeftToFetch
                      + " CMC left)");
          filter.add(
              new ConvertedManaCostPredicate(ComparisonType.LessThan, manaCostLeftToFetch + 1));
          target = new TargetCardInLibrary(0, 1, filter);
          target.setCardLimit(librarySearchLimit);
        }
        game.fireEvent(
            GameEvent.getEvent(
                GameEvent.EventType.LIBRARY_SEARCHED,
                source.getControllerId(),
                source.getControllerId()));
      }
    }
    return cardsPicked;
  }
Beispiel #15
0
  @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 = source.getManaCostsToPay().getX();
    count = Math.min(player.getLibrary().size(), count);
    boolean legendaryIncluded = false;
    for (int i = 0; i < count; i++) {
      Card card = player.getLibrary().removeFromTop(game);
      if (card != null) {
        cards.add(card);
        if (filter.match(card, game)) {
          legendaryIncluded = true;
        }
        game.setZone(card.getId(), Zone.PICK);
      }
    }
    player.lookAtCards("Heroes' Podium", cards, game);

    // You may reveal a legendary creature card from among them and put it into your hand.
    if (!cards.isEmpty()
        && legendaryIncluded
        && player.chooseUse(
            outcome, "Put a legendary creature card into your hand?", source, game)) {
      if (cards.size() == 1) {
        Card card = cards.getRandom(game);
        cards.remove(card);
        card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
        return true;
      } else {
        TargetCard target = new TargetCard(Zone.PICK, filter);
        if (player.choose(outcome, cards, target, game)) {
          Card card = cards.get(target.getFirstTarget(), game);
          if (card != null) {
            cards.remove(card);
            card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
          }
        }
      }
    }

    // Put the rest on the bottom of your library in a random order
    while (cards.size() > 0) {
      Card card = cards.getRandom(game);
      if (card != null) {
        cards.remove(card);
        card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
      }
    }
    return true;
  }
Beispiel #16
0
 @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;
 }
Beispiel #17
0
 @Override
 public boolean canTarget(UUID id, Ability source, Game game) {
   Card card = game.getCard(id);
   if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
     UUID firstTarget = source.getFirstTarget();
     if (firstTarget != null && game.getPlayer(firstTarget).getGraveyard().contains(id)) {
       return filter.match(card, game);
     }
   }
   return false;
 }
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }

    int cmc = 0;
    for (Cost cost : source.getCosts()) {
      if (cost instanceof PayVariableLoyaltyCost) {
        cmc = ((PayVariableLoyaltyCost) cost).getAmount();
      }
    }

    FilterCard filter =
        new FilterCreatureCard(
            new StringBuilder("creature card with converted mana cost {")
                .append(cmc)
                .append("} exiled with Ashiok, Nightmare Weaver")
                .toString());
    filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, cmc));
    Target target = new TargetCardInExile(filter, CardUtil.getCardExileZoneId(game, source));

    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
      if (player.chooseTarget(Outcome.PutCreatureInPlay, target, source, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null
            && player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId())) {
          Permanent permanent = game.getPermanent(card.getId());
          if (permanent != null) {
            permanent.changeControllerId(source.getControllerId(), game);
          }
          ContinuousEffectImpl effect = new AshiokNightmareWeaverAddTypeEffect();
          effect.setTargetPointer(new FixedTarget(card.getId()));
          game.addEffect(effect, source);
          return true;
        }
      }
    }
    return false;
  }
Beispiel #19
0
 @Override
 public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
   Set<UUID> possibleTargets = new HashSet<UUID>();
   if (allExileZones) {
     for (Card card : game.getExile().getAllCards(game)) {
       if (filter.match(card, sourceControllerId, game)) {
         possibleTargets.add(card.getId());
       }
     }
   } else {
     ExileZone exileZone = game.getExile().getExileZone(zoneId);
     if (exileZone != null) {
       for (Card card : exileZone.getCards(game)) {
         if (filter.match(card, sourceControllerId, game)) {
           possibleTargets.add(card.getId());
         }
       }
     }
   }
   return possibleTargets;
 }
Beispiel #20
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   if (controller != null) {
     UUID targetId = targetPointer.getFirst(game, source);
     StackObject stackObject = game.getStack().getStackObject(targetId);
     if (stackObject != null
         && game.getStack()
             .counter(targetId, source.getSourceId(), game, Zone.EXILED, false, false)) {
       Card card = ((Spell) stackObject).getCard();
       if (card != null) {
         ContinuousEffect effect = new SpelljackCastFromExileEffect();
         effect.setTargetPointer(
             new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
         game.addEffect(effect, source);
       }
     }
     return true;
   }
   return false;
 }
Beispiel #21
0
 @Override
 public boolean replaceEvent(GameEvent event, Ability source, Game game) {
   MageObject object = game.getObject(event.getSourceId());
   if (object != null) {
     Card card = (Card) object;
     Ability ability = new AffinityForArtifactsAbility();
     card.addAbility(ability);
     ability.setControllerId(source.getControllerId());
     ability.setSourceId(card.getId());
     game.getState().addAbility(ability, source.getSourceId(), card);
   }
   return false;
 }
 // TODO implement may look at exile cards
 @Override
 public void mulligan(UUID playerId) {
   Player player = getPlayer(playerId);
   TargetCardInHand target =
       new TargetCardInHand(1, player.getHand().size(), new FilterCard("card to mulligan"));
   target.setNotTarget(true);
   target.setRequired(false);
   if (player.choose(Outcome.Exile, player.getHand(), target, this)) {
     int numCards = target.getTargets().size();
     for (UUID uuid : target.getTargets()) {
       Card card = player.getHand().get(uuid, this);
       if (card != null) {
         if (!mulliganedCards.containsKey(playerId)) {
           mulliganedCards.put(playerId, new CardsImpl());
         }
         player.getHand().remove(card);
         getExile().add(card);
         getState().setZone(card.getId(), Zone.EXILED);
         card.setFaceDown(true, this);
         mulliganedCards.get(playerId).add(card);
       }
     }
     int deduction = 1;
     if (freeMulligans > 0) {
       if (usedFreeMulligans != null && usedFreeMulligans.containsKey(player.getId())) {
         int used = usedFreeMulligans.get(player.getId());
         if (used < freeMulligans) {
           deduction = 0;
           usedFreeMulligans.put(player.getId(), used + 1);
         }
       } else {
         deduction = 0;
         {
         }
         usedFreeMulligans.put(player.getId(), 1);
       }
     }
     player.drawCards(numCards - deduction, this);
     fireInformEvent(
         new StringBuilder(player.getLogName())
             .append(" mulligans ")
             .append(numCards)
             .append(numCards == 1 ? " card" : " cards")
             .append(deduction == 0 ? " for free and draws " : " down to ")
             .append(Integer.toString(player.getHand().size()))
             .append(player.getHand().size() <= 1 ? " card" : " cards")
             .toString());
   }
 }
 @Override
 public boolean apply(Game game, Ability source) {
   Player you = game.getPlayer(source.getControllerId());
   Permanent attackingCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
   if (you != null && attackingCreature != null) {
     FilterCard filter = new FilterCard("aura that could enchant the lone attacking creature");
     filter.add(new SubtypePredicate("Aura"));
     filter.add(new AuraCardCanAttachToPermanentId(attackingCreature.getId()));
     if (you.chooseUse(Outcome.Benefit, "Do you want to search your library?", source, game)) {
       TargetCardInLibrary target = new TargetCardInLibrary(filter);
       target.setNotTarget(true);
       if (you.searchLibrary(target, game)) {
         if (target.getFirstTarget() != null) {
           Card aura = game.getCard(target.getFirstTarget());
           game.getState().setValue("attachTo:" + aura.getId(), attackingCreature);
           aura.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), you.getId());
           return attackingCreature.addAttachment(aura.getId(), game);
         }
       }
     }
     you.shuffleLibrary(game);
   }
   return false;
 }
Beispiel #24
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;
 }
Beispiel #25
0
 @Override
 public boolean apply(Game game, Ability source) {
   Card creatureCard = game.getCard(this.getTargetPointer().getFirst(game, source));
   Player controller = game.getPlayer(source.getControllerId());
   if (creatureCard != null && controller != null) {
     boolean result = false;
     if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) {
       result =
           controller.putOntoBattlefieldWithInfo(
               creatureCard, game, Zone.GRAVEYARD, source.getSourceId());
     }
     controller.loseLife(creatureCard.getManaCost().convertedManaCost(), game);
     return result;
   }
   return false;
 }
  @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;
  }
 @Override
 public void endMulligan(UUID playerId) {
   // return cards to
   Player player = getPlayer(playerId);
   if (player != null && mulliganedCards.containsKey(playerId)) {
     for (Card card : mulliganedCards.get(playerId).getCards(this)) {
       if (card != null) {
         getExile().removeCard(card, this);
         player.getLibrary().putOnTop(card, this);
         getState().setZone(card.getId(), Zone.LIBRARY);
         card.setFaceDown(false, this);
       }
     }
     if (mulliganedCards.get(playerId).size() > 0) {
       player.shuffleLibrary(this);
     }
   }
 }
Beispiel #28
0
 @java.lang.Override
 public boolean apply(Game game, Ability source) {
   Player player = game.getPlayer(source.getControllerId());
   if (player.getHand().size() > 0) {
     TargetCard target = new TargetCard(Zone.HAND, filter);
     player.choose(Outcome.Benefit, player.getHand(), target, game);
     Card card = player.getHand().get(target.getFirstTarget(), game);
     if (card != null) {
       card.moveToExile(getId(), "Chrome Mox (Imprint)", source.getSourceId(), game);
       Permanent permanent = game.getPermanent(source.getSourceId());
       if (permanent != null) {
         permanent.imprint(card.getId(), game);
       }
       return true;
     }
   }
   return true;
 }
 @Override
 public boolean applies(GameEvent event, Ability source, Game game) {
   Card targetCard = game.getCard(event.getTargetId());
   StackObject stackObject = (StackObject) game.getStack().getStackObject(event.getSourceId());
   if (targetCard != null
       && stackObject != null
       && targetCard.getId().equals(source.getSourceId())) {
     if (stackObject.getColor(game).contains(ObjectColor.BLACK)
         || stackObject.getColor(game).contains(ObjectColor.RED)) {
       if (!stackObject.getControllerId().equals(source.getControllerId())
               && stackObject.getCardType().contains(CardType.INSTANT)
           || stackObject.getCardType().contains(CardType.SORCERY)) {
         return true;
       }
     }
   }
   return false;
 }
Beispiel #30
0
  @Override
  public boolean apply(Game game, Ability source) {

    Player player = game.getPlayer(source.getControllerId());

    for (Card card : player.getGraveyard().getCards(filterZombie, game)) {
      card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
      Permanent permanent = game.getPermanent(card.getId());
      if (permanent != null) {
        permanent.setTapped(true);
      }
    }
    for (Permanent permanent :
        game.getBattlefield().getActivePermanents(filterHuman, source.getControllerId(), game)) {
      permanent.destroy(source.getSourceId(), game, false);
    }
    return true;
  }