Search in sources :

Example 1 with RallyTheHordeWarriorToken

use of mage.game.permanent.token.RallyTheHordeWarriorToken in project mage by magefree.

the class RallyTheHordeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int nonLandCardsExiled = 0;
        while (controller.getLibrary().hasCards()) {
            nonLandCardsExiled += checkIfNextLibCardIsNonLandAndExile(controller, source, game);
            if (controller.getLibrary().hasCards()) {
                nonLandCardsExiled += checkIfNextLibCardIsNonLandAndExile(controller, source, game);
            }
            if (controller.getLibrary().hasCards()) {
                int nonLands = checkIfNextLibCardIsNonLandAndExile(controller, source, game);
                if (nonLands == 0) {
                    break;
                }
                nonLandCardsExiled += nonLands;
            }
        }
        return new CreateTokenEffect(new RallyTheHordeWarriorToken(), nonLandCardsExiled).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) RallyTheHordeWarriorToken(mage.game.permanent.token.RallyTheHordeWarriorToken)

Aggregations

CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 RallyTheHordeWarriorToken (mage.game.permanent.token.RallyTheHordeWarriorToken)1 Player (mage.players.Player)1