Search in sources :

Example 1 with CyclingAbility

use of mage.abilities.keyword.CyclingAbility in project mage by magefree.

the class AbandonedSarcophagusWatcher method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    boolean cardWasCycledThisTurn = false;
    boolean cardHasCycling = false;
    if (!(((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD)) {
        return false;
    }
    Player controller = game.getPlayer(source.getControllerId());
    AbandonedSarcophagusWatcher watcher = game.getState().getWatcher(AbandonedSarcophagusWatcher.class);
    Card card = game.getCard(event.getTargetId());
    if (card == null || controller == null || watcher == null || !card.isOwnedBy(controller.getId())) {
        return false;
    }
    for (Ability ability : card.getAbilities(game)) {
        if (ability instanceof CyclingAbility) {
            cardHasCycling = true;
        }
    }
    Cards cards = watcher.getCardsCycledThisTurn(controller.getId());
    for (Card c : cards.getCards(game)) {
        if (c == card) {
            cardWasCycledThisTurn = true;
            // remove reference to the card as it is no longer needed
            watcher.getCardsCycledThisTurn(controller.getId()).remove(card);
        }
    }
    return !cardWasCycledThisTurn && cardHasCycling;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) CyclingAbility(mage.abilities.keyword.CyclingAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) CyclingAbility(mage.abilities.keyword.CyclingAbility) FilterCard(mage.filter.FilterCard)

Example 2 with CyclingAbility

use of mage.abilities.keyword.CyclingAbility in project mage by magefree.

the class UnpredictableCycloneReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (!event.getPlayerId().equals(source.getControllerId())) {
        return false;
    }
    Player player = game.getPlayer(event.getPlayerId());
    // event.getSourceId() will be null for default draws (non effects)
    StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
    if (player == null || stackObject == null || stackObject.getStackAbility() == null || !(stackObject.getStackAbility() instanceof CyclingAbility)) {
        return false;
    }
    Card sourceCard = game.getCard(stackObject.getSourceId());
    return sourceCard != null && !sourceCard.isLand(game);
}
Also used : Player(mage.players.Player) CyclingAbility(mage.abilities.keyword.CyclingAbility) StackObject(mage.game.stack.StackObject)

Example 3 with CyclingAbility

use of mage.abilities.keyword.CyclingAbility in project mage by magefree.

the class SharkTyphoonTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getSourceId().equals(this.getSourceId())) {
        return false;
    }
    StackObject object = game.getStack().getStackObject(event.getSourceId());
    if (object == null || !(object.getStackAbility() instanceof CyclingAbility)) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new CreateTokenEffect(new SharkToken(object.getStackAbility().getManaCostsToPay().getX())));
    return true;
}
Also used : CyclingAbility(mage.abilities.keyword.CyclingAbility) StackObject(mage.game.stack.StackObject) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) SharkToken(mage.game.permanent.token.SharkToken)

Example 4 with CyclingAbility

use of mage.abilities.keyword.CyclingAbility in project mage by magefree.

the class YidaroWanderingMonsterWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.ACTIVATED_ABILITY) {
        return;
    }
    StackObject object = game.getStack().getStackObject(event.getSourceId());
    if (object == null || !(object.getStackAbility() instanceof CyclingAbility)) {
        return;
    }
    Card card = game.getCard(object.getSourceId());
    if (card != null && "Yidaro, Wandering Monster".equals(card.getName())) {
        countMap.merge(object.getControllerId(), 1, Integer::sum);
    }
}
Also used : CyclingAbility(mage.abilities.keyword.CyclingAbility) StackObject(mage.game.stack.StackObject) Card(mage.cards.Card)

Example 5 with CyclingAbility

use of mage.abilities.keyword.CyclingAbility in project mage by magefree.

the class ValiantRescuerWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.ACTIVATED_ABILITY || game.getState().getStack().isEmpty()) {
        return;
    }
    StackObject item = game.getState().getStack().getFirst();
    if (item instanceof StackAbility && item.getStackAbility() instanceof CyclingAbility) {
        playerMap.computeIfAbsent(event.getPlayerId(), u -> new HashMap<>());
        playerMap.get(event.getPlayerId()).compute(event.getSourceId(), CardUtil::setOrIncrementValue);
    }
}
Also used : CyclingAbility(mage.abilities.keyword.CyclingAbility) StackObject(mage.game.stack.StackObject) StackAbility(mage.game.stack.StackAbility) CardUtil(mage.util.CardUtil)

Aggregations

CyclingAbility (mage.abilities.keyword.CyclingAbility)6 StackObject (mage.game.stack.StackObject)5 StackAbility (mage.game.stack.StackAbility)2 Player (mage.players.Player)2 Ability (mage.abilities.Ability)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 Card (mage.cards.Card)1 FilterCard (mage.filter.FilterCard)1 SharkToken (mage.game.permanent.token.SharkToken)1 CardUtil (mage.util.CardUtil)1