Treat replaceAbilityText bandaids

This commit is contained in:
tool4EvEr
2023-05-25 22:04:17 +02:00
parent ea4cfaf9b7
commit d4030e0f1d
6 changed files with 23 additions and 24 deletions

View File

@@ -5,6 +5,7 @@ import java.util.Map;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import forge.ai.ComputerUtil;
import forge.ai.ComputerUtilAbility;
@@ -310,8 +311,15 @@ public class UntapAi extends SpellAbilityAi {
@Override
public Card chooseSingleCard(Player ai, SpellAbility sa, Iterable<Card> list, boolean isOptional, Player targetedPlayer, Map<String, Object> params) {
PlayerCollection pl = ai.getYourTeam();
return ComputerUtilCard.getBestAI(CardLists.filterControlledBy(list, pl));
CardCollection pref = CardLists.filterControlledBy(list, ai.getYourTeam());
if (Iterables.isEmpty(pref)) {
if (isOptional) {
return null;
}
} else {
list = pref;
}
return ComputerUtilCard.getBestAI(list);
}
private static Card detectPriorityUntapTargets(final List<Card> untapList) {

View File

@@ -55,7 +55,6 @@ 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();

View File

@@ -158,7 +158,6 @@ 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;
@@ -184,28 +183,21 @@ public abstract class Trigger extends TriggerReplacementBase {
}
}
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");
SpellAbility trigSA = sa;
while (trigSA != null) {
if (ApiType.Charm.equals(trigSA.getApi())) {
ApiType api = trigSA.getApi();
if (ApiType.Charm.equals(api)) {
saDesc = CharmEffect.makeFormatedDescription(trigSA, !forStack);
break;
}
trigSA = trigSA.getSubAbility();
if (ApiType.ImmediateTrigger.equals(api) || ApiType.DelayedTrigger.equals(api)) {
trigSA = sa.getAdditionalAbility("Execute");
} else {
trigSA = sa.getSubAbility();
}
break;
}
sa = sa.getSubAbility();
}
}
if (saDesc.equals("")) { // in case we haven't found anything better
if (sa != null)
saDesc = sa.toString();
}
// string might have leading whitespace
@@ -223,7 +215,7 @@ public abstract class Trigger extends TriggerReplacementBase {
}
result = TextUtil.fastReplace(result, "ABILITY", saDesc);
String currentName = sa == null ? "" : sa.getHostCard().getName();
String currentName = sa.getHostCard().getName();
result = CardTranslation.translateMultipleDescriptionText(result, currentName);
result = TextUtil.fastReplace(result,"CARDNAME", CardTranslation.getTranslatedName(currentName));
result = TextUtil.fastReplace(result,"NICKNAME", Lang.getInstance().getNickName(CardTranslation.getTranslatedName(currentName)));

View File

@@ -7,7 +7,7 @@ T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.S
SVar:TrigDig:DB$ DigUntil | Defined$ Player | Valid$ Card.nonLand | FoundDestination$ Exile | RevealedDestination$ Exile | RememberFound$ True | SubAbility$ DBPlay
SVar:DBPlay:DB$ Play | Controller$ You | Defined$ Remembered | WithoutManaCost$ True | ValidSA$ Spell | Optional$ True | Amount$ All | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
A:AB$ SetState | Cost$ 9 GP | Defined$ Self | Mode$ Transform | SorcerySpeed$ True | AILogic$ Always | SpellDescription$ Transform CARDNAME. Activate only as a sorcery.
A:AB$ SetState | Cost$ 9 GP | Defined$ Self | Mode$ Transform | SorcerySpeed$ True | AILogic$ Always | SpellDescription$ Transform NICKNAME. Activate only as a sorcery.
AlternateMode:DoubleFaced
Oracle:Trample\nWhen Etali, Primal Conqueror enters the battlefield, each player exiles cards from the top of their library until they exile a nonland card. You may cast any number of spells from among the nonland cards exiled this way without paying their mana costs.\n{9}{G/P}: Transform Etali. Activate only as a sorcery.

View File

@@ -4,7 +4,7 @@ Types:Legendary Creature Merfolk Rogue
PT:4/4
K:Flash
A:AB$ ChangeZone | Cost$ 2 U B Return<1/Rogue.unblocked+attacking+YouCtrl/unblocked attacking Rogue you control> | ActivationZone$ Hand | Defined$ Self | Origin$ Hand | Destination$ Battlefield | Tapped$ True | Attacking$ True | SpellDescription$ Put CARDNAME from your hand onto the battlefield tapped and attacking.
T:Mode$ DamageDone | ValidSource$ Card.Self | ValidTarget$ Player | CombatDamage$ True | Execute$ TrigGainControl | OptionalDecider$ You | TriggerDescription$ Whenever CARDNAME deals combat damage to a player, you may put target permanent card from that player's graveyard onto the battlefield under your control.
T:Mode$ DamageDone | ValidSource$ Card.Self | ValidTarget$ Player | CombatDamage$ True | Execute$ TrigGainControl | OptionalDecider$ You | TriggerDescription$ Whenever NICKNAME deals combat damage to a player, you may put target permanent card from that player's graveyard onto the battlefield under your control.
SVar:TrigGainControl:DB$ ChangeZone | Origin$ Graveyard | Destination$ Battlefield | GainControl$ True | ValidTgts$ Permanent | TargetsWithDefinedController$ TriggeredTarget | TgtPrompt$ Select target permanent in opponent's graveyard
DeckHints:Type$Rogue
Oracle:Flash\n{2}{U}{B}, Return an unblocked attacking Rogue you control to its owner's hand: Put Zareth San, the Trickster from your hand onto the battlefield tapped and attacking.\nWhenever Zareth San deals combat damage to a player, you may put target permanent card from that player's graveyard onto the battlefield under your control.