Merge pull request #2467 from Northmoc/stackDesc

More (hopefully better) StackDesc tweaks
This commit is contained in:
Anthony Calosa
2023-02-14 16:22:05 +08:00
committed by GitHub
7 changed files with 34 additions and 16 deletions

View File

@@ -1251,6 +1251,13 @@ public class AbilityUtils {
else if (defined.startsWith("NextPlayerToYour")) {
Direction dir = defined.substring(16).equals("Left") ? Direction.Left : Direction.Right;
players.add(game.getNextPlayerAfter(player, dir));
} else if (defined.startsWith("NextOpponentToYour")) {
Direction dir = defined.substring(18).equals("Left") ? Direction.Left : Direction.Right;
Player next = game.getNextPlayerAfter(player, dir);
while (!next.isOpponentOf(player)) {
next = game.getNextPlayerAfter(next, dir);
}
players.add(next);
}
else {
// will be filtered below

View File

@@ -6,7 +6,6 @@ import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import forge.util.lang.LangEnglish;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Iterables;
@@ -82,7 +81,7 @@ public abstract class SpellAbilityEffect {
String stackDesc = params.get("StackDescription");
if (stackDesc != null) {
String[] reps = null;
if (stackDesc.startsWith("REP") && Lang.getInstance() instanceof LangEnglish) {
if (stackDesc.startsWith("REP")) {
reps = stackDesc.substring(4).split(" & ");
stackDesc = "SpellDescription";
}
@@ -97,7 +96,9 @@ public abstract class SpellAbilityEffect {
if (reps != null) {
for (String s : reps) {
String[] rep = s.split("_",2);
spellDesc = spellDesc.replaceFirst(rep[0], rep[1]);
if (spellDesc.contains(rep[0])) {
spellDesc = spellDesc.replaceFirst(rep[0], rep[1]);
}
}
tokenizeString(sa, sb, spellDesc);
} else {

View File

@@ -10,12 +10,14 @@ import forge.game.GameEntityCounterTable;
import forge.game.ability.AbilityKey;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card;
import forge.game.card.CardCollection;
import forge.game.card.CardDamageMap;
import forge.game.player.Player;
import forge.game.replacement.ReplacementType;
import forge.game.spellability.SpellAbility;
import forge.game.trigger.TriggerType;
import forge.util.CardTranslation;
import forge.util.Lang;
import forge.util.Localizer;
public class FightEffect extends DamageBaseEffect {
@@ -30,10 +32,17 @@ public class FightEffect extends DamageBaseEffect {
List<Card> fighters = getFighters(sa);
if (fighters.size() > 1) {
sb.append(fighters.get(0)).append(" fights ").append(fighters.get(1));
sb.append(fighters.get(0)).append(" fights ").append(fighters.get(1)).append(".");
}
else if (fighters.size() == 1) {
sb.append(fighters.get(0)).append(" fights unknown");
sb.append(fighters.get(0)).append(" fights.");
}
if (sa.hasParam("ReplaceDyingDefined")) {
CardCollection cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("ReplaceDyingDefined"), sa);
if (!cards.isEmpty()) {
sb.append(" If ").append(Lang.joinHomogenous(cards, null, "or"));
sb.append(" would die this turn, exile it instead.");
}
}
return sb.toString();
}
@@ -117,8 +126,9 @@ public class FightEffect extends DamageBaseEffect {
if (defined.size() > 1 && fighter1 == null) {
fighter1 = defined.get(0);
fighter2 = defined.get(1);
} else {
fighter2 = defined.get(0);
} else { // template often Defined$ ParentTarget vs. Targeted - this yields good StackDesc order
fighter2 = fighter1;
fighter1 = defined.get(0);
}
}
} else if (tgts.size() > 1) {

View File

@@ -1,7 +1,7 @@
Name:Barroom Brawl
ManaCost:1 G
Types:Sorcery
A:SP$ Pump | ValidTgts$ Creature.YouCtrl | AILogic$ Fight | TgtPrompt$ Choose target creature you control | SubAbility$ DBFight | SpellDescription$ SpellDescription$ Target creature you control fights target creature the opponent to your left controls. Then that player may copy this spell and may choose new targets for the copy.
SVar:DBFight:DB$ Fight | Defined$ ParentTarget | ValidTgts$ Creature.ControlledBy NextPlayerToYourLeft | TgtPrompt$ Choose target creature controlled by the opponent to your left | SubAbility$ DBCopy
SVar:DBCopy:DB$ CopySpellAbility | Defined$ Parent | Controller$ NextPlayerToYourLeft | Optional$ True | AILogic$ ChainOfAcid | StackDescription$ None | MayChooseTarget$ True
A:SP$ Pump | ValidTgts$ Creature.YouCtrl | AILogic$ Fight | TgtPrompt$ Select target creature you control | SubAbility$ DBFight | StackDescription$ None
SVar:DBFight:DB$ Fight | Defined$ ParentTarget | ValidTgts$ Creature.ControlledBy NextOpponentToYourLeft | TgtPrompt$ Select target creature controlled by the opponent to your left | SubAbility$ DBCopy | SpellDescription$ Target creature you control fights target creature the opponent to your left controls.
SVar:DBCopy:DB$ CopySpellAbility | Defined$ Parent | Controller$ NextOpponentToYourLeft | Optional$ True | AILogic$ ChainOfAcid | StackDescription$ None | MayChooseTarget$ True | StackDescription$ REP that player_{p:NextPlayerToYourLeft} | SpellDescription$ Then that player may copy this spell and may choose new targets for the copy.
Oracle:Target creature you control fights target creature the opponent to your left controls. Then that player may copy this spell and may choose new targets for the copy.

View File

@@ -1,6 +1,6 @@
Name:Prey Upon
ManaCost:G
Types:Sorcery
A:SP$ Pump | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Choose target creature you control | SubAbility$ DBFight | StackDescription$ Target creature you control [{c:ThisTargetedCard}] | SpellDescription$ Target creature you control fights target creature you don't control. (Each deals damage equal to its power to the other.)
SVar:DBFight:DB$ Fight | Defined$ ParentTarget | ValidTgts$ Creature.YouDontCtrl | TgtPrompt$ Choose target creature you don't control | StackDescription$ fights target creature you don't control [{c:ThisTargetedCard}]. (Each deals damage equal to its power to the other.)
A:SP$ Pump | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | SubAbility$ DBFight | StackDescription$ None
SVar:DBFight:DB$ Fight | Defined$ ParentTarget | ValidTgts$ Creature.YouDontCtrl | TgtPrompt$ Select target creature you don't control | SpellDescription$ Target creature you control fights target creature you don't control. (Each deals damage equal to its power to the other.)
Oracle:Target creature you control fights target creature you don't control. (Each deals damage equal to its power to the other.)

View File

@@ -2,7 +2,7 @@ Name:Ulvenwald Tracker
ManaCost:G
Types:Creature Human Shaman
PT:1/1
A:AB$ Pump | Cost$ 1 G T | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Choose target creature you control | SubAbility$ TrackerFight | StackDescription$ None | SpellDescription$ Target creature you control fights another target creature.
SVar:TrackerFight:DB$ Fight | Defined$ ParentTarget | ValidTgts$ Creature | TargetUnique$ True | TgtPrompt$ Choose target creature to fight the first target
A:AB$ Pump | Cost$ 1 G T | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | SubAbility$ TrackerFight | StackDescription$ None
SVar:TrackerFight:DB$ Fight | Defined$ ParentTarget | ValidTgts$ Creature | TargetUnique$ True | TgtPrompt$ Select another target creature | SpellDescription$ Target creature you control fights another target creature.
AI:RemoveDeck:All
Oracle:{1}{G}, {T}: Target creature you control fights another target creature.

View File

@@ -2,6 +2,6 @@ Name:Unnatural Aggression
ManaCost:2 G
Types:Instant
K:Devoid
A:SP$ Pump | Cost$ 2 G | AILogic$ Fight | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Choose target creature you control | SubAbility$ DBFight | StackDescription$ None | SpellDescription$ Target creature you control fights target creature an opponent controls. If the creature an opponent controls would die this turn, exile it instead.
SVar:DBFight:DB$ Fight | Defined$ ParentTarget | ValidTgts$ Creature.OppCtrl | ReplaceDyingDefined$ Targeted | TgtPrompt$ Choose target creature an opponent controls to fight the first target
A:SP$ Pump | AILogic$ Fight | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | SubAbility$ DBFight | StackDescription$ None | SpellDescription$ Target creature you control fights target creature an opponent controls. If the creature an opponent controls would die this turn, exile it instead.
SVar:DBFight:DB$ Fight | Defined$ ParentTarget | ValidTgts$ Creature.OppCtrl | ReplaceDyingDefined$ ThisTargetedCard | TgtPrompt$ Select target creature an opponent controls
Oracle:Devoid (This card has no color.)\nTarget creature you control fights target creature an opponent controls. If the creature an opponent controls would die this turn, exile it instead.