use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.
the class MetathranAerostatEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int xValue = source.getManaCostsToPay().getX();
FilterCreatureCard filter = new FilterCreatureCard("a creature with mana value " + xValue);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
if (new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source)) {
return new ReturnToHandSourceEffect(true).apply(game, source);
}
return false;
}
use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.
the class CrypticGatewayPredicate method apply.
@Override
public boolean apply(Game game, Ability source) {
if (source.getCosts() == null) {
return false;
}
FilterCard filter = new FilterCreatureCard("creature card from your hand that shares a creature type with each creature tapped this way");
for (Cost cost : source.getCosts()) {
if (cost instanceof CrypticGatewayCost) {
Predicate predicate = ((CrypticGatewayCost) cost).getPredicate();
filter.add(predicate);
return new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source);
}
}
return false;
}
use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.
the class DermoplasmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent thisCreature = game.getPermanent(source.getId());
FilterCreatureCard filter = new FilterCreatureCard("a creature card with a morph ability");
filter.add(new AbilityPredicate(MorphAbility.class));
Effect effect = new PutCardFromHandOntoBattlefieldEffect(filter);
if (effect.apply(game, source)) {
if (thisCreature != null) {
effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(thisCreature.getId(), game));
effect.apply(game, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.
the class FloodOfTearsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
List<Permanent> nonlands = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, source.getControllerId(), source.getSourceId(), game);
Cards cards = new CardsImpl();
if (!nonlands.isEmpty()) {
nonlands.forEach(cards::add);
boolean putIntoPlay = nonlands.stream().filter(permanent -> permanent.isControlledBy(player.getId())).filter(permanent -> !(permanent instanceof PermanentToken)).count() > 3;
player.moveCards(cards, Zone.HAND, source, game);
if (putIntoPlay) {
new PutCardFromHandOntoBattlefieldEffect().apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect in project mage by magefree.
the class TheUrDragonTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int attackingDragons = 0;
for (UUID attacker : game.getCombat().getAttackers()) {
Permanent creature = game.getPermanent(attacker);
if (creature != null && creature.getControllerId() != null && creature.isControlledBy(this.getControllerId()) && creature.hasSubtype(SubType.DRAGON, game)) {
attackingDragons++;
}
}
if (attackingDragons > 0) {
this.getEffects().clear();
addEffect(new DrawCardSourceControllerEffect(attackingDragons));
addEffect(new PutCardFromHandOntoBattlefieldEffect());
return true;
}
return false;
}
Aggregations