@Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.DRAW_STEP_PRE) {
     switch (targetController) {
       case YOU:
         boolean yours = event.getPlayerId().equals(this.controllerId);
         if (yours) {
           if (getTargets().size() == 0) {
             for (Effect effect : this.getEffects()) {
               effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
             }
           }
         }
         return yours;
       case OPPONENT:
         if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
           if (getTargets().size() == 0) {
             for (Effect effect : this.getEffects()) {
               effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
             }
           }
           return true;
         }
       case CONTROLLER_ATTACHED_TO:
         Permanent attachment = game.getPermanent(sourceId);
         if (attachment != null && attachment.getAttachedTo() != null) {
           Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
           if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
             if (getTargets().size() == 0) {
               for (Effect effect : this.getEffects()) {
                 effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
               }
             }
             return true;
           }
         }
         break;
       case ANY:
         if (getTargets().size() == 0) {
           for (Effect effect : this.getEffects()) {
             effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
           }
         }
         return true;
     }
   }
   return false;
 }
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (!event.getTargetId().equals(getSourceId())) {
     MageObject sourceObj = this.getSourceObject(game);
     if (sourceObj != null) {
       if (sourceObj instanceof Card && ((Card) sourceObj).isFaceDown(game)) {
         // if face down and it's not itself that is turned face up, it does not trigger
         return false;
       }
     } else {
       // Permanent is and was not on the battlefield
       return false;
     }
   }
   Permanent permanent = game.getPermanent(event.getTargetId());
   if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
     if (setTargetPointer) {
       for (Effect effect : getEffects()) {
         effect.setTargetPointer(new FixedTarget(event.getTargetId()));
       }
     }
     return true;
   }
   return false;
 }
示例#3
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   if (controller != null) {
     int xSum = 0;
     xSum += playerPaysXGenericMana(controller, source, game);
     for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
       if (playerId != controller.getId()) {
         Player player = game.getPlayer(playerId);
         if (player != null) {
           xSum += playerPaysXGenericMana(player, source, game);
         }
       }
     }
     if (xSum > 0) {
       for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
         Effect effect = new PutTopCardOfLibraryIntoGraveTargetEffect(xSum);
         effect.setTargetPointer(new FixedTarget(playerId));
         effect.apply(game, source);
       }
     }
     // prevent undo
     controller.resetStoredBookmark(game);
     return true;
   }
   return false;
 }
示例#4
0
  @Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent =
        game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
    Permanent sourceObject = game.getPermanent(source.getSourceId());
    if (permanent != null && sourceObject != null) {

      PutTokenOntoBattlefieldCopyTargetEffect effect =
          new PutTokenOntoBattlefieldCopyTargetEffect();
      effect.setTargetPointer(new FixedTarget(permanent, game));
      effect.apply(game, source);
      game.getState().setValue(source.getSourceId() + "_token", effect.getAddedPermanent());
      for (Permanent addedToken : effect.getAddedPermanent()) {
        Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice Dance of Many");
        sacrificeEffect.setTargetPointer(new FixedTarget(sourceObject, game));
        LeavesBattlefieldTriggeredAbility triggerAbility =
            new LeavesBattlefieldTriggeredAbility(sacrificeEffect, false);
        ContinuousEffect continuousEffect =
            new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield);
        continuousEffect.setTargetPointer(new FixedTarget(addedToken, game));
        game.addEffect(continuousEffect, source);
      }
      return true;
    }
    return false;
  }
示例#5
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player player = getPayingPlayer(game, source);
   MageObject mageObject = game.getObject(source.getSourceId());
   if (player != null && mageObject != null) {
     String message;
     if (chooseUseText == null) {
       message =
           new StringBuilder(getCostText())
               .append(" and ")
               .append(executingEffect.getText(source.getModes().getMode()))
               .append("?")
               .toString();
     } else {
       message = chooseUseText;
     }
     message = CardUtil.replaceSourceName(message, mageObject.getName());
     if (cost.canPay(source, source.getSourceId(), player.getId(), game)
         && player.chooseUse(executingEffect.getOutcome(), message, game)) {
       cost.clearPaid();
       if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
         executingEffect.setTargetPointer(this.targetPointer);
         if (executingEffect instanceof OneShotEffect) {
           if (!(executingEffect instanceof PostResolveEffect)) {
             return executingEffect.apply(game, source);
           }
         } else {
           game.addEffect((ContinuousEffect) executingEffect, source);
         }
       }
     }
     return true;
   }
   return false;
 }
