use of mage.abilities.effects.common.DrawCardTargetEffect in project mage by magefree.
the class HatefulEidolonTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int auraCount = 0;
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent()) {
return false;
}
Permanent deadCreature = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (deadCreature.getAttachments().isEmpty()) {
return false;
}
for (UUID auraId : deadCreature.getAttachments()) {
Permanent attachment = game.getPermanentOrLKIBattlefield(auraId);
if (attachment.getControllerId().equals(controllerId) && attachment.isEnchantment(game)) {
// Shadowspear or any other equipment does not count
auraCount += 1;
}
}
if (auraCount == 0) {
// just equipment not aura's
return false;
}
Player controller = game.getPlayer(controllerId);
if (controller != null && controller.canRespond()) {
this.getEffects().clear();
DrawCardTargetEffect drawCard = new DrawCardTargetEffect(auraCount);
drawCard.setTargetPointer(new FixedTarget(controllerId));
this.addEffect(drawCard);
return true;
}
return false;
}
use of mage.abilities.effects.common.DrawCardTargetEffect in project mage by magefree.
the class FatalLoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player chosenOpponent = game.getPlayer(targetPointer.getFirst(game, source));
if (controller != null && chosenOpponent != null) {
if (chosenOpponent.chooseUse(Outcome.Neutral, "If you choose Yes, the controller draws three cards. If no, the controller gets to destroy up to two target creatures that you control and you get to draw up to 3 cards. Those creatures can't be regenerated.", source, game)) {
controller.drawCards(3, source, game);
} else {
FilterCreaturePermanent filter = new FilterCreaturePermanent("chosen opponent's creature");
filter.add(new ControllerIdPredicate(chosenOpponent.getId()));
TargetCreaturePermanent target = new TargetCreaturePermanent(0, 2, filter, false);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game)) {
for (UUID targetId : target.getTargets()) {
Effect destroyCreature = new DestroyTargetEffect(true);
destroyCreature.setTargetPointer(new FixedTarget(targetId, game));
destroyCreature.apply(game, source);
}
Effect opponentDrawsCards = new DrawCardTargetEffect(StaticValue.get(3), false, true);
opponentDrawsCards.setTargetPointer(new FixedTarget(chosenOpponent.getId()));
opponentDrawsCards.apply(game, source);
return true;
}
}
}
return false;
}
use of mage.abilities.effects.common.DrawCardTargetEffect in project mage by magefree.
the class CurseOfVerbosityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// In the case that the enchantment is blinked
Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (enchantment == null) {
// It was not blinked, use the standard method
enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
}
if (enchantment != null) {
Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
if (enchantedPlayer != null) {
Set<UUID> players = new HashSet<>();
for (UUID attacker : game.getCombat().getAttackers()) {
UUID defender = game.getCombat().getDefenderId(attacker);
if (defender.equals(enchantedPlayer.getId()) && game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
players.add(game.getPermanent(attacker).getControllerId());
}
}
players.add(source.getControllerId());
for (UUID player : players) {
game.getPlayer(player);
Effect effect = new DrawCardTargetEffect(1);
effect.setTargetPointer(new FixedTarget(player));
effect.apply(game, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.DrawCardTargetEffect in project mage by magefree.
the class ArcaneDenialEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = null;
boolean countered = false;
UUID targetId = this.getTargetPointer().getFirst(game, source);
if (targetId != null) {
controller = game.getPlayer(game.getControllerId(targetId));
}
if (targetId != null && game.getStack().counter(targetId, source, game)) {
countered = true;
}
if (controller != null) {
Effect effect = new DrawCardTargetEffect(StaticValue.get(2), false, true);
effect.setTargetPointer(new FixedTarget(controller.getId()));
effect.setText("Its controller may draw up to two cards");
DelayedTriggeredAbility ability = new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(ability, source);
}
return countered;
}
use of mage.abilities.effects.common.DrawCardTargetEffect in project mage by magefree.
the class HornOfPlentyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player caster = game.getPlayer(targetPointer.getFirst(game, source));
if (caster != null) {
if (caster.chooseUse(Outcome.DrawCard, "Pay {1} to draw a card at the beginning of the next end step?", source, game)) {
Cost cost = new ManaCostsImpl("{1}");
if (cost.pay(source, game, source, caster.getId(), false, null)) {
Effect effect = new DrawCardTargetEffect(1);
effect.setTargetPointer(new FixedTarget(caster.getId()));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY), source);
return true;
}
}
}
return false;
}
Aggregations