Merge pull request #166 from tool4ever/esix2

Fix Esix replacing too much from other effects
This commit is contained in:
Anthony Calosa
2022-04-29 05:41:58 +08:00
committed by GitHub
3 changed files with 23 additions and 4 deletions

View File

@@ -251,7 +251,7 @@ public class CopyPermanentEffect extends TokenEffectBase {
}
} // end resolve
private Card getProtoType(final SpellAbility sa, final Card original, final Player newOwner) {
public static Card getProtoType(final SpellAbility sa, final Card original, final Player newOwner) {
final Card host = sa.getHostCard();
int id = newOwner == null ? 0 : newOwner.getGame().nextCardId();
final Card copy = new Card(id, original.getPaperCard(), host.getGame());

View File

@@ -17,11 +17,15 @@ import forge.game.ability.AbilityKey;
import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card;
import forge.game.card.CardCollectionView;
import forge.game.card.CardLists;
import forge.game.card.TokenCreateTable;
import forge.game.card.token.TokenInfo;
import forge.game.player.Player;
import forge.game.replacement.ReplacementResult;
import forge.game.spellability.SpellAbility;
import forge.game.zone.ZoneType;
import forge.util.Localizer;
public class ReplaceTokenEffect extends SpellAbilityEffect {
@@ -86,6 +90,16 @@ public class ReplaceTokenEffect extends SpellAbilityEffect {
}
}
} else if ("ReplaceToken".equals(sa.getParam("Type"))) {
Card chosen = null;
if (sa.hasParam("ValidChoices")) {
CardCollectionView choices = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), sa.getParam("ValidChoices").split(","), p, card, sa);
if (choices.isEmpty()) {
originalParams.put(AbilityKey.ReplacementResult, ReplacementResult.NotReplaced);
return;
}
chosen = p.getController().chooseSingleEntityForEffect(choices, sa, Localizer.getInstance().getMessage("lblChooseaCard"), false, null);
}
long timestamp = game.getNextTimestamp();
Multimap<Player, Pair<Integer, Iterable<Object>>> toInsertMap = ArrayListMultimap.create();
@@ -111,7 +125,12 @@ public class ReplaceTokenEffect extends SpellAbilityEffect {
continue;
}
for (String script : sa.getParam("TokenScript").split(",")) {
final Card token = TokenInfo.getProtoType(script, sa, pe.getKey());
final Card token;
if (script.equals("Chosen")) {
token = CopyPermanentEffect.getProtoType(sa, chosen, pe.getKey());
} else {
token = TokenInfo.getProtoType(script, sa, pe.getKey());
}
if (token == null) {
throw new RuntimeException("don't find Token for TokenScript: " + script);

View File

@@ -4,8 +4,8 @@ Types:Legendary Creature Fractal
PT:4/4
K:Flying
R:Event$ CreateToken | ActiveZones$ Battlefield | CheckSVar$ X | SVarCompare$ EQ0 | ValidPlayer$ You | PlayerTurn$ True | Optional$ True | ReplaceWith$ DBCopy | Description$ The first time you would create one or more tokens during each of your turns, you may instead choose a creature other than CARDNAME and create that many tokens that are copies of that creature.
SVar:DBCopy:DB$ CopyPermanent | Choices$ Creature.Other | NumCopies$ Y
SVar:DBCopy:DB$ ReplaceToken | Type$ ReplaceToken | ValidChoices$ Creature.Other | TokenScript$ Chosen
SVar:X:PlayerCountPropertyYou$TokensCreatedThisTurn
SVar:Y:ReplaceCount$TokenNum
DeckHas:Ability$Token
AI:RemoveDeck:All
Oracle:Flying\nThe first time you would create one or more tokens during each of your turns, you may instead choose a creature other than Esix, Fractal Bloom and create that many tokens that are copies of that creature.