示例#6
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (game.getOpponents(getControllerId()).contains(event.getPlayerId())) {
     for (Effect effect : getEffects()) {
       effect.setTargetPointer(new FixedTarget(event.getSourceId()));
     }
     return true;
   }
   return false;
 }
示例#7
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == EventType.DECLARED_ATTACKERS
       && game.getActivePlayerId().equals(this.controllerId)) {
     if (game.getCombat().attacksAlone()) {
       for (Effect effect : this.getEffects()) {
         effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackers().get(0)));
       }
       return true;
     }
   }
   return false;
 }
示例#8
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getTargetId().equals(this.getSourceId())) {
     Permanent blocker = game.getPermanent(event.getSourceId());
     if (filter.match(blocker, game)) {
       for (Effect effect : this.getEffects()) {
         effect.setTargetPointer(new FixedTarget(event.getSourceId()));
       }
       return true;
     }
   }
   return false;
 }
示例#9
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getType() == GameEvent.EventType.SPELL_CAST) {
     Spell spell = game.getStack().getSpell(event.getTargetId());
     if (spell != null && spell.getConvertedManaCost() <= 3) {
       for (Effect effect : this.getEffects()) {
         effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
       }
       return true;
     }
   }
   return false;
 }
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   Permanent sourcePermanent = game.getPermanent(event.getSourceId());
   if (sourcePermanent != null && filter.match(sourcePermanent, sourceId, controllerId, game)) {
     if (setTargetPointer) {
       for (Effect effect : this.getEffects()) {
         effect.setTargetPointer(new FixedTarget(event.getSourceId()));
       }
     }
     return true;
   }
   return false;
 }
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getSourceId().equals(this.sourceId)) {
     if (setTargetPointer) {
       for (Effect effect : this.getEffects()) {
         effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
         effect.setValue("damage", event.getAmount());
       }
     }
     return true;
   }
   return false;
 }
示例#12
0
  public Lunge(UUID ownerId) {
    super(ownerId, 203, "Lunge", Rarity.COMMON, new CardType[] {CardType.INSTANT}, "{2}{R}");
    this.expansionSetCode = "MMQ";

    // Lunge deals 2 damage to target creature and 2 damage to target player.
    this.getSpellAbility().addEffect(new DamageTargetEffect(1));
    this.getSpellAbility().addTarget(new TargetCreaturePermanent());

    Effect effect = new DamageTargetEffect(1);
    effect.setTargetPointer(new SecondTargetPointer());
    effect.setText("and 2 damage to target player");
    this.getSpellAbility().addEffect(effect);
    this.getSpellAbility().addTarget(new TargetPlayer());
  }
示例#13
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (super.checkTrigger(event, game)) {
     String key = CardUtil.getCardZoneString("targetPlayer", this.getSourceId(), game, true);
     Object object = game.getState().getValue(key);
     if (object instanceof UUID) {
       for (Effect effect : this.getEffects()) {
         effect.setTargetPointer(new FixedTarget((UUID) object));
       }
       return true;
     }
   }
   return false;
 }
示例#14
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
   Permanent p = game.getPermanent(event.getSourceId());
   if (damageEvent.isCombatDamage()
       && p != null
       && p.getAttachments().contains(this.getSourceId())) {
     for (Effect effect : this.getEffects()) {
       effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
     }
     return true;
   }
   return false;
 }
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   Permanent enchantment = game.getPermanent(sourceId);
   UUID targetId = event.getTargetId();
   if (enchantment != null
       && enchantment.getAttachedTo() != null
       && targetId.equals(enchantment.getAttachedTo())) {
     for (Effect effect : this.getEffects()) {
       effect.setValue("damage", event.getAmount());
       switch (setTargetPointer) {
         case PERMANENT:
           effect.setTargetPointer(new FixedTarget(targetId));
           break;
         case PLAYER:
           effect.setTargetPointer(
               new FixedTarget(game.getPermanentOrLKIBattlefield(targetId).getControllerId()));
           break;
       }
     }
     return true;
   }
   return false;
 }
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (!onlyCombat || ((DamagedPlayerEvent) event).isCombatDamage()) {
     Permanent permanent = game.getPermanent(event.getSourceId());
     if (permanent != null && filter.match(permanent, sourceId, controllerId, game)) {
       if (!setTargetPointer.equals(SetTargetPointer.NONE)) {
         for (Effect effect : this.getEffects()) {
           effect.setValue("damage", event.getAmount());
           switch (setTargetPointer) {
             case PLAYER:
               effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
               break;
             case PERMANENT:
               effect.setTargetPointer(
                   new FixedTarget(permanent.getId(), permanent.getZoneChangeCounter(game)));
               break;
           }
         }
       }
       return true;
     }
   }
   return false;
 }
