use of mage.abilities.costs.common.CyclingDiscardCost in project mage by magefree.
the class YidaroWanderingMonsterWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Costs<Cost> costs = (Costs) this.getValue("cycleCosts");
if (costs == null) {
return false;
}
MageObjectReference cycledCard = costs.stream().filter(CyclingDiscardCost.class::isInstance).map(CyclingDiscardCost.class::cast).map(CyclingDiscardCost::getCycledCard).findFirst().orElse(null);
if (cycledCard == null || game.getState().getZone(cycledCard.getSourceId()) != Zone.GRAVEYARD) {
return false;
}
Card card = cycledCard.getCard(game);
if (card == null) {
return false;
}
YidaroWanderingMonsterWatcher watcher = game.getState().getWatcher(YidaroWanderingMonsterWatcher.class);
if (watcher == null || watcher.getYidaroCount(player.getId()) < 4) {
player.putCardsOnBottomOfLibrary(card, game, source, true);
player.shuffleLibrary(source, game);
} else {
player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
return true;
}
use of mage.abilities.costs.common.CyclingDiscardCost in project mage by magefree.
the class NewPerspectivesCostModificationEffect method apply.
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
Player controller = game.getPlayer(abilityToModify.getControllerId());
if (controller != null) {
if (game.inCheckPlayableState() || controller.chooseUse(Outcome.PlayForFree, "Pay {0} to cycle?", source, game)) {
abilityToModify.getCosts().clear();
abilityToModify.getManaCostsToPay().clear();
abilityToModify.getCosts().add(new CyclingDiscardCost());
}
return true;
}
return false;
}
Aggregations