mage/Mage/src/main/java/mage/abilities/Mode.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

88 lines
2 KiB
Java

package mage.abilities;
import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects;
import mage.target.Target;
import mage.target.Targets;
import java.io.Serializable;
import java.util.UUID;
/**
* @author BetaSteward_at_googlemail.com
*/
public class Mode implements Serializable {
protected UUID id;
protected final Targets targets;
protected final Effects effects;
protected String flavorWord;
public Mode(Effect effect) {
this.id = UUID.randomUUID();
this.targets = new Targets();
this.effects = new Effects();
if (effect != null) {
this.effects.add(effect);
}
}
protected Mode(final Mode mode) {
this.id = mode.id;
this.targets = mode.targets.copy();
this.effects = mode.effects.copy();
this.flavorWord = mode.flavorWord;
}
public UUID setRandomId() {
return this.id = UUID.randomUUID();
}
public Mode copy() {
return new Mode(this);
}
public UUID getId() {
return id;
}
public Targets getTargets() {
return targets;
}
public Mode addTarget(Target target) {
return this.addTarget(target, false);
}
public Mode addTarget(Target target, Boolean addChooseHintFromEffect) {
targets.add(target);
if (addChooseHintFromEffect) {
target.withChooseHint(this.getEffects().getText(this));
}
return this;
}
public Effects getEffects() {
return effects;
}
public Mode addEffect(Effect effect) {
effects.add(effect);
return this;
}
public String getFlavorWord() {
return flavorWord;
}
/**
* Set Flavor word for choice in the mode (same as ability/ancher words, but uses for lore/info and represents a possible choices)
*
* @param flavorWord
* @return
*/
public Mode withFlavorWord(String flavorWord) {
this.flavorWord = flavorWord;
return this;
}
}