Explorar el Código

wrapping up link effects

mbunch_kascope hace 1 año
padre
commit
f815b63a6a

+ 2 - 2
Assets/CardBaseEntity/BT1/Blue/Digimon/BT1_027.asset

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:6d72763a95c3bdedc652d59b638091130975660c0e138d4dcd7998c4db5d7abb
-size 1141
+oid sha256:1b554a09474fb1f0e3099ab2d19cf6e0c765923f1700b6040eba70aa2639f20f
+size 1134

+ 0 - 80
Assets/CardEffect/BT21/BT1_027.cs

@@ -1,80 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace DCGO.CardEffects.BT1
-{
-    public class BT1_027 : CEntity_Effect
-    {
-        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
-        {
-            List<ICardEffect> cardEffects = new List<ICardEffect>();
-
-            if (timing == EffectTiming.OnDeclaration)
-            {
-                cardEffects.Add(CardEffectFactory.LinkEffect(card, 1, 2000));
-            }
-
-            if(timing == EffectTiming.WhenLinked)
-            {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("Testing When Linked", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
-                activateClass.SetIsLinkedEffect(true);
-                cardEffects.Add(activateClass);
-
-                string EffectDiscription()
-                {
-                    return "[When linked] Testing Log";
-                }
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.CanTriggerWhenLinked(hashtable, null, card);
-                }
-
-                bool CanActivateCondition(Hashtable hashtable)
-                {
-                    return isExistOnField(card);
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable _hashtable)
-                {
-                    UnityEngine.Debug.Log("CARD SUCCESSFULLY LINKED");
-                    yield return null;
-                }
-            }
-
-            if(timing == EffectTiming.None)
-            {
-                bool CanUseCondition()
-                {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
-                }
-
-                cardEffects.Add(CardEffectFactory.BlockerStaticEffect(permanentCondition: null, isInheritedEffect: true, card: card, condition: CanUseCondition));
-            }
-
-            if (timing == EffectTiming.None)
-            {
-                bool Condition()
-                {
-                    if (CardEffectCommons.IsExistOnBattleArea(card))
-                    {
-                        return true;
-                    }
-
-                    return false;
-                }
-
-                cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
-                    changeValue: 1,
-                    isInheritedEffect: true,
-                    card: card,
-                    condition: Condition));
-            }
-
-            return cardEffects;
-        }
-    }
-}

+ 99 - 0
Assets/Scripts/CardController.cs

@@ -3901,6 +3901,105 @@ public class ITrashDigivolutionCards
 }
 #endregion
 
