foul-magics/Mage/src/main/java/mage/abilities/abilityword/ConstellationAbility.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

62 lines
1.8 KiB
Java

package mage.abilities.abilityword;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.AbilityWord;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
/**
* Constellation
*
* @author LevelX2
*/
public class ConstellationAbility extends TriggeredAbilityImpl {
private final boolean thisOr;
public ConstellationAbility(Effect effect) {
this(effect, false);
}
public ConstellationAbility(Effect effect, boolean optional) {
this(effect, optional, true);
}
public ConstellationAbility(Effect effect, boolean optional, boolean thisOr) {
super(Zone.BATTLEFIELD, effect, optional);
this.thisOr = thisOr;
setAbilityWord(AbilityWord.CONSTELLATION);
setTriggerPhrase("Whenever " + (thisOr ? "{this} or another" : "an")
+ " enchantment enters the battlefield under your control, ");
}
protected ConstellationAbility(final ConstellationAbility ability) {
super(ability);
this.thisOr = ability.thisOr;
}
@Override
public ConstellationAbility copy() {
return new ConstellationAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getPlayerId().equals(this.getControllerId())) {
return false;
}
Permanent permanent = game.getPermanent(event.getTargetId());
return permanent != null && ((thisOr && permanent.getId().equals(getSourceId())) || permanent.isEnchantment(game));
}
}