示例#17
0
  public PullFromTheDeep(UUID ownerId, CardSetInfo setInfo) {
    super(ownerId, setInfo, new CardType[] {CardType.SORCERY}, "{2}{U}{U}");

    // Return up to one target instant card and up to one target sorcery card from your graveyard to
    // your hand. Exile Pull from the Deep.
    Effect effect = new ReturnToHandTargetEffect();
    effect.setText("Return up to one target instant card");
    this.getSpellAbility().addEffect(effect);
    this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterInstant));
    effect = new ReturnToHandTargetEffect();
    effect.setText("and up to one target sorcery card from your graveyard to your hand");
    effect.setTargetPointer(new SecondTargetPointer());
    this.getSpellAbility().addEffect(effect);
    this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterSorcery));
    this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
  }
示例#18
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (event.getZone() == Zone.HAND) {
     Spell spell = game.getStack().getSpell(event.getTargetId());
     if (spell != null
         && !spell.isCopy()
         && (spell.getCardType().contains(CardType.INSTANT)
             || spell.getCardType().contains(CardType.SORCERY))) {
       for (Effect effect : this.getEffects()) {
         effect.setTargetPointer(new FixedTarget(event.getTargetId()));
       }
       return true;
     }
   }
   return false;
 }
示例#19
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   StackObject spell = game.getStack().getStackObject(event.getSourceId());
   if (spell == null || !(spell instanceof Spell)) {
     return false;
   } else {
     if (event.getTargetId().equals(this.getSourceId())
         && game.getOpponents(this.controllerId).contains(event.getPlayerId())
         && spellCard.match(spell, getSourceId(), getControllerId(), game)) {
       for (Effect effect : getEffects()) {
         effect.setTargetPointer(new FixedTarget(spell.getId()));
       }
       return true;
     }
   }
   return false;
 }
 @Override
 public void adjustTargets(Ability ability, Game game) {
   if (ability.getOriginalId().equals(originalId)) {
     for (Effect effect : ability.getEffects()) {
       UUID opponentId = effect.getTargetPointer().getFirst(game, ability);
       Player opponent = game.getPlayer(opponentId);
       if (opponent != null) {
         effect.setTargetPointer(new FirstTargetPointer());
         FilterCreaturePermanent filter =
             new FilterCreaturePermanent("a creature from the active opponent");
         filter.add(new ControllerIdPredicate(opponentId));
         Target target = new TargetCreaturePermanent(filter);
         ability.addTarget(target);
       }
     }
   }
 }
示例#21
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (((DamagedEvent) event).isCombatDamage()) {
     if (event.getSourceId().equals(getSourceId())) {
       this.getEffects().clear();
       Effect effect =
           new AddManaToManaPoolTargetControllerEffect(
               Mana.GreenMana(event.getAmount()), "that player", true);
       effect.setTargetPointer(new FixedTarget(getControllerId()));
       effect.setText(
           "add that much {G} to your mana pool. Until end of turn, this mana doesn't empty from your mana pool as steps and phases end");
       this.addEffect(effect);
       return true;
     }
   }
   return false;
 }
示例#22
0
 @Override
 public boolean checkTrigger(GameEvent event, Game game) {
   if (super.checkTrigger(event, game)) {
     Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId());
     if (sourcePermanent != null && sourcePermanent.getAttachedTo() != null) {
       Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo());
       if (attachedTo != null) {
         for (Effect effect : getEffects()) {
           effect.setTargetPointer(
               new FixedTarget(attachedTo.getId(), attachedTo.getZoneChangeCounter(game)));
         }
       }
     }
     return true;
   }
   return false;
 }