+#region Trash link cards
+public class ITrashLinkCards
+{
+    public ITrashLinkCards(Permanent permanent, List<CardSource> trashTargetCards, ICardEffect cardEffect)
+    {
+        _permanent = permanent;
+
+        _trashTargetCards = trashTargetCards.Clone();
+
+        _cardEffect = cardEffect;
+    }
+
+    Permanent _permanent = null;
+    List<CardSource> _trashTargetCards = new List<CardSource>();
+    ICardEffect _cardEffect = null;
+
+    public IEnumerator TrashLinkCards()
+    {
+        if (_trashTargetCards == null) yield break;
+        if (_cardEffect == null) yield break;
+        if (_permanent == null) yield break;
+        if (_permanent.TopCard == null) yield break;
+        if (_permanent.TopCard.CanNotBeAffected(_cardEffect)) yield break;
+        if (_permanent.HasNoDigivolutionCards) yield break;
+
+        _trashTargetCards = _trashTargetCards.Filter((cardSource) =>
+            _permanent.DigivolutionCards.Contains(cardSource) &&
+            !cardSource.CanNotTrashFromDigivolutionCards(_cardEffect));
+
+        if (_trashTargetCards.Count == 0) yield break;
+
+        _trashTargetCards.ForEach(source => source.willBeRemoveSources = true);
+
+        string message = "Discarded card" + Utils.PluralFormSuffix(_trashTargetCards.Count);
+        yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_trashTargetCards, message, true, true));
+
+        yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(_permanent));
+
+        #region cut in effect - Would discard
+
+        // "When link cards would be trashed" effect
+        //TODO: Create CardEffectCommons.WhenLinkCardWouldDiscard function
+        /*yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.StackSkillInfos(
+            CardEffectCommons.WhenDigivolutionCardWouldDiscardedCheckHashtable(
+                _permanent,
+                _trashTargetCards,
+                _cardEffect
+            ),
+            EffectTiming.WhenWouldDigivolutionCardDiscarded));*/
+
+        if (GManager.instance.autoProcessing_CutIn.HasAwaitingActivateEffects())
+        {
+            // effect
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.ShrinkSecurityDigimonDisplay());
+
+            // cut in effect process
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.TriggeredSkillProcess(false, AutoProcessing.HasExecutedSameEffect));
+        }
+        #endregion
+
+        //fix trash target permanent
+        Permanent permanentTarget_Fixed = _permanent;
+
+        // fix trash sources sources
+        List<CardSource> trashLinkCards_Fixed = _trashTargetCards.Filter(cardsource =>
+            cardsource != null
+            && cardsource.willBeRemoveSources);
+
+        #region "When link cards are trashed" effect
+
+        #region Hashtable Setting
+        Hashtable hashtable = new Hashtable()
+            {
+                {"CardEffect", _cardEffect},
+                {"Permanent", permanentTarget_Fixed},
+                {"DiscardedCards", trashLinkCards_Fixed},
+            };
+        #endregion
+        //TODO: Create OnLinkCardDiscarded timing
+        //yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing.StackSkillInfos(hashtable, EffectTiming.OnDigivolutionCardDiscarded));
+        #endregion
+
+        yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(_trashTargetCards).Overflow());
+
+        foreach (CardSource cardSource in trashLinkCards_Fixed)
+        {
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, permanentTarget_Fixed));
+
+            if (!cardSource.IsToken)
+            {
+                yield return ContinuousController.instance.StartCoroutine(permanentTarget_Fixed.RemoveLinkedCard(cardSource));
+            }
+
+            cardSource.willBeRemoveSources = false;
+        }
+    }
+}
+#endregion
+
 #region Return digivolution cards to deck bottom
 public class ReturnToLibraryBottomDigivolutionCardsClass
 {

+ 37 - 1
Assets/Scripts/CardEffectCommons/CanUseEffects/WhenLinked.cs

@@ -7,7 +7,7 @@ using UnityEngine;
 public partial class CardEffectCommons
 {
     #region Can trigger "When card is linked" effect
-    public static bool CanTriggerWhenLinked(Hashtable hashtable, Func<Permanent, bool> permanentCondition, CardSource card)
+    public static bool CanTriggerWhenLinking(Hashtable hashtable, Func<Permanent, bool> permanentCondition, CardSource card)
     {
         if (hashtable != null)
         {
@@ -41,4 +41,40 @@ public partial class CardEffectCommons
         return false;
     }
     #endregion
+
+    #region Can trigger "When a card gets linked" effect
+    public static bool CanTriggerWhenLinked(Hashtable hashtable, Func<Permanent, bool> permanentCondition, Func<CardSource, bool> sourcecCondition)
+    {
+        if (hashtable != null)
+        {
+            Permanent Permanent = GetPermanentFromHashtable(hashtable);
+
+            if (Permanent != null)
+            {
+                if (Permanent.TopCard != null)
+                {
+                    if (permanentCondition == null || permanentCondition(Permanent))
+                    {
+                        ICardEffect CardEffect = GetCardEffectFromHashtable(hashtable);
+
+                        if (CardEffect != null)
+                        {
+                            CardSource cardSource = GetCardFromHashtable(hashtable);
+
+                            if (cardSource != null)
+                            {
+                                if (sourcecCondition == null || sourcecCondition(cardSource))
+                                {
+                                    return true;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+    #endregion
 }

+ 10 - 0
Assets/Scripts/CardEffectCommons/GameContextDeterminarion.cs

@@ -96,6 +96,16 @@ public partial class CardEffectCommons
     }
     #endregion
 
+    #region Whether the card is Linked
+    public static bool IsExistLinked(CardSource card)
+    {
+        if (IsExistOnField(card))
+            return card.PermanentOfThisCard().LinkedCards.Any(source => source.Source == card);
+
+        return false;
+    }
+    #endregion
+
     #region Whether the card is in trash
     public static bool IsExistOnTrash(CardSource card)
     {

+ 121 - 0
Assets/Scripts/CardEffectCommons/GiveEffect/GiveEffectToPermanent/ChangeLinkMax.cs

@@ -0,0 +1,121 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectCommons
+{
+    #region Change target 1 Digimon's Link Max
+    public static IEnumerator ChangeDigimonLinkMax(Permanent targetPermanent, int changeValue, EffectDuration effectDuration, ICardEffect activateClass)
+    {
+        if (targetPermanent == null) yield break;
+        if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
+        if (changeValue == 0) yield break;
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+        bool isUpValue = changeValue > 0;
+
+        bool CanUseCondition()
+        {
+            if (IsPermanentExistsOnBattleArea(targetPermanent))
+            {
+                if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        ChangeLinkMaxClass changeLinkMaxClass = CardEffectFactory.ChangeTargetLinkMaxStaticEffect(
+                    targetPermanent: targetPermanent,
+                    changeValue: changeValue,
+                    isInheritedEffect: false,
+                    card: card,
+                    condition: CanUseCondition);
+
+        AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: changeLinkMaxClass,
+            timing: EffectTiming.None);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            if (isUpValue)
+            {
+                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
+            }
+
+            else
+            {
+                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
+            }
+        }
+    }
+
+    public static IEnumerator ChangeDigimonLinkMax(Permanent targetPermanent, int changeValue, EffectDuration effectDuration, ICardEffect activateClass, bool activateAnimation, string hashstring = null)
+    {
+        if (targetPermanent == null) yield break;
+        if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
+        if (changeValue == 0) yield break;
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+        bool isUpValue = changeValue > 0;
+
+        bool CanUseCondition()
+        {
+            if (IsPermanentExistsOnBattleArea(targetPermanent))
+            {
+                if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        ChangeLinkMaxClass changeLinkMaxClass = CardEffectFactory.ChangeTargetLinkMaxStaticEffect(
+                    targetPermanent: targetPermanent,
+                    changeValue: changeValue,
+                    isInheritedEffect: false,
+                    card: card,
+                    condition: CanUseCondition,
+                    hashstring: hashstring);
+
+        AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: changeLinkMaxClass,
+            timing: EffectTiming.None);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            if (isUpValue)
+            {
+                if (activateAnimation)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
+                }
+            }
+
+            else
+            {
+                if (activateAnimation)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
+                }
+            }
+        }
+    }
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectCommons/GiveEffect/GiveEffectToPermanent/ChangeLinkMax.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f76ee890acdfe124db988841089049b6
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 183 - 0
Assets/Scripts/CardEffectCommons/TrashLinkedCards.cs

@@ -0,0 +1,183 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System.Linq;
+using Photon;
+using System;
+using Photon.Pun;
+
+public partial class CardEffectCommons
+{
+    public static IEnumerator SelectTrashLinkedCards(Func<Permanent, bool> permanentCondition, Func<CardSource, bool> cardCondition, int maxCount, bool canNoTrash, bool isFromOnly1Permanent, ICardEffect activateClass, string selectString = "Digimon", Func<Permanent, List<CardSource>, IEnumerator> afterSelectionCoroutine = null)
+    {
+        if (maxCount <= 0) yield break;
+        if (activateClass == null) yield break;
+        CardSource card = activateClass.EffectSourceCard;
+        if (card == null) yield break;
+
+        bool CanSelectPermanentCondition(Permanent permanent)
+        {
+            if (IsPermanentExistsOnBattleArea(permanent))
+            {
+                if (permanentCondition == null || permanentCondition(permanent))
+                {
+                    if (!permanent.TopCard.CanNotBeAffected(activateClass))
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            return false;
+        }
+
+        bool CanSelectCardCondition(CardSource cardSource)
+        {
+            if (cardCondition == null || cardCondition(cardSource))
+            {
+                return true;
+            }
+
+            return false;
+        }
+
+        int permanentSum =
+            GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
+                .Map(player => player.GetBattleAreaPermanents().Filter(CanSelectPermanentCondition))
+                .Flat().Count();
+
+        int linkedCardsSum =
+                GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
+                .Map(player => player.GetBattleAreaPermanents().Filter(CanSelectPermanentCondition))
+                .Flat()
+                .Map(permanent => permanent.LinkedCards.Map(link => link.Source).Count(CanSelectCardCondition))
+                .Sum();
+
+        int maxLinkDiscardCount = Math.Min(linkedCardsSum, maxCount);
+        int linkDiscardedCount = 0;
+
+        void EndSelection() => linkDiscardedCount = linkedCardsSum;
+        bool NotSelectYet() => linkDiscardedCount == 0;
+
+        int permanentSelectedCount = 0;
+
+        while (true)
+        {
+            if (isFromOnly1Permanent)
+            {
+                if (permanentSelectedCount >= 1)
+                {
+                    break;
+                }
+            }
+
+            if (linkDiscardedCount >= maxLinkDiscardCount)
+            {
+                break;
+            }
+
+            if (permanentSum < 1)
+            {
+                break;
+            }
+            else
+            {
+                permanentSelectedCount++;
+                maxCount = Math.Min(1, permanentSum);
+
+                SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+
+                selectPermanentEffect.SetUp(
+                    selectPlayer: card.Owner,
+                    canTargetCondition: CanSelectPermanentCondition,
+                    canTargetCondition_ByPreSelecetedList: null,
+                    canEndSelectCondition: null,
+                    maxCount: maxCount,
+                    canNoSelect: canNoTrash && NotSelectYet(),
+                    canEndNotMax: false,
+                    selectPermanentCoroutine: SelectPermanentCoroutine,
+                    afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
+                    mode: SelectPermanentEffect.Mode.Custom,
+                    cardEffect: activateClass);
+
+                selectPermanentEffect.SetUpCustomMessage($"Select 1 {selectString} that will trash digivolution cards.", $"The opponent is selecting 1 {selectString} that will trash digivolution cards.");
+
+                yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+
+                IEnumerator SelectPermanentCoroutine(Permanent permanent)
+                {
+                    Permanent selectedPermanent = permanent;
+
+                    if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
+                    {
+                        int trashMaxCountOfTargetPermanent = Math.Min(
+                            maxLinkDiscardCount - linkDiscardedCount,
+                            selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
+
+                        List<CardSource> selectedCards = new List<CardSource>();
+
+                        SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
+
+                        selectCardEffect.SetUp(
+                                    canTargetCondition: CanSelectCardCondition,
+                                    canTargetCondition_ByPreSelecetedList: null,
+                                    canEndSelectCondition: null,
+                                    canNoSelect: () => canNoTrash && NotSelectYet(),
+                                    selectCardCoroutine: SelectCardCoroutine,
+                                    afterSelectCardCoroutine: null,
+                                    message: "Select linked cards to trash.",
+                                    maxCount: trashMaxCountOfTargetPermanent,
+                                    canEndNotMax: trashMaxCountOfTargetPermanent >= 2 && !isFromOnly1Permanent,
+                                    isShowOpponent: true,
+                                    mode: SelectCardEffect.Mode.Custom,
+                                    root: SelectCardEffect.Root.Custom,
+                                    customRootCardList: selectedPermanent.LinkedCards.Map(linked => linked.Source),
+                                    canLookReverseCard: true,
+                                    selectPlayer: card.Owner,
+                                    cardEffect: activateClass);
+
+                        selectCardEffect.SetUpCustomMessage("Select linked cards to trash.", "The opponent is selecting linked cards to trash.");
+
+                        yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
+
+                        IEnumerator SelectCardCoroutine(CardSource cardSource)
+                        {
+                            selectedCards.Add(cardSource);
+
+                            yield return null;
+                        }
+
+                        yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(
+                                selectedPermanent,
+                                selectedCards,
+                                activateClass).TrashDigivolutionCards());
+
+                       linkDiscardedCount += selectedCards.Count;
+
+                        if (canNoTrash && NotSelectYet())
+                        {
+                            EndSelection();
+                        }
+
+                        if (afterSelectionCoroutine != null)
+                            yield return ContinuousController.instance.StartCoroutine(afterSelectionCoroutine(selectedPermanent, selectedCards));
+                    }
+                }
+
+                IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
+                {
+                    if (permanents.Count == 0)
+                    {
+                        if (canNoTrash && NotSelectYet())
+                        {
+                            EndSelection();
+                        }
+                    }
+
+                    yield return null;
+                }
+            }
+        }
+    }
+
+}

+ 11 - 0
Assets/Scripts/CardEffectCommons/TrashLinkedCards.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e8c382c5aa5579d48be86c4bbc84081e
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 2
Assets/Scripts/CardEffectFactory/KeyWordEffects/Link.cs

@@ -96,9 +96,7 @@ public partial class CardEffectFactory
 
             if (selectedPermanent != null)
             {
-
                 yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkCard(card, dp, activateClass));
-                    //yield return ContinuousController.instance.StartCoroutine(new ILinkPermanentToPermanent(new List<Permanent[]>() { new Permanent[] { card.PermanentOfThisCard(), selectedPermanent } }, dp, activateClass).LinkPermanent());
             }
         }
 

+ 0 - 5
Assets/Scripts/CardObjectController.cs

@@ -391,11 +391,6 @@ public class CardObjectController : MonoBehaviour
                 {
                     yield return ContinuousController.instance.StartCoroutine(permanent.RemoveCardSource(cardSource));
                 }
-
-                if(permanent.LinkedCards.Any(linked => linked.Source == cardSource))
-                {
-                    yield return ContinuousController.instance.StartCoroutine(permanent.RemoveLinkedCard(cardSource));
-                }
             }
         }
 

+ 8 - 0
Assets/Scripts/Effect Examples.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 3ca64c3d0906a504797e7e90bfa8a077
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 185 - 0
Assets/Scripts/Effect Examples/Link_Examples.cs

@@ -0,0 +1,185 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace DCGO.CardEffects.Examples
+{
+    public class Link_Examples : CEntity_Effect
+    {
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+        {
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
+
+            #region Basic link effect keyword
+            if (timing == EffectTiming.OnDeclaration)
+            {
+                cardEffects.Add(CardEffectFactory.LinkEffect(card, 1, 2000));
+            }
+            #endregion
+
+            #region When Linked Example, Specifically When THIS card is added as a linked card
+            if (timing == EffectTiming.WhenLinked)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Testing When Linking", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
+                activateClass.SetIsLinkedEffect(true);
+                cardEffects.Add(activateClass);
+
+                string EffectDiscription()
+                {
+                    return "[When linked] Testing When linking";
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    return isExistOnField(card);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                {
+                    UnityEngine.Debug.Log("CARD SUCCESSFULLY LINKED");
+                    yield return null;
+                }
+            }
+            #endregion
+
+            #region When Linked Example, When A card is linked at all
+            if (timing == EffectTiming.WhenLinked)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Testing When Linked", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
+                cardEffects.Add(activateClass);
+
+                string EffectDiscription()
+                {
+                    return "[Your Turn] When this Digimon gets linked";
+                }
+
+                bool PermanentCondition(Permanent permanent)
+                {
+                    return permanent == card.PermanentOfThisCard();
+                }
+
+                bool CardCondition(CardSource source)
+                {
+                    return true;
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, CardCondition);
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    return isExistOnField(card);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                {
+                    UnityEngine.Debug.Log("CARD LINKED");
+                    yield return null;
+                }
+            }
+            #endregion
+
+            #region Trash 1 Link card
+            if (timing == EffectTiming.OnStartMainPhase)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
+                cardEffects.Add(activateClass);
+
+                string EffectDiscription()
+                {
+                    return "";
+                }
+
+                bool CanSelectPermanentCondition(Permanent permanent)
+                {
+                    if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
+                    {
+                        if (permanent.LinkedCards.Map(link => link.Source).Count(CanSelectCardCondition) >= 1)
+                        {
+                            return true;
+                        }
+                    }
+
+                    return false;
+                }
+
+                bool CanSelectCardCondition(CardSource cardSource)
+                {
+                    return true;
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    if (CardEffectCommons.IsExistOnBattleArea(card))
+                    {
+                        if (CardEffectCommons.IsOwnerTurn(card))
+                        {
+                            return true;
+                        }
+                    }
+
+                    return false;
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    if (CardEffectCommons.IsExistOnBattleArea(card))
+                    {
+                        return true;
+                    }
+
+                    return false;
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashLinkedCards(
+                            permanentCondition: CanSelectPermanentCondition,
+                            cardCondition: CanSelectCardCondition,
+                            maxCount: 1,
+                            canNoTrash: false,
+                            isFromOnly1Permanent: true,
+                            activateClass: activateClass
+                        ));
+                }
+            }
+            #endregion
+
+            #region Change Link Max Count
+            if (timing == EffectTiming.None)
+            {
+                bool Condition()
+                {
+                    if (CardEffectCommons.IsExistOnBattleArea(card))
+                    {
+                        return true;
+                    }
+
+                    return false;
+                }
+
+                cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(
+                    changeValue: 1,
+                    isInheritedEffect: true,
+                    card: card,
+                    condition: Condition));
+            }
+
+            return cardEffects;
+        }
+        #endregion
+    }
+}

+ 0 - 0
Assets/CardEffect/BT21/BT1_027.cs.meta → Assets/Scripts/Effect Examples/Link_Examples.cs.meta


+ 5 - 1
Assets/Scripts/Permanent.cs

@@ -961,7 +961,7 @@ public class Permanent
         }
         Debug.Log($"LINK CARDS: {LinkedCards.Count} >= {LinkedMax}");
         if (LinkedCards.Count >= LinkedMax)
-            yield return ContinuousController.instance.StartCoroutine(RemoveCardSource(LinkedCards[0].Source));
+            yield return ContinuousController.instance.StartCoroutine(RemoveLinkedCard(LinkedCards[0].Source));
 
         yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(addedLinkCard));
 
@@ -3375,6 +3375,10 @@ public class Permanent
     public bool HasNoDigivolutionCards => DigivolutionCards.Count == 0;
     #endregion
 
+    #region Has No Link Cards
+    public bool HasNoLinkCards => LinkedCards.Count == 0;
+    #endregion
+
     #region Digivolution cards' colors
     public List<CardColor> DigivolutionCardsColors
     {