Merge branch 'update_wrapped_description' into 'master'

Update the implementation of trigger replacing ABILITY text

Closes #1914

See merge request core-developers/forge!4976
This commit is contained in:
Michael Kamensky
2021-07-10 12:33:59 +00:00
4 changed files with 7 additions and 18 deletions

View File

@@ -28,7 +28,7 @@ public class RollDiceEffect extends SpellAbilityEffect {
String [] kv = ab.split(":"); String [] kv = ab.split(":");
String desc = sa.getAdditionalAbility(kv[0]).getDescription(); String desc = sa.getAdditionalAbility(kv[0]).getDescription();
if (!desc.isEmpty()) { if (!desc.isEmpty()) {
sb.append("\n\n").append(desc); sb.append("\n").append(desc);
} }
} }
} }

View File

@@ -193,13 +193,13 @@ public abstract class Trigger extends TriggerReplacementBase {
if (ApiType.Charm.equals(sa.getApi())) { if (ApiType.Charm.equals(sa.getApi())) {
saDesc = sa.getStackDescription(); saDesc = sa.getStackDescription();
} else { } else {
saDesc = sa.getDescription(); saDesc = sa.toString();
} }
} else if (ApiType.Charm.equals(sa.getApi())) { } else if (ApiType.Charm.equals(sa.getApi())) {
// use special formating, can be used in Card Description // use special formating, can be used in Card Description
saDesc = CharmEffect.makeFormatedDescription(sa); saDesc = CharmEffect.makeFormatedDescription(sa);
} else { } else {
saDesc = sa.getDescription(); saDesc = sa.toString();
} }
// string might have leading whitespace // string might have leading whitespace
saDesc = saDesc.trim(); saDesc = saDesc.trim();

View File

@@ -25,7 +25,6 @@ import forge.game.spellability.AbilitySub;
import forge.game.spellability.AlternativeCost; import forge.game.spellability.AlternativeCost;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.game.spellability.SpellAbilityRestriction; import forge.game.spellability.SpellAbilityRestriction;
import forge.game.spellability.SpellAbilityView;
import forge.game.spellability.TargetChoices; import forge.game.spellability.TargetChoices;
import forge.game.spellability.TargetRestrictions; import forge.game.spellability.TargetRestrictions;
@@ -62,12 +61,11 @@ public class WrappedAbility extends Ability {
boolean mandatory = false; boolean mandatory = false;
public WrappedAbility(final Trigger regtrig0, final SpellAbility sa0, final Player decider0) { public WrappedAbility(final Trigger regtrig0, final SpellAbility sa0, final Player decider0) {
super(sa0.getHostCard(), ManaCost.ZERO, sa0.getView()); super(sa0.getHostCard(), ManaCost.ZERO);
setTrigger(regtrig0); setTrigger(regtrig0);
sa = sa0; sa = sa0;
sa.setTrigger(regtrig0); sa.setTrigger(regtrig0);
decider = decider0; decider = decider0;
sa.setDescription(this.getStackDescription());
} }
public SpellAbility getWrappedAbility() { public SpellAbility getWrappedAbility() {
@@ -202,16 +200,6 @@ public class WrappedAbility extends Ability {
return sa.getSATargetingCard(); return sa.getSATargetingCard();
} }
@Override
public Card getHostCard() {
return sa.getHostCard();
}
@Override
public SpellAbilityView getView() {
return sa.getView();
}
// key for autoyield - if there is a trigger use its description as the wrapper now has triggering information in its description // key for autoyield - if there is a trigger use its description as the wrapper now has triggering information in its description
@Override @Override
public String yieldKey() { public String yieldKey() {
@@ -241,6 +229,7 @@ public class WrappedAbility extends Ability {
@Override @Override
public String getStackDescription() { public String getStackDescription() {
final Trigger regtrig = getTrigger(); final Trigger regtrig = getTrigger();
if (regtrig == null) return "";
final StringBuilder sb = new StringBuilder(regtrig.replaceAbilityText(regtrig.toString(true), this)); final StringBuilder sb = new StringBuilder(regtrig.replaceAbilityText(regtrig.toString(true), this));
List<TargetChoices> allTargets = sa.getAllTargetChoices(); List<TargetChoices> allTargets = sa.getAllTargetChoices();
if (!allTargets.isEmpty()) { if (!allTargets.isEmpty()) {

View File

@@ -2,9 +2,9 @@ Name:Aberrant Mind Sorcerer
ManaCost:4 U ManaCost:4 U
Types:Creature Human Elf Shaman Types:Creature Human Elf Shaman
PT:3/4 PT:3/4
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Creature.Self | Execute$ TrigPump | TriggerDescription$ Psionic Spells When CARDNAME enters the battlefield, choose target instant or sorcery card in your graveyard, then roll a d20. T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Creature.Self | Execute$ TrigPump | TriggerDescription$ Psionic Spells When CARDNAME enters the battlefield, choose target instant or sorcery card in your graveyard, then ABILITY
SVar:TrigPump:DB$ Pump | ValidTgts$ Instant.YouOwn,Sorcery.YouOwn | TgtZone$ Graveyard | TgtPrompt$ Choose target instant or sorcery card in your graveyard | SubAbility$ DBRollDice SVar:TrigPump:DB$ Pump | ValidTgts$ Instant.YouOwn,Sorcery.YouOwn | TgtZone$ Graveyard | TgtPrompt$ Choose target instant or sorcery card in your graveyard | SubAbility$ DBRollDice
SVar:DBRollDice:DB$ RollDice | Sides$ 20 | ResultSubAbilities$ 1-9:DBLibrary,10-20:DBHand SVar:DBRollDice:DB$ RollDice | Sides$ 20 | ResultSubAbilities$ 1-9:DBLibrary,10-20:DBHand | SpellDescription$ roll a d20.
SVar:DBLibrary:DB$ ChangeZone | Defined$ Targeted | Origin$ Graveyard | Destination$ Library | LibraryPosition$ 0 | Optional$ True | SpellDescription$ 1-9 VERT You may put that card on top of your library. SVar:DBLibrary:DB$ ChangeZone | Defined$ Targeted | Origin$ Graveyard | Destination$ Library | LibraryPosition$ 0 | Optional$ True | SpellDescription$ 1-9 VERT You may put that card on top of your library.
SVar:DBHand:DB$ ChangeZone | Defined$ Targeted | Origin$ Graveyard | Destination$ Hand | SpellDescription$ 10-20 VERT Return that card to your hand. SVar:DBHand:DB$ ChangeZone | Defined$ Targeted | Origin$ Graveyard | Destination$ Hand | SpellDescription$ 10-20 VERT Return that card to your hand.
Oracle:Psionic Spells — When Aberrant Mind Sorcerer enters the battlefield, choose target instant or sorcery card in your graveyard, then roll a d20.\n1-9 | You may put that card on top of your library.\n10-20 | Return that card to your hand. Oracle:Psionic Spells — When Aberrant Mind Sorcerer enters the battlefield, choose target instant or sorcery card in your graveyard, then roll a d20.\n1-9 | You may put that card on top of your library.\n10-20 | Return that card to your hand.