Search in sources :

Example 1 with KnightToken

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

the class ValiantEndeavorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    List<Integer> results = controller.rollDice(outcome, source, game, 6, 2, 0);
    int firstResult = results.get(0);
    int secondResult = results.get(1);
    int first, second;
    if (firstResult != secondResult && controller.chooseUse(outcome, "Destroy each creature with power greater than or equal to your choice", "The other number will be the amount of 2/2 white Knight tokens with vigilance.", "" + firstResult, "" + secondResult, source, game)) {
        first = firstResult;
        second = secondResult;
    } else {
        first = secondResult;
        second = firstResult;
    }
    final FilterCreaturePermanent filter = new FilterCreaturePermanent(String.format("creatures with power greater than or equal to %s", first));
    filter.add(new PowerPredicate(ComparisonType.MORE_THAN, first - 1));
    Effect wrathEffect = new DestroyAllEffect(filter);
    wrathEffect.apply(game, source);
    new KnightToken().putOntoBattlefield(second, game, source, source.getControllerId());
    return true;
}
Also used : Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) PowerPredicate(mage.filter.predicate.mageobject.PowerPredicate) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect) KnightToken(mage.game.permanent.token.KnightToken) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Aggregations

Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 DestroyAllEffect (mage.abilities.effects.common.DestroyAllEffect)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 PowerPredicate (mage.filter.predicate.mageobject.PowerPredicate)1 KnightToken (mage.game.permanent.token.KnightToken)1 Player (mage.players.Player)1