use of mage.abilities.effects.Effect in project mage by magefree.
the class InvokePrejudiceEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(getControllerId()).contains(event.getPlayerId())) {
Spell spell = (Spell) game.getObject(event.getTargetId());
if (spell != null && spell.isCreature(game)) {
boolean creatureSharesAColor = false;
ObjectColor spellColor = spell.getColor(game);
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterControlledCreaturePermanent(), getControllerId(), game)) {
if (spellColor.shares(permanent.getColor(game))) {
creatureSharesAColor = true;
break;
}
}
if (!creatureSharesAColor) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
}
return true;
}
}
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class LabyrinthRaptorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (permanent == null) {
return false;
}
Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(permanent.getId(), game));
if (player == null) {
return false;
}
FilterPermanent filterPermanent = new FilterPermanent("creature blocking " + permanent.getIdName());
filterPermanent.add(new BlockingAttackerIdPredicate(permanent.getId()));
Effect effect = new SacrificeEffect(filterPermanent, 1, "");
effect.setTargetPointer(new FixedTarget(player.getId(), game));
return effect.apply(game, source);
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class MacabreMockeryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card == null) {
return false;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
return false;
}
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return false;
}
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
effect = new BoostTargetEffect(2, 0, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + permanent.getLogName(), controller.getId());
sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class OathOfLiegesPredicate method apply.
@Override
public boolean apply(Game game, Ability source) {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer != null) {
if (activePlayer.chooseUse(outcome, "Search your library for a basic land card, put that card onto the battlefield, then shuffle?", source, game)) {
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), false, false, Outcome.PutLandInPlay, true);
effect.setTargetPointer(new FixedTarget(game.getActivePlayerId()));
return effect.apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class RakdossReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayerOrPlaneswalkerController(source.getFirstTarget());
if (player == null) {
return false;
}
Effect effect = new DiscardTargetEffect(ManacostVariableValue.REGULAR);
effect.setTargetPointer(new FixedTarget(player.getId(), game));
return effect.apply(game, source);
}
Aggregations