refactor: use setter method and private field

This commit is contained in:
xenohedron 2024-04-12 20:11:04 -04:00
parent 577a3708fc
commit f3fccfbd8a
29 changed files with 31 additions and 31 deletions

View file

@ -47,7 +47,7 @@ class HiddenPredatorsStateTriggeredAbility extends StateTriggeredAbility {
public HiddenPredatorsStateTriggeredAbility() {
super(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new HiddenPredatorsToken(), null, Duration.Custom));
this.replaceRuleText = false;
this.withRuleTextReplacement(false);
setTriggerPhrase("When an opponent controls a creature with power 4 or greater, if {this} is an enchantment, ");
}

View file

@ -42,7 +42,7 @@ class LurkingJackalsStateTriggeredAbility extends StateTriggeredAbility {
public LurkingJackalsStateTriggeredAbility() {
super(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new LurkingJackalsToken(), null, Duration.Custom));
setTriggerPhrase("When an opponent has 10 or less life, if {this} is an enchantment, ");
this.replaceRuleText = true;
this.withRuleTextReplacement(true);
}
private LurkingJackalsStateTriggeredAbility(final LurkingJackalsStateTriggeredAbility ability) {

View file

@ -39,9 +39,9 @@ public final class OpalAvenger extends CardImpl {
class OpalAvengerStateTriggeredAbility extends StateTriggeredAbility {
public OpalAvengerStateTriggeredAbility() {
OpalAvengerStateTriggeredAbility() {
super(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new OpalAvengerToken(), null, Duration.Custom));
this.replaceRuleText = false;
this.withRuleTextReplacement(false);
setTriggerPhrase("When you have 10 or less life, if {this} is an enchantment, ");
}

View file

@ -42,7 +42,7 @@ class VeiledCrocodileStateTriggeredAbility extends StateTriggeredAbility {
public VeiledCrocodileStateTriggeredAbility() {
super(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new VeilCrocodileToken(), null, Duration.Custom));
this.replaceRuleText = false;
this.withRuleTextReplacement(false);
setTriggerPhrase("When a player has no cards in hand, if {this} is an enchantment, ");
}

View file

@ -51,7 +51,7 @@ class ZhurTaaDruidAbility extends TriggeredAbilityImpl {
ZhurTaaDruidAbility() {
super(Zone.BATTLEFIELD, new DamagePlayersEffect(1, TargetController.OPPONENT));
setTriggerPhrase("Whenever you tap {this} for mana, ");
this.replaceRuleText = true;
this.withRuleTextReplacement(true);
}
private ZhurTaaDruidAbility(final ZhurTaaDruidAbility ability) {

View file

@ -27,7 +27,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
private boolean leavesTheBattlefieldTrigger;
private boolean triggersOnceEachTurn = false;
private boolean doOnlyOnceEachTurn = false;
protected boolean replaceRuleText = false; // if true, replace "{this}" with "it" in effect text
private boolean replaceRuleText = false; // if true, replace "{this}" with "it" in effect text
private GameEvent triggerEvent = null;
private String triggerPhrase = null;

View file

@ -16,7 +16,7 @@ public class AttacksAloneSourceTriggeredAbility extends TriggeredAbilityImpl {
public AttacksAloneSourceTriggeredAbility(Effect effect) {
super(Zone.BATTLEFIELD, effect);
setTriggerPhrase("Whenever {this} attacks alone, ");
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
}
protected AttacksAloneSourceTriggeredAbility(final AttacksAloneSourceTriggeredAbility ability) {

View file

@ -24,7 +24,7 @@ public class AttacksAndIsNotBlockedTriggeredAbility extends TriggeredAbilityImpl
super(Zone.BATTLEFIELD, effect, optional);
this.setTargetPointer = setTargetPointer;
setTriggerPhrase("Whenever {this} attacks and isn't blocked, ");
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
}
protected AttacksAndIsNotBlockedTriggeredAbility(final AttacksAndIsNotBlockedTriggeredAbility ability) {

View file

@ -16,7 +16,7 @@ public class AttacksOrBlocksTriggeredAbility extends TriggeredAbilityImpl {
} else {
setTriggerPhrase("Whenever {this} attacks or blocks, ");
}
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
}
protected AttacksOrBlocksTriggeredAbility(final AttacksOrBlocksTriggeredAbility ability) {

View file

@ -35,7 +35,7 @@ public class AttacksTriggeredAbility extends TriggeredAbilityImpl {
this.text = text;
this.setTargetPointer = setTargetPointer;
setTriggerPhrase("Whenever {this} attacks, ");
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
}
protected AttacksTriggeredAbility(final AttacksTriggeredAbility ability) {

View file

@ -24,7 +24,7 @@ public class BecomesBlockedByCreatureTriggeredAbility extends TriggeredAbilityIm
public BecomesBlockedByCreatureTriggeredAbility(Effect effect, FilterCreaturePermanent filter, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
this.filter = filter;
this.replaceRuleText = false;
this.withRuleTextReplacement(false);
setTriggerPhrase("Whenever {this} becomes blocked by " + CardUtil.addArticle(filter.getMessage()) + ", ");
}

View file

@ -22,7 +22,7 @@ public class BecomesBlockedSourceTriggeredAbility extends TriggeredAbilityImpl {
super(Zone.BATTLEFIELD, effect, optional);
this.setTargetPointer = setTargetPointer;
setTriggerPhrase(getWhen() + "{this} becomes blocked, ");
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
}
protected BecomesBlockedSourceTriggeredAbility(final BecomesBlockedSourceTriggeredAbility ability) {

View file

@ -14,7 +14,7 @@ public class BecomesPlottedSourceTriggeredAbility extends TriggeredAbilityImpl {
public BecomesPlottedSourceTriggeredAbility(Effect effect, boolean optional) {
super(Zone.EXILED, effect, optional);
setTriggerPhrase("When {this} becomes plotted, ");
replaceRuleText = true;
this.withRuleTextReplacement(true);
}
public BecomesPlottedSourceTriggeredAbility(Effect effect) {

View file

@ -19,7 +19,7 @@ public class BecomesTappedSourceTriggeredAbility extends TriggeredAbilityImpl {
public BecomesTappedSourceTriggeredAbility(Effect effect, boolean isOptional) {
super(Zone.BATTLEFIELD, effect, isOptional);
setTriggerPhrase("Whenever {this} becomes tapped, ");
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
}
protected BecomesTappedSourceTriggeredAbility(final BecomesTappedSourceTriggeredAbility ability) {

View file

@ -33,7 +33,7 @@ public class BecomesTargetSourceTriggeredAbility extends TriggeredAbilityImpl {
this.filter = filter;
this.setTargetPointer = setTargetPointer;
setTriggerPhrase(getWhen() + "{this} becomes the target of " + filter.getMessage() + ", ");
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
}
protected BecomesTargetSourceTriggeredAbility(final BecomesTargetSourceTriggeredAbility ability) {

View file

@ -32,7 +32,7 @@ public class BlocksOrBecomesBlockedByOneOrMoreTriggeredAbility extends Triggered
public BlocksOrBecomesBlockedByOneOrMoreTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional, String rule) {
super(Zone.BATTLEFIELD, effect, optional);
this.filter = filter;
this.replaceRuleText = false;
this.withRuleTextReplacement(false);
this.rule = rule;
setTriggerPhrase("Whenever {this} blocks or becomes blocked by one or more " + (filter != null ? filter.getMessage() : "creatures") + ", ");
}

View file

@ -18,7 +18,7 @@ public class BlocksSourceTriggeredAbility extends TriggeredAbilityImpl {
public BlocksSourceTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
setTriggerPhrase("Whenever {this} blocks, ");
this.replaceRuleText = true;
this.withRuleTextReplacement(true);
}
protected BlocksSourceTriggeredAbility(final BlocksSourceTriggeredAbility ability) {

View file

@ -14,7 +14,7 @@ public class CycleTriggeredAbility extends ZoneChangeTriggeredAbility {
public CycleTriggeredAbility(Effect effect, boolean optional) {
super(Zone.ALL, effect, "When you cycle {this}, ", optional);
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
}
public CycleTriggeredAbility(Effect effect) {

View file

@ -23,7 +23,7 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
super(Zone.BATTLEFIELD, effect, optional);
this.setTargetPointer = setTargetPointer;
setTriggerPhrase(getWhen() + "{this} deals combat damage to a player, ");
this.replaceRuleText = true;
this.withRuleTextReplacement(true);
}
protected DealsCombatDamageToAPlayerTriggeredAbility(final DealsCombatDamageToAPlayerTriggeredAbility ability) {

View file

@ -20,7 +20,7 @@ public class DealsCombatDamageTriggeredAbility extends TriggeredAbilityImpl {
public DealsCombatDamageTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
setTriggerPhrase(getWhen() + "{this} deals combat damage, ");
this.replaceRuleText = true;
this.withRuleTextReplacement(true);
}
protected DealsCombatDamageTriggeredAbility(final DealsCombatDamageTriggeredAbility ability) {

View file

@ -23,7 +23,7 @@ public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl {
this.setAbilityWord(AbilityWord.ENRAGE);
}
setTriggerPhrase("Whenever {this} is dealt damage, ");
this.replaceRuleText = true;
this.withRuleTextReplacement(true);
}
protected DealtDamageToSourceTriggeredAbility(final DealtDamageToSourceTriggeredAbility ability) {

View file

@ -15,7 +15,7 @@ public class DiesSourceTriggeredAbility extends ZoneChangeTriggeredAbility {
public DiesSourceTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, Zone.GRAVEYARD, effect, "When {this} dies, ", optional);
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
}
public DiesSourceTriggeredAbility(Effect effect) {

View file

@ -17,7 +17,7 @@ public class EntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl {
public EntersBattlefieldTriggeredAbility(Effect effect, boolean optional) {
super(Zone.ALL, effect, optional); // Zone.All because a creature with trigger can be put into play and be sacrificed during the resolution of an effect (discard Obstinate Baloth with Smallpox)
this.replaceRuleText = true; // default true to replace "{this}" with "it"
this.withRuleTextReplacement(true); // default true to replace "{this}" with "it"
setTriggerPhrase("When {this} enters the battlefield, ");
}

View file

@ -14,7 +14,7 @@ public class SourcePhaseInTriggeredAbility extends TriggeredAbilityImpl {
public SourcePhaseInTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
setTriggerPhrase("Whenever {this} phases in, ");
this.replaceRuleText = true;
this.withRuleTextReplacement(true);
}
protected SourcePhaseInTriggeredAbility(final SourcePhaseInTriggeredAbility ability) {

View file

@ -29,7 +29,7 @@ public class TurnedFaceUpSourceTriggeredAbility extends TriggeredAbilityImpl {
this.setWorksFaceDown(true);
this.setTargetPointer = setTargetPointer;
setTriggerPhrase("When {this} is turned face up, ");
this.replaceRuleText = true;
this.withRuleTextReplacement(true);
}
protected TurnedFaceUpSourceTriggeredAbility(final TurnedFaceUpSourceTriggeredAbility ability) {

View file

@ -34,7 +34,7 @@ public class HeroicAbility extends TriggeredAbilityImpl {
if (isHeroic) {
this.setAbilityWord(AbilityWord.HEROIC);
}
this.replaceRuleText = false;
this.withRuleTextReplacement(false);
setTriggerPhrase("Whenever you cast a spell that targets {this}, ");
}

View file

@ -28,7 +28,7 @@ public class InspiredAbility extends TriggeredAbilityImpl {
setAbilityWord(AbilityWord.INSPIRED);
}
setTriggerPhrase("Whenever {this} becomes untapped, ");
this.replaceRuleText = true;
this.withRuleTextReplacement(true);
}
protected InspiredAbility(final InspiredAbility ability) {

View file

@ -17,7 +17,7 @@ public class PackTacticsAbility extends TriggeredAbilityImpl {
public PackTacticsAbility(Effect effect) {
super(Zone.BATTLEFIELD, effect, false);
this.replaceRuleText = false;
this.withRuleTextReplacement(false);
this.setAbilityWord(AbilityWord.PACK_TACTICS);
setTriggerPhrase("Whenever {this} attacks, if you attacked with creatures with total power 6 or greater this combat, ");
}

View file

@ -37,7 +37,7 @@ public class OrTriggeredAbility extends TriggeredAbilityImpl {
public OrTriggeredAbility(Zone zone, Effect effect, boolean optional, String ruleTrigger, TriggeredAbility... abilities) {
super(zone, effect, optional);
this.ruleTrigger = ruleTrigger;
this.replaceRuleText = false;
this.withRuleTextReplacement(false);
Collections.addAll(this.triggeredAbilities, abilities);
for (TriggeredAbility ability : triggeredAbilities) {
//Remove useless data