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;
}
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);
}
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;
}
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);
}
}
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);
}
}
Aggregations