Beispiel #1
0
 @Override
 public boolean apply(Game game, Ability source) {
   Set<String> targets = new HashSet<>();
   for (UUID target : targetPointer.getTargets(game, source)) {
     Permanent permanent = game.getPermanent(target);
     if (permanent != null) {
       permanent.untap(game);
       targets.add(CardUtil.getCardZoneString("", permanent.getId(), game));
     }
   }
   if (!targets.isEmpty()) {
     // save the targets for the watcher in a map with zone change counter (as the card is recast
     // during combat it's neccessary to save with zone change counter)
     Map<Integer, Set<String>> targetMap;
     Object object = game.getState().getValue("targets" + source.getSourceId());
     if (object != null && object instanceof Map) {
       targetMap = (Map<Integer, Set<String>>) object;
     } else {
       targetMap = new HashMap<>();
     }
     targetMap.put(game.getCard(source.getSourceId()).getZoneChangeCounter(game), targets);
     if (object == null) {
       game.getState().setValue("targets" + source.getSourceId().toString(), targetMap);
     }
   }
   return true;
 }
Beispiel #2
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player player = game.getPlayer(source.getControllerId());
   MageObject sourceObject = game.getObject(source.getSourceId());
   if (player != null) {
     Choice typeChoice = new ChoiceImpl(true);
     typeChoice.setMessage("Choose a creature type:");
     typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
     while (!player.choose(outcome, typeChoice, game)) {
       if (!player.canRespond()) {
         return false;
       }
     }
     if (typeChoice.getChoice() != null) {
       game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
     }
     FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
     filterCreaturePermanent.add(new SubtypePredicate(typeChoice.getChoice()));
     for (Permanent creature :
         game.getBattlefield()
             .getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
       creature.untap(game);
     }
     return true;
   }
   return false;
 }
Beispiel #3
0
 @Override
 public boolean apply(Game game, Ability source) {
   for (Permanent permanent :
       game.getBattlefield()
           .getActivePermanents(MyrGalvanizer.filter, source.getControllerId(), game)) {
     if (!permanent.getId().equals(source.getSourceId())) {
       permanent.untap(game);
     }
   }
   return true;
 }
Beispiel #4
0
  @Override
  public boolean apply(Game game, Ability source) {
    boolean result = false;
    for (Target target : source.getTargets()) {
      if (target instanceof TargetCreaturePermanent) {
        Permanent targetCreature = game.getPermanent(target.getFirstTarget());
        if (targetCreature != null) {
          ContinuousEffect effect1 = new GainControlTargetEffect(Duration.EndOfTurn);
          effect1.setTargetPointer(new FixedTarget(targetCreature.getId()));
          game.addEffect(effect1, source);

          ContinuousEffect effect2 =
              new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
          effect2.setTargetPointer(new FixedTarget(targetCreature.getId()));
          game.addEffect(effect2, source);

          targetCreature.untap(game);
          result = true;
        }
      }
    }
    return result;
  }
Beispiel #5
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player player = game.getPlayer(source.getControllerId());
   if (player != null) {
     player.drawCards(1, game);
     TargetDiscard target = new TargetDiscard(player.getId());
     player.choose(Outcome.Discard, target, source.getSourceId(), game);
     Card card = player.getHand().get(target.getFirstTarget(), game);
     if (card != null) {
       player.discard(card, source, game);
       if (card.getCardType().contains(CardType.CREATURE)) {
         Permanent permanent = game.getPermanent(source.getSourceId());
         if (permanent != null) {
           permanent.untap(game);
           permanent.transform(game);
         }
       }
       return true;
     }
     return false;
   }
   return false;
 }