use of mage.abilities.effects.Effect in project mage by magefree.
the class RallyTheAncestorsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int xValue = source.getManaCostsToPay().getX();
FilterCreatureCard filter = new FilterCreatureCard();
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
Set<Card> cards = player.getGraveyard().getCards(filter, game);
player.moveCards(cards, Zone.BATTLEFIELD, source, game);
List<Permanent> toExile = new ArrayList<>(cards.size());
for (Card card : cards) {
if (card != null) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
toExile.add(permanent);
}
}
}
Effect exileEffect = new ExileTargetEffect("Exile those creatures at the beginning of your next upkeep");
exileEffect.setTargetPointer(new FixedTargets(toExile, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class RangeTrooperEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
MageObject sourceObject = game.getObject(source.getSourceId());
if (permanent != null && sourceObject != null) {
if (permanent.moveToExile(source.getSourceId(), sourceObject.getIdName(), source, game)) {
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setText("Return that card to the battlefield under its owner's control at the beginning of the next end step");
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
return true;
}
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class RancidEarthEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Effect effect1 = new DestroyTargetEffect("destroy that land");
effect1.apply(game, source);
return new DamageEverythingEffect(1).apply(game, source);
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class ServantOfTheScaleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (sourcePermanent != null && controller != null && (// Token
sourcePermanent.getZoneChangeCounter(game) == source.getSourceObjectZoneChangeCounter() || sourcePermanent.getZoneChangeCounter(game) + 1 == source.getSourceObjectZoneChangeCounter())) {
// PermanentCard
int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (amount > 0) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(amount));
effect.setTargetPointer(targetPointer);
effect.apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class SkybindEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (permanent != null && sourcePermanent != null) {
if (permanent.moveToExile(source.getSourceId(), sourcePermanent.getName(), source, game)) {
// create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setText("Return that card to the battlefield under its owner's control at the beginning of the next end step");
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source), game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
return true;
}
}
return false;
}
Aggregations