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