use of mage.abilities.effects.EntersBattlefieldEffect in project mage by magefree.
the class PyrrhicRevivalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Set<Card> toBattlefield = new HashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card : player.getGraveyard().getCards(game)) {
if (card != null && card.isCreature(game)) {
toBattlefield.add(card);
ContinuousEffect effect = new EntersBattlefieldEffect(new AddCountersTargetEffect(CounterType.M1M1.createInstance()));
effect.setDuration(Duration.OneUse);
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
}
}
}
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null);
return true;
}
use of mage.abilities.effects.EntersBattlefieldEffect in project mage by magefree.
the class GemstoneCavernsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
ContinuousEffect effect = new EntersBattlefieldEffect(new AddCountersSourceEffect(CounterType.LUCK.createInstance()), "");
effect.setDuration(Duration.OneUse);
game.addEffect(effect, source);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
Cost cost = new ExileFromHandCost(new TargetCardInHand());
if (cost.canPay(source, source, source.getControllerId(), game)) {
result = cost.pay(source, game, source, source.getControllerId(), true, null);
}
}
}
}
}
return result;
}
Aggregations