Merge pull request #3031 from Northmoc/mat_tranquil

MAT: tranquil_frillback.txt + support/related
This commit is contained in:
Anthony Calosa
2023-05-25 06:08:20 +08:00
committed by GitHub
11 changed files with 76 additions and 34 deletions

View File

@@ -53,6 +53,10 @@ public class CharmEffect extends SpellAbilityEffect {
}
public static String makeFormatedDescription(SpellAbility sa) {
return makeFormatedDescription(sa, true);
}
public static String makeFormatedDescription(SpellAbility sa, boolean includeChosen) {
Card source = sa.getHostCard();
List<AbilitySub> list = CharmEffect.makePossibleOptions(sa);
@@ -83,7 +87,7 @@ public class CharmEffect extends SpellAbilityEffect {
sb.append(oppChooses ? "An opponent chooses " : "Choose ");
if (num == min || num == Integer.MAX_VALUE) {
sb.append(Lang.getNumeral(min));
sb.append(num == 0 ? "up to that many" : Lang.getNumeral(min));
} else if (min == 0 && num == sa.getParam("Choices").split(",").length) {
sb.append("any number ");
} else if (min == 0) {
@@ -137,7 +141,9 @@ public class CharmEffect extends SpellAbilityEffect {
}
}
if (!list.isEmpty()) {
if (!includeChosen) {
sb.append(num == 1 ? " mode." : " modes.");
} else if (!list.isEmpty()) {
if (!repeat && !additionalDesc && !limit && !gameLimit) {
sb.append(" \u2014");
}
@@ -146,6 +152,7 @@ public class CharmEffect extends SpellAbilityEffect {
sb.append("\u2022 ").append(sub.getParam("SpellDescription"));
sb.append("\r\n");
}
sb.append("\r\n");
}
return sb.toString();
}

View File

@@ -17,23 +17,10 @@
*/
package forge.game.trigger;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import forge.game.Game;
import forge.game.GameEntity;
import forge.game.GameStage;
import forge.game.IHasSVars;
import forge.game.TriggerReplacementBase;
import forge.game.*;
import forge.game.ability.AbilityFactory;
import forge.game.ability.AbilityKey;
import forge.game.ability.ApiType;
@@ -50,6 +37,8 @@ import forge.util.CardTranslation;
import forge.util.Lang;
import forge.util.TextUtil;
import java.util.*;
/**
* <p>
* Abstract Trigger class. Constructed by reflection only
@@ -167,6 +156,10 @@ public abstract class Trigger extends TriggerReplacementBase {
}
public final String replaceAbilityText(final String desc, SpellAbility sa) {
return replaceAbilityText(desc, sa, false);
}
public final String replaceAbilityText(final String desc, SpellAbility sa, boolean forStack) {
String result = desc;
// this function is for ABILITY
@@ -177,23 +170,41 @@ public abstract class Trigger extends TriggerReplacementBase {
sa = getOverridingAbility();
}
if (sa != null) {
String saDesc;
String saDesc = "";
boolean digMore = true;
// if sa is a wrapper, get the Wrapped Ability
if (sa.isWrapper()) {
final WrappedAbility wa = (WrappedAbility) sa;
sa = wa.getWrappedAbility();
// wrapped Charm spells are special,
// only get the selected abilities
// wrapped Charm spells are special, only get the selected abilities (if there are any yet)
if (ApiType.Charm.equals(sa.getApi())) {
saDesc = sa.getStackDescription();
} else {
saDesc = sa.toString();
digMore = false;
}
} else if (ApiType.Charm.equals(sa.getApi())) {
// use special formating, can be used in Card Description
saDesc = CharmEffect.makeFormatedDescription(sa);
} else {
}
if (digMore) { // if ABILITY is used, there is probably Charm somewhere
while (sa != null) {
ApiType api = sa.getApi();
if (ApiType.Charm.equals(api)) {
saDesc = CharmEffect.makeFormatedDescription(sa, !forStack);
break;
}
if (ApiType.ImmediateTrigger.equals(api) || ApiType.DelayedTrigger.equals(api)) {
SpellAbility trigSA = sa.getAdditionalAbility("Execute");
while (trigSA != null) {
if (ApiType.Charm.equals(trigSA.getApi())) {
saDesc = CharmEffect.makeFormatedDescription(trigSA, !forStack);
break;
}
trigSA = trigSA.getSubAbility();
}
break;
}
sa = sa.getSubAbility();
}
}
if (saDesc.equals("")) { // in case we haven't found anything better
saDesc = sa.toString();
}
// string might have leading whitespace

View File

@@ -229,7 +229,8 @@ public class WrappedAbility extends Ability {
public String getStackDescription() {
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, true));
List<TargetChoices> allTargets = sa.getAllTargetChoices();
if (!allTargets.isEmpty() && !ApiType.Charm.equals(sa.getApi())) {
sb.append(" (Targeting: ");