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

52 lines
1.5 KiB
Java

package mage.abilities.common;
import mage.abilities.StaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.constants.EnterEventType;
import mage.constants.Zone;
/**
* @author North
*/
public class AsEntersBattlefieldAbility extends StaticAbility {
public AsEntersBattlefieldAbility(Effect effect) {
this(effect, null, EnterEventType.OTHER);
}
public AsEntersBattlefieldAbility(Effect effect, String text) {
this(effect, text, EnterEventType.OTHER);
}
public AsEntersBattlefieldAbility(Effect effect, String text, EnterEventType enterEventType) {
super(Zone.ALL, new EntersBattlefieldEffect(effect, null, text, true, false, enterEventType));
}
protected AsEntersBattlefieldAbility(final AsEntersBattlefieldAbility ability) {
super(ability);
}
@Override
public void addEffect(Effect effect) {
if (!getEffects().isEmpty()) {
Effect entersEffect = this.getEffects().get(0);
if (entersEffect instanceof EntersBattlefieldEffect) {
((EntersBattlefieldEffect) entersEffect).addEffect(effect);
return;
}
}
super.addEffect(effect);
}
@Override
public AsEntersBattlefieldAbility copy() {
return new AsEntersBattlefieldAbility(this);
}
@Override
public String getRule() {
return "As {this} enters the battlefield, " + super.getRule();
}
}