Package mage.game.stack

Examples of mage.game.stack.StackAbility


  protected boolean playAbility(ActivatedAbility ability, Game game) {
    //20091005 - 602.2a
    if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, ability.getSourceId(), ability.getId(), playerId))) {
      game.bookmarkState();
      ability.newId();
      game.getStack().push(new StackAbility(ability, playerId));
      String message = ability.getActivatedMessage(game);
      if (ability.activate(game, false)) {
        game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATED_ABILITY, ability.getSourceId(), ability.getId(), playerId));
        game.fireInformEvent(name + message);
        game.removeLastBookmark();
View Full Code Here


  public boolean triggerAbility(TriggeredAbility source, Game game) {
    //20091005 - 603.3c, 603.3d
    game.bookmarkState();
    TriggeredAbility ability = (TriggeredAbility) source.copy();
    if (ability.getTargets().canChoose(ability.getSourceId(), playerId, game)) {
      game.getStack().push(new StackAbility(ability, playerId));
      if (ability.activate(game, false)) {
        game.removeLastBookmark();
        return true;
      }
    }
View Full Code Here

    Ability ability = source.copy();
    List<Ability> options = getPlayableOptions(ability, game);
    if (options.size() == 0) {
      if (logger.isLoggable(Level.FINE))
        logger.fine("simulating -- triggered ability:" + ability);
      game.getStack().push(new StackAbility(ability, playerId));
      ability.activate(game, false);
      game.applyEffects();
      game.getPlayers().resetPassed();
    }
    else {
View Full Code Here

    return true;
  }

  protected void addAbilityNode(SimulationNode parent, Ability ability, int depth, Game game) {
    Game sim = game.copy();
    sim.getStack().push(new StackAbility(ability, playerId));
    ability.activate(sim, false);
    sim.applyEffects();
    SimulationNode newNode = new SimulationNode(sim, depth, playerId);
    logger.fine("simulating -- node #:" + SimulationNode.getCount() + " triggered ability option");
    for (Target target: ability.getTargets()) {
View Full Code Here

      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);
View Full Code Here

                    ability = options.get(0);
                else
                    ability = options.get(rnd.nextInt(options.size()));
            }
            if (ability.isUsesStack()) {
                game.getStack().push(new StackAbility(ability, playerId));
                if (ability.activate(game, false)) {
                    actionCount++;
                    return true;
                }
            } else {
View Full Code Here

        //20091005 - 602.2a
        if (ability.isUsesStack()) {
            if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, ability.getId(), ability.getSourceId(), playerId))) {
                int bookmark = game.bookmarkState();
                ability.newId();
                game.getStack().push(new StackAbility(ability, playerId));
                if (ability.activate(game, false)) {
                    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATED_ABILITY, ability.getId(), ability.getSourceId(), playerId));
                    game.informPlayers(new StringBuilder(name).append(ability.getGameLogMessage(game)).toString());
                    game.removeBookmark(bookmark);
                    resetStoredBookmark(game);
View Full Code Here

        //20091005 - 603.3c, 603.3d
        int bookmark = game.bookmarkState();
        TriggeredAbility ability = source.copy();
        if (ability != null && ability.canChooseTarget(game)) {           
            if (ability.isUsesStack()) {
                game.getStack().push(new StackAbility(ability, playerId));
            }
            if (ability.activate(game, false)) {
                if (ability.isUsesStack() || ability.getRuleVisible()) {
                    game.informPlayers(ability.getGameLogMessage(game));
                }
View Full Code Here

                // cast from exile (e.g. Neightveil Spector) -> no replacement
                return false;
            }
        }
        if (sourceObject instanceof StackAbility) {
            StackAbility stackAbility = (StackAbility) sourceObject;
            if (!stackAbility.getEffects().isEmpty()) {
                targetId = stackAbility.getEffects().get(0).getTargetPointer().getFirst(game, stackAbility);
            }
        }
       
        if (targetId == null) {
            Target target = card.getSpellAbility().getTargets().get(0);
View Full Code Here

        super(effect);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        StackAbility stackAbility = (StackAbility)game.getStack().getStackObject(targetPointer.getFirst(game, source));
        if(stackAbility != null){
            Ability ability = (Ability) stackAbility.getStackAbility();
            Player controller = game.getPlayer(source.getControllerId());
            Permanent sourcePermanent = game.getPermanent(source.getSourceId());
            if (ability != null && controller != null && sourcePermanent != null) {
                Ability newAbility = ability.copy();
                newAbility.newId();
                game.getStack().push(new StackAbility(newAbility, source.getControllerId()));
                if (newAbility.getTargets().size() > 0) {
                    if (controller.chooseUse(newAbility.getEffects().get(0).getOutcome(), "Choose new targets?", game)) {
                        newAbility.getTargets().clearChosen();
                        if (newAbility.getTargets().chooseTargets(newAbility.getEffects().get(0).getOutcome(), source.getControllerId(), newAbility, game) == false) {
                            return false;
View Full Code Here

TOP

Related Classes of mage.game.stack.StackAbility

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.