Update cardstates after creating token from prototype (#5676)

* Hotfix for Toggo rock

* Force update cardstate

* Clean up

---------

Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.60>
This commit is contained in:
tool4ever
2024-07-24 04:59:34 +00:00
committed by GitHub
parent 983f2d2856
commit 07eae3c8d1
3 changed files with 23 additions and 18 deletions

View File

@@ -114,6 +114,8 @@ public abstract class TokenEffectBase extends SpellAbilityEffect {
for (int i = 0; i < cellAmount; i++) { for (int i = 0; i < cellAmount; i++) {
Card tok = new CardCopyService(prototype).copyCard(true); Card tok = new CardCopyService(prototype).copyCard(true);
// disconnect from prototype
tok.getStates().forEach(cs -> tok.getState(cs).resetOriginalHost());
// Crafty Cutpurse would change under which control it does enter, // Crafty Cutpurse would change under which control it does enter,
// but it shouldn't change who creates the token // but it shouldn't change who creates the token
tok.setOwner(creator); tok.setOwner(creator);

View File

@@ -18,7 +18,6 @@
package forge.game.card; package forge.game.card;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -748,15 +747,26 @@ public class CardState extends GameObject implements IHasSVars {
} }
} }
public ImmutableList<CardTraitBase> getTraits() {
return ImmutableList.<CardTraitBase>builder()
.addAll(manaAbilities)
.addAll(nonManaAbilities)
.addAll(triggers)
.addAll(replacementEffects)
.addAll(staticAbilities)
.build();
}
public void resetOriginalHost() {
for (final CardTraitBase ctb : getTraits()) {
if (ctb.isIntrinsic()) {
ctb.setCardState(this);
}
}
}
public void updateChangedText() { public void updateChangedText() {
final List<CardTraitBase> allAbs = ImmutableList.<CardTraitBase>builder() for (final CardTraitBase ctb : getTraits()) {
.addAll(manaAbilities)
.addAll(nonManaAbilities)
.addAll(triggers)
.addAll(replacementEffects)
.addAll(staticAbilities)
.build();
for (final CardTraitBase ctb : allAbs) {
if (ctb.isIntrinsic()) { if (ctb.isIntrinsic()) {
ctb.changeText(); ctb.changeText();
} }
@@ -764,14 +774,7 @@ public class CardState extends GameObject implements IHasSVars {
} }
public void changeTextIntrinsic(Map<String,String> colorMap, Map<String,String> typeMap) { public void changeTextIntrinsic(Map<String,String> colorMap, Map<String,String> typeMap) {
final List<CardTraitBase> allAbs = ImmutableList.<CardTraitBase>builder() for (final CardTraitBase ctb : getTraits()) {
.addAll(manaAbilities)
.addAll(nonManaAbilities)
.addAll(triggers)
.addAll(replacementEffects)
.addAll(staticAbilities)
.build();
for (final CardTraitBase ctb : allAbs) {
if (ctb.isIntrinsic()) { if (ctb.isIntrinsic()) {
ctb.changeTextIntrinsic(colorMap, typeMap); ctb.changeTextIntrinsic(colorMap, typeMap);
} }

View File

@@ -4,7 +4,7 @@ Types:Legendary Creature Human Warlock
PT:4/4 PT:4/4
K:Lifelink K:Lifelink
T:Mode$ Attached | ValidSource$ Aura.YouCtrl | TargetRelativeToSource$ Permanent.nonLand+OppCtrl+cmcLEX | TriggerZones$ Battlefield | Execute$ TrigGainControl | TriggerDescription$ Whenever an Aura you control becomes attached to a nonland permanent an opponent controls with mana value less than or equal to that Aura's mana value, gain control of that permanent for as long as that Aura is attached to it. T:Mode$ Attached | ValidSource$ Aura.YouCtrl | TargetRelativeToSource$ Permanent.nonLand+OppCtrl+cmcLEX | TriggerZones$ Battlefield | Execute$ TrigGainControl | TriggerDescription$ Whenever an Aura you control becomes attached to a nonland permanent an opponent controls with mana value less than or equal to that Aura's mana value, gain control of that permanent for as long as that Aura is attached to it.
SVar:TrigGainControl:DB$ GainControl | NewController$ You | Defined$ TriggeredTarget | Duration$ UntilSourceUnattached SVar:TrigGainControl:DB$ GainControl | NewController$ You | Defined$ TriggeredTarget | LoseControl$ UntilSourceUnattached
SVar:X:Count$CardManaCost SVar:X:Count$CardManaCost
DeckHas:Ability$LifeGain DeckHas:Ability$LifeGain
DeckNeeds:Type$Aura DeckNeeds:Type$Aura