[AFR] improved flavor words, added support in ETB abilities (#7952, #7808);

This commit is contained in:
Oleg Agafonov 2021-06-30 17:47:11 +04:00
parent 93ea276e83
commit bbd3f266f0
34 changed files with 125 additions and 75 deletions

View file

@ -1,5 +1,6 @@
package mage.abilities.common;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
@ -11,31 +12,26 @@ import mage.game.events.GameEvent;
*/
public class EntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl {
protected String rulePrefix;
protected boolean noRule;
protected boolean ignoreRulesGeneration; // use it with custom rules (if you don't want ETB auto-generated text)
protected String etbFlavorWord = null;
public EntersBattlefieldTriggeredAbility(Effect effect) {
this(effect, false);
}
public EntersBattlefieldTriggeredAbility(Effect effect, boolean optional) {
this(effect, optional, null);
this(effect, optional, false);
}
public EntersBattlefieldTriggeredAbility(Effect effect, boolean optional, boolean noRule) {
this(effect, optional, null);
this.noRule = noRule;
}
public EntersBattlefieldTriggeredAbility(Effect effect, boolean optional, String rulePrefix) {
public EntersBattlefieldTriggeredAbility(Effect effect, boolean optional, boolean ignoreRulesGeneration) {
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.rulePrefix = rulePrefix;
this.ignoreRulesGeneration = ignoreRulesGeneration;
}
public EntersBattlefieldTriggeredAbility(final EntersBattlefieldTriggeredAbility ability) {
super(ability);
this.rulePrefix = ability.rulePrefix;
this.noRule = ability.noRule;
this.ignoreRulesGeneration = ability.ignoreRulesGeneration;
this.etbFlavorWord = ability.etbFlavorWord;
}
@Override
@ -52,12 +48,21 @@ public class EntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl {
return false;
}
@Override
public Ability withFlavorWord(String flavorWord) {
// must put flavor word before auto-generated rules, so keep it in etb place
super.withFlavorWord(null);
this.etbFlavorWord = flavorWord;
return this;
}
@Override
public String getRule() {
if (noRule) {
if (ignoreRulesGeneration) {
return super.getRule();
}
return (rulePrefix != null ? rulePrefix : "") + "When {this} enters the battlefield, " + super.getRule();
return (this.etbFlavorWord == null ? "" : "<i>" + this.etbFlavorWord + "</i> &mdash; ")
+ "When {this} enters the battlefield, " + super.getRule();
}
@Override

View file

@ -12,7 +12,7 @@ public class EntersBattlefieldUntappedTriggeredAbility extends EntersBattlefield
public EntersBattlefieldUntappedTriggeredAbility(Effect effect, boolean optional) {
super(effect, optional);
this.noRule = true;
this.ignoreRulesGeneration = true;
}
private EntersBattlefieldUntappedTriggeredAbility(final EntersBattlefieldUntappedTriggeredAbility ability) {