use of mage.abilities.effects.common.DamagePlayersEffect in project mage by magefree.
the class RadiantEpicureEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ManaSpentToCastWatcher watcher = game.getState().getWatcher(ManaSpentToCastWatcher.class);
if (player == null || watcher == null) {
return false;
}
Mana payment = watcher.getLastManaPayment(source.getSourceId());
if (payment == null) {
return false;
}
int xValue = payment.getDifferentColors();
new DamagePlayersEffect(xValue, TargetController.OPPONENT).apply(game, source);
player.gainLife(xValue, game, source);
return true;
}
use of mage.abilities.effects.common.DamagePlayersEffect in project mage by magefree.
the class CulminationOfStudiesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
player.moveCards(cards, Zone.EXILED, source, game);
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
int landCards = cards.count(StaticFilters.FILTER_CARD_LAND, game);
int blueCards = cards.count(filterBlue, game);
int redCards = cards.count(filterRed, game);
if (landCards > 0) {
new TreasureToken().putOntoBattlefield(landCards, game, source, source.getControllerId());
}
if (blueCards > 0) {
player.drawCards(blueCards, source, game);
}
if (redCards > 0) {
new DamagePlayersEffect(redCards, TargetController.OPPONENT).apply(game, source);
}
return true;
}
use of mage.abilities.effects.common.DamagePlayersEffect in project mage by magefree.
the class ChandraTorchOfDefianceEffect 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 && controller.getLibrary().hasCards()) {
Library library = controller.getLibrary();
Card card = library.getFromTop(game);
if (card != null) {
boolean cardWasCast = false;
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
if (!card.getManaCost().isEmpty() || !card.isLand(game)) {
if (controller.chooseUse(Outcome.Benefit, "Cast " + card.getName() + "? (You still pay the costs)", source, game) && (game.getState().getZone(card.getId()) == Zone.EXILED)) {
// card must be in the exile zone
// enable the card to be cast from the exile zone
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, false), game, false, new ApprovingObject(source, game));
// reset to null
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
}
if (!cardWasCast) {
new DamagePlayersEffect(Outcome.Damage, StaticValue.get(2), TargetController.OPPONENT).apply(game, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.DamagePlayersEffect 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