foul-magics/Mage/src/main/java/mage/abilities/effects/common/DamageSelfEffect.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.3 KiB
Java

package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* @author North, Quercitron
*/
public class DamageSelfEffect extends OneShotEffect {
protected int amount;
public DamageSelfEffect(int amount) {
super(Outcome.Damage);
this.amount = amount;
}
protected DamageSelfEffect(final DamageSelfEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public DamageSelfEffect copy() {
return new DamageSelfEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.damage(amount, source.getSourceId(), source, game, false, true);
return true;
}
return false;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
sb.append("{this} deals ").append(amount).append(" damage to itself");
return sb.toString();
}
}