use of mage.abilities.keyword.DecayedAbility in project mage by magefree.
the class GisaGloriousResurrectorReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Ability exiledWithSource = (Ability) game.getState().getValue("GisaGloriousResurrectorExile" + source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()));
if (exiledWithSource == null) {
return false;
}
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, exiledWithSource));
if (player == null || exileZone == null || exileZone.isEmpty()) {
return false;
}
Cards cards = new CardsImpl(exileZone.getCards(StaticFilters.FILTER_CARD_CREATURE, game));
if (cards.isEmpty()) {
return false;
}
player.moveCards(cards, Zone.BATTLEFIELD, source, game);
cards.retainZone(Zone.BATTLEFIELD, game);
if (cards.isEmpty()) {
return false;
}
game.addEffect(new GainAbilityTargetEffect(new DecayedAbility(), Duration.Custom).setTargetPointer(new FixedTargets(cards, game)), source);
return true;
}
use of mage.abilities.keyword.DecayedAbility in project mage by magefree.
the class GhoulsNightOutTypeChangingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
UUID controllerId = source.getControllerId();
Player controller = game.getPlayer(controllerId);
if (controller != null) {
Set<Card> cardsToBattlefield = new HashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(controllerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
boolean creatureInGraveyard = false;
for (UUID cardId : player.getGraveyard()) {
Card card = game.getCard(cardId);
if (card != null && card.isCreature(game)) {
creatureInGraveyard = true;
break;
}
}
if (creatureInGraveyard) {
FilterCreatureCard filter = new FilterCreatureCard("creature card in " + player.getName() + "'s graveyard");
TargetCard target = new TargetCard(Zone.GRAVEYARD, filter);
target.setNotTarget(true);
controller.chooseTarget(controllerId.equals(playerId) ? Outcome.Benefit : Outcome.Detriment, player.getGraveyard(), target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cardsToBattlefield.add(card);
}
}
}
}
if (!cardsToBattlefield.isEmpty()) {
controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game);
cardsToBattlefield.removeIf(card -> game.getState().getZone(card.getId()) != Zone.BATTLEFIELD);
if (!cardsToBattlefield.isEmpty()) {
game.addEffect(new GhoulsNightOutTypeChangingEffect().setTargetPointer(new FixedTargets(cardsToBattlefield, game)), source);
game.addEffect(new GainAbilityTargetEffect(new DecayedAbility(), Duration.Custom).setTargetPointer(new FixedTargets(cardsToBattlefield, game)), source);
return true;
}
}
}
return false;
}
Aggregations