Package mage.game.stack

Examples of mage.game.stack.StackObject


    return new CounterUnlessPaysEffect(this);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    StackObject spell = game.getStack().getStackObject(source.getFirstTarget());
    if (spell != null) {
      Player player = game.getPlayer(spell.getControllerId());
      if (player != null) {
        cost.clearPaid();
        if (!cost.pay(game, spell.getControllerId(), spell.getControllerId(), false)) {
          return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);
        }
      }
    }
    return false;
View Full Code Here


        }
        it.remove();
      }
    }
    for (Iterator<StackObject> it = game.getStack().iterator(); it.hasNext();) {
      StackObject object = it.next();
      if (object.getControllerId().equals(playerId)) {
        it.remove();
      }
    }
    for (Iterator<Permanent> it = game.getBattlefield().getAllPermanents().iterator(); it.hasNext();) {
      Permanent perm = it.next();
View Full Code Here

  }

  @Override
  public boolean applies(GameEvent event, Ability source, Game game) {
    if (event.getType() == EventType.TARGET && event.getTargetId().equals(source.getSourceId())) {
      StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
      if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) {
        return true;
      }
    }
    return false;
View Full Code Here

    return filter;
  }

  @Override
  public boolean canTarget(UUID id, Ability source, Game game) {
    StackObject stackObject = game.getStack().getStackObject(id);
    if (stackObject != null) {
      return filter.match(stackObject);
    }
    return false;
  }
View Full Code Here

  }

  @Override
  public boolean applies(GameEvent event, Ability source, Game game) {
    if (event.getType() == EventType.TARGET && event.getTargetId().equals(source.getControllerId())) {
      StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
      if (sourceObject != null && filterSource.match(sourceObject)) {
        return true;
      }
    }
    return false;
View Full Code Here

    }
    return false;
  }

  protected Ability getSource(UUID sourceId, Game game) {
    StackObject source = game.getStack().getStackObject(sourceId);
    if (source != null) {
      if (source instanceof StackAbility)
        return (StackAbility)source;
      if (source instanceof Spell)
        return ((Spell)source).getSpellAbility();
View Full Code Here

      Permanent permanent = game.getPermanent(event.getTargetId());
      if (permanent != null && filterTarget.match(permanent, source.getControllerId(), game)) {
        if (filterSource == null)
          return true;
        else {
          StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
          if (sourceObject != null && filterSource.match(sourceObject)) {
            return true;
          }
        }
      }
View Full Code Here

  public boolean applies(GameEvent event, Ability source, Game game) {
    switch (event.getType()) {
      case DAMAGE_CREATURE:
      case DAMAGE_PLAYER:
      case DAMAGE_PLANESWALKER:
        StackObject spell = game.getStack().getStackObject(event.getSourceId());
        if (spell != null && spell.getControllerId().equals(source.getControllerId()) && spell.getColor().isRed() &&
            (spell.getCardType().contains(CardType.INSTANT) || spell.getCardType().contains(CardType.SORCERY))) {
          event.setAmount(event.getAmount() * 2);
        }
    }
    return false;
  }
View Full Code Here

  @Override
  public boolean applies(GameEvent event, Ability source, Game game) {
    if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) {
      ZoneChangeEvent zcEvent = (ZoneChangeEvent) event;
      if (zcEvent.getFromZone() == Zone.HAND && zcEvent.getToZone() == Zone.GRAVEYARD) {
        StackObject spell = game.getStack().getStackObject(event.getSourceId());
        if (spell != null && game.getOpponents(source.getControllerId()).contains(spell.getControllerId())) {
          return true;
        }
      }
    }
    return false;
View Full Code Here

    }
    return null;
  }

  protected void resolve(SimulationNode node, int depth, Game game) {
    StackObject ability = game.getStack().pop();
    if (ability instanceof StackAbility) {
      SearchEffect effect = getSearchEffect((StackAbility) ability);
      if (effect != null && ability.getControllerId().equals(playerId)) {
        Target target = effect.getTarget();
        if (!target.doneChosing()) {
          for (UUID targetId: target.possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) {
            Game sim = game.copy();
            StackAbility newAbility = (StackAbility) ability.copy();
            SearchEffect newEffect = getSearchEffect((StackAbility) newAbility);
            newEffect.getTarget().addTarget(targetId, newAbility, sim);
            sim.getStack().push(newAbility);
            SimulationNode newNode = new SimulationNode(sim, depth, ability.getControllerId());
            node.children.add(newNode);
            newNode.getTargets().add(targetId);
            logger.fine("simulating search -- node#: " + SimulationNode.getCount() + "for player: " + sim.getPlayer(ability.getControllerId()).getName());
          }
          return;
        }
      }
    }
    logger.fine("simulating resolve ");
    ability.resolve(game);
    game.applyEffects();
    game.getPlayers().resetPassed();
    game.getPlayerList().setCurrent(game.getActivePlayerId());
  }
View Full Code Here

TOP

Related Classes of mage.game.stack.StackObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.