foul-magics/Mage/src/main/java/mage/abilities/common/CycleAllTriggeredAbility.java
Susucre f75b1c9f0a
Code cleanup: protect all copy constructors (#10750)
* apply regex to change public copy constructors to protected
* cleanup code using now protected constructors
* fix manaBuilder weird casting of Mana into ConditionalMana
2023-08-04 19:34:58 -04:00

46 lines
1.3 KiB
Java

package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.keyword.CyclingAbility;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.StackAbility;
import mage.game.stack.StackObject;
/**
* @author LevelX2
*/
public class CycleAllTriggeredAbility extends TriggeredAbilityImpl {
public CycleAllTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
setTriggerPhrase("Whenever a player cycles a card, ");
}
protected CycleAllTriggeredAbility(final CycleAllTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ACTIVATED_ABILITY;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getState().getStack().isEmpty()) {
return false;
}
StackObject item = game.getState().getStack().getFirst();
return item instanceof StackAbility
&& item.getStackAbility() instanceof CyclingAbility;
}
@Override
public CycleAllTriggeredAbility copy() {
return new CycleAllTriggeredAbility(this);
}
}