Search in sources :

Example 1 with CyclingDiscardCost

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;
}
Also used : Player(mage.players.Player) Costs(mage.abilities.costs.Costs) Cost(mage.abilities.costs.Cost) CyclingDiscardCost(mage.abilities.costs.common.CyclingDiscardCost) MageObjectReference(mage.MageObjectReference) CyclingDiscardCost(mage.abilities.costs.common.CyclingDiscardCost) Card(mage.cards.Card)

Example 2 with CyclingDiscardCost

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;
}
Also used : Player(mage.players.Player) CyclingDiscardCost(mage.abilities.costs.common.CyclingDiscardCost)

Aggregations

CyclingDiscardCost (mage.abilities.costs.common.CyclingDiscardCost)2 Player (mage.players.Player)2 MageObjectReference (mage.MageObjectReference)1 Cost (mage.abilities.costs.Cost)1 Costs (mage.abilities.costs.Costs)1 Card (mage.cards.Card)1