use of mage.abilities.effects.common.UntapAllLandsControllerEffect in project mage by magefree.
the class FieryGambitEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
int flipsWon = 0;
boolean controllerStopped = false;
while (controller.flipCoin(source, game, true)) {
++flipsWon;
if (!controller.chooseUse(outcome, "You won " + flipsWon + (flipsWon == 1 ? " flip." : " flips.") + " Flip another coin?", source, game)) {
controllerStopped = true;
break;
}
// AI workaround to stop flips on good result
if (controller.isComputer() && flipsWon >= 3) {
controllerStopped = true;
break;
}
}
if (controllerStopped) {
Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (creature != null) {
creature.damage(3, source.getSourceId(), source, game, false, true);
}
if (flipsWon > 1) {
new DamagePlayersEffect(6, TargetController.OPPONENT).apply(game, source);
}
if (flipsWon > 2) {
controller.drawCards(9, source, game);
new UntapAllLandsControllerEffect().apply(game, source);
}
} else {
game.informPlayers(sourceObject.getIdName() + " had no effect");
}
return true;
}
return false;
}
Aggregations