use of mage.abilities.effects.Effect in project mage by magefree.
the class GoblinTutorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int amount = controller.rollDice(outcome, source, game, 6);
Effect effect = null;
// 6 - An instant or sorcery card
if (amount == 2) {
effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, filter), true);
} else if (amount == 3) {
effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_ENTCHANTMENT), true);
} else if (amount == 4) {
effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_ARTIFACT), true);
} else if (amount == 5) {
effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_CREATURE), true);
} else if (amount == 6) {
effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, new FilterInstantOrSorceryCard()), true);
}
if (effect != null) {
effect.apply(game, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class HamletbackGoliathEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
UUID targetId = event.getTargetId();
Permanent permanent = game.getPermanent(targetId);
if (permanent != null && permanent.isCreature(game) && !(targetId.equals(this.getSourceId()))) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(permanent, game));
}
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class LiesaForgottenArchangelReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Effect effect = new ReturnToHandTargetEffect();
effect.setText("return that card to its owner's hand");
effect.setTargetPointer(targetPointer);
DelayedTriggeredAbility ability = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(ability, source);
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class LichsMasteryLoseLifeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
FilterPermanent filter = new FilterPermanent();
filter.add(new ControllerIdPredicate(controller.getId()));
for (int i = 0; i < amount; i++) {
int handCount = controller.getHand().size();
int graveCount = controller.getGraveyard().size();
int permCount = game.getBattlefield().getActivePermanents(filter, controller.getId(), game).size();
if (graveCount + handCount == 0 || (permCount > 0 && controller.chooseUse(Outcome.Exile, "Exile permanent you control? (No = from hand or graveyard)", source, game))) {
Target target = new TargetControlledPermanent(1, 1, new FilterControlledPermanent(), true);
controller.choose(outcome, target, source.getSourceId(), game);
Effect effect = new ExileTargetEffect();
effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
effect.apply(game, source);
} else if (graveCount == 0 || (handCount > 0 && controller.chooseUse(Outcome.Exile, "Exile a card from your hand? (No = from graveyard)", source, game))) {
Target target = new TargetCardInHand(1, 1, new FilterCard());
controller.choose(outcome, target, source.getSourceId(), game);
Card card = controller.getHand().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
}
} else if (graveCount > 0) {
Target target = new TargetCardInYourGraveyard(1, 1, new FilterCard(), true);
target.choose(Outcome.Exile, source.getControllerId(), source.getSourceId(), game);
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
}
}
}
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class LifelineEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setTargetPointer(new FixedTarget(card, game));
effect.setText("return that card to the battlefield under it's owner's control at the beginning of the next end step");
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY), source);
return true;
}
return false;
}
Aggregations