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;
}
Aggregations