Esempio n. 1
0
  @Override
  public boolean resolve(Game game) {
    boolean result = true;
    // 20100716 - 117.12
    if (checkIfClause(game)) {

      for (Effect effect : getEffects()) {
        if (effect instanceof OneShotEffect) {
          boolean effectResult = effect.apply(game, this);
          result &= effectResult;
          if (logger.isDebugEnabled()) {
            if (!this.getAbilityType().equals(AbilityType.MANA)) {
              if (!effectResult) {
                if (this.getSourceId() != null) {
                  MageObject mageObject = game.getObject(this.getSourceId());
                  if (mageObject != null) {
                    logger.debug("AbilityImpl.resolve: object: " + mageObject.getName());
                  }
                }
                logger.debug(
                    "AbilityImpl.resolve: effect returned false -"
                        + effect.getText(this.getModes().getMode()));
              }
            }
          }
        } else {
          game.addEffect((ContinuousEffect) effect, this);
        }
        /**
         * All restrained trigger events are fired now. To restrain the events is mainly neccessary
         * because of the movement of multiple object at once. If the event is fired directly as one
         * object moved, other objects are not already in the correct zone to check for their
         * effects. (e.g. Valakut, the Molten Pinnacle)
         */
        game.getState().handleSimultaneousEvent(game);
        game.resetShortLivingLKI();
        /**
         * game.applyEffects() has to be done at least for every effect that moves cards/permanent
         * between zones, or changes control of objects so Static effects work as intened if
         * dependant from the moved objects zone it is in Otherwise for example were static
         * abilities with replacement effects deactivated too late Example: {@link
         * org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
         */
        if (effect.applyEffectsAfter()) {
          game.applyEffects();
          game.getState().getTriggers().checkStateTriggers(game);
        }
      }
    }
    return result;
  }