Fix triggered object issue

This commit is contained in:
Lyu Zong-Hong
2021-02-13 00:09:55 +09:00
parent bca0282cae
commit 7938e6bb84
3 changed files with 1 additions and 17 deletions

View File

@@ -564,9 +564,6 @@ public class CardState extends GameObject implements IHasSVars {
}
public final void addAbilitiesFrom(final CardState source, final boolean lki) {
// TODO: what happens if SVar has the same name ?
sVars.putAll(source.getSVars());
for (SpellAbility sa : source.manaAbilities) {
if (sa.isIntrinsic()) {
manaAbilities.add(sa.copy(card, lki));

View File

@@ -195,16 +195,7 @@ public class TriggerChangesZone extends Trigger {
// TODO use better way to always copy both Card and CardLKI
if ("Battlefield".equals(getParam("Origin"))) {
sa.setTriggeringObject(AbilityKey.Card, runParams.get(AbilityKey.CardLKI));
final Object crd = runParams.get(AbilityKey.Card);
if (crd instanceof Card) {
sa.setTriggeringObject(AbilityKey.NewCard, CardUtil.getLKICopy((Card)runParams.get(AbilityKey.Card)));
} else if (crd instanceof CardCollection) {
CardCollection newCards = new CardCollection();
for (final Card c : (CardCollection) crd) {
newCards.add(CardUtil.getLKICopy(c));
}
sa.setTriggeringObject(AbilityKey.NewCard, newCards);
}
sa.setTriggeringObject(AbilityKey.NewCard, runParams.get(AbilityKey.Card));
} else {
sa.setTriggeringObjectsFrom(runParams, AbilityKey.Card);
}

View File

@@ -477,17 +477,13 @@ public class TriggerHandler {
if (runParams.get(AbilityKey.MergedCards) != null) {
// Check if the trigger cares the origin is from battlefield
Card original = (Card) runParams.get(AbilityKey.Card);
Card lastKnownInfo = (Card) runParams.get(AbilityKey.CardLKI);
CardCollection mergedCards = (CardCollection) runParams.get(AbilityKey.MergedCards);
CardCollection mergedCardsLKI = new CardCollection(mergedCards);
mergedCards.set(mergedCards.indexOf(original), original);
mergedCardsLKI.set(mergedCardsLKI.indexOf(original), lastKnownInfo);
Map<AbilityKey, Object> newParams = AbilityKey.mapFromCard(original);
newParams.putAll(runParams);
if ("Battlefield".equals(regtrig.getParam("Origin"))) {
// If yes, only trigger once
newParams.put(AbilityKey.Card, mergedCards);
newParams.put(AbilityKey.CardLKI, mergedCardsLKI);
runSingleTriggerInternal(regtrig, newParams);
} else {
// Else, trigger for each merged components