Package mage.abilities

Examples of mage.abilities.TriggeredAbility


  @Override
  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;
      }
    }
    game.restoreState();
View Full Code Here


    state.addEffect(newEffect, newAbility);
  }

  @Override
  public void addTriggeredAbility(TriggeredAbility ability) {
    TriggeredAbility newAbility = (TriggeredAbility) ability.copy();
    newAbility.newId();
    state.addTriggeredAbility(newAbility);
  }
View Full Code Here

        if (abilities.size() == 1) {
          state.getTriggered().remove(abilities.get(0));
          played |= player.triggerAbility(abilities.get(0), this);
        }
        else {
          TriggeredAbility ability = player.chooseTriggeredAbility(abilities, this);
          state.getTriggered().remove(ability);
          played |= player.triggerAbility(ability, this);
        }
      }
    }
View Full Code Here

            logger.warn("Null source in triggerAbility method");
            throw new IllegalArgumentException("source TriggeredAbility  must not be null");
        }
        //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));
                }
                if (!ability.isUsesStack()) {
                    ability.resolve(game);
                }
                game.removeBookmark(bookmark);
                return true;
            }
        }
View Full Code Here

            Ability manaAbiltiy = ability.copy();
            manaAbiltiy.activate(this, false);
            manaAbiltiy.resolve(this);
        }
        else {
            TriggeredAbility newAbility = ability.copy();
            newAbility.newId();
            state.addTriggeredAbility(newAbility);
        }
    }
View Full Code Here

        this.toughness = new MageInt(6);

        this.addAbility(VigilanceAbility.getInstance());
        this.addAbility(LifelinkAbility.getInstance());
        // At the beginning of your upkeep, if you have 40 or more life, you win the game.
        TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new WinGameSourceControllerEffect(), TargetController.YOU, false);
        this.addAbility(new ConditionalTriggeredAbility(ability, new FortyOrMoreLifeCondition(), "At the beginning of your upkeep, if you have 40 or more life, you win the game."));

    }
View Full Code Here

                if (abilities.isEmpty()) {
                    break;
                }
                // triggered abilities that don't use the stack have to be executed first (e.g. Banisher Priest Return exiled creature
                for (Iterator<TriggeredAbility> it = abilities.iterator(); it.hasNext();) {
                    TriggeredAbility triggeredAbility = it.next();
                    if (!triggeredAbility.isUsesStack()) {
                        state.removeTriggeredAbility(triggeredAbility);
                        played |= player.triggerAbility(triggeredAbility, this);
                        it.remove();
                    }
                }
                if (abilities.isEmpty()) {
                    break;
                }
                if (abilities.size() == 1) {
                    state.removeTriggeredAbility(abilities.get(0));
                    played |= player.triggerAbility(abilities.get(0), this);
                }
                else {
                    TriggeredAbility ability = player.chooseTriggeredAbility(abilities, this);
                    if (ability != null) {
                        state.removeTriggeredAbility(ability);
                        played |= player.triggerAbility(ability, this);
                    }
                }
View Full Code Here

        this.addAbility(TrampleAbility.getInstance());
        // Whenever Hellkite Tyrant deals combat damage to a player, gain control of all artifacts that player controls.
        this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new HellkiteTyrantEffect(),false, true));

        // At the beginning of your upkeep, if you control twenty or more artifacts, you win the game.
        TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new WinGameSourceControllerEffect(), TargetController.YOU, false);
        this.addAbility(new ConditionalTriggeredAbility(
                ability,
                new PermanentsOnTheBattlefieldCondition(new FilterArtifactPermanent(), PermanentsOnTheBattlefieldCondition.CountType.MORE_THAN,19),
                "At the beginning of your upkeep, if you control twenty or more artifacts, you win the game."));
View Full Code Here

        this.toughness = new MageInt(6);

        // Tribute 6
        this.addAbility(new TributeAbility(6));
        // When Nessian Wilds Ravager enters the battlefield, if tribute wasn't paid, you may have Nessian Wilds Ravager fight another target creature.
        TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new FightTargetSourceEffect(), true);
        ability.addTarget(new TargetCreaturePermanent(filter));
        this.addAbility(new ConditionalTriggeredAbility(ability, TributeNotPaidCondition.getInstance(),
                "When {this} enters the battlefield, if its tribute wasn't paid, you may have {this} fight another target creature."));
    }
View Full Code Here

        // Trample
        this.addAbility(TrampleAbility.getInstance());
        // Tribute 1
        this.addAbility(new TributeAbility(1));
        // When Fanatic of Xenagos enters the battlefield, if its tribute wasn't paid, it gets +1/+1 and gains haste until end of turn.
        TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new BoostSourceEffect(1,1, Duration.EndOfTurn));
        ability.addEffect( new GainAbilitySourceEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.EndOfTurn)));
        this.addAbility(new ConditionalTriggeredAbility(ability, TributeNotPaidCondition.getInstance(),
                "When {this} enters the battlefield, if its tribute wasn't paid, it gets +1/+1 and gains haste until end of turn."));
    }
View Full Code Here

TOP

Related Classes of mage.abilities.TriggeredAbility

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.