Explorar o código

Added new link condition requirement, updated app fusion triggers, Added CanLink and CanLinkFromTargetPermanent function to CardSource class

mbunch_kascope hai 1 ano
pai
achega
ec55d5804e

+ 15 - 6
Assets/CardEffect/BT21/Black/BT21_053.cs

@@ -11,6 +11,20 @@ namespace DCGO.CardEffects.BT21
         {
             List<ICardEffect> cardEffects = new List<ICardEffect>();
 
+            #region Link Condition
+
+            if (timing == EffectTiming.None)
+            {
+                static bool PermanentCondition(Permanent targetPermanent)
+                {
+                    return targetPermanent.TopCard.HasAppmonTraits;
+                }
+
+                cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 0, card: card));
+            }
+
+            #endregion
+
             #region Alternative Digivolution Condition
 
             if (timing == EffectTiming.None)
@@ -110,12 +124,7 @@ namespace DCGO.CardEffects.BT21
             #region Link
             if (timing == EffectTiming.OnDeclaration)
             {
-                bool DigimonCondition(Permanent permanent)
-                {
-                    return permanent.TopCard.EqualsTraits("Appmon");
-                }
-
-                cardEffects.Add(CardEffectFactory.LinkEffect(card, DigimonCondition));
+                cardEffects.Add(CardEffectFactory.LinkEffect(card));
             }
             #endregion
 

+ 15 - 6
Assets/CardEffect/BT21/Black/BT21_054.cs

@@ -14,6 +14,20 @@ namespace DCGO.CardEffects.BT21
 
             int totalSourceCount = 0;
 
+            #region Link Condition
+
+            if (timing == EffectTiming.None)
+            {
+                static bool PermanentCondition(Permanent targetPermanent)
+                {
+                    return targetPermanent.TopCard.HasAppmonTraits;
+                }
+
+                cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 0, card: card));
+            }
+
+            #endregion
+
             #region Alternative Digivolution Condition
 
             if (timing == EffectTiming.None)
@@ -159,12 +173,7 @@ namespace DCGO.CardEffects.BT21
             #region Link
             if (timing == EffectTiming.OnDeclaration)
             {
-                bool DigimonCondition(Permanent permanent)
-                {
-                    return permanent.TopCard.EqualsTraits("Appmon");
-                }
-
-                cardEffects.Add(CardEffectFactory.LinkEffect(card, DigimonCondition));
+                cardEffects.Add(CardEffectFactory.LinkEffect(card));
             }
             #endregion
 

+ 15 - 6
Assets/CardEffect/BT21/Black/BT21_059.cs

@@ -11,6 +11,20 @@ namespace DCGO.CardEffects.BT21
         {
             List<ICardEffect> cardEffects = new List<ICardEffect>();
 
+            #region Link Condition
+
+            if (timing == EffectTiming.None)
+            {
+                static bool PermanentCondition(Permanent targetPermanent)
+                {
+                    return targetPermanent.TopCard.HasAppmonTraits;
+                }
+
+                cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 0, card: card));
+            }
+
+            #endregion
+
             #region App Fusion
 
             if (timing == EffectTiming.None)
@@ -153,12 +167,7 @@ namespace DCGO.CardEffects.BT21
             #region Link
             if (timing == EffectTiming.OnDeclaration)
             {
-                bool DigimonCondition(Permanent permanent)
-                {
-                    return permanent.TopCard.EqualsTraits("Appmon");
-                }
-
-                cardEffects.Add(CardEffectFactory.LinkEffect(card, DigimonCondition));
+                cardEffects.Add(CardEffectFactory.LinkEffect(card));
             }
             #endregion
 

+ 0 - 1
Assets/Editor/JSONLoader_CardEntity.cs

@@ -152,7 +152,6 @@ namespace DCGO.CardEntities
             cardEntity.LinkDP = dpParse(card.linkDP);
             cardEntity.LinkEffect = card.linkEffect;
             cardEntity.LinkRequirement = card.linkRequirement;
-            cardEntity.LinkCost = GetLinkCost(card.linkRequirement);
 
             cardEntity.name = cardEntity.CardSpriteName.Replace("-Errata","").Replace("-","_");
 

+ 0 - 1
Assets/Scripts/CEntity_Base.cs

@@ -35,7 +35,6 @@ public class CEntity_Base : ScriptableObject
     public int LinkDP = 0;
     [TextArea] public string LinkEffect = "";
     [TextArea] public string LinkRequirement = "";
-    public int LinkCost = 0;
 
     public bool HasInhetitedEffect => !string.IsNullOrEmpty(InheritedEffectDiscription_ENG) && !InheritedEffectDiscription_ENG.Equals("-");
     public bool HasSecutiryEffect => !string.IsNullOrEmpty(SecurityEffectDiscription_ENG) && !SecurityEffectDiscription_ENG.Equals("-");

+ 96 - 0
Assets/Scripts/CardEffectFactory/AddLinkRequirement.cs

@@ -0,0 +1,96 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+using System.Net.NetworkInformation;
+
+public partial class CardEffectFactory
+{
+    #region Static effect that adds one's own card's link condition
+    public static AddLinkConditionClass AddSelfLinkConditionStaticEffect(Func<Permanent, bool> permanentCondition, int linkCost, CardSource card, Func<bool> condition = null, Func<CardSource, bool> cardCondition = null, string effectName = null)
+    {
+        bool CanUseCondition()
+        {
+            return condition == null || condition();
+        }
+
+        return AddLinkConditionStaticEffect(
+            permanentCondition: permanentCondition,
+            cardCondition: cardCondition ?? ((cardSource) => cardSource == card),
+            linkCost: linkCost,
+            isInheritedEffect: false,
+            card: card,
+            condition: CanUseCondition,
+            effectName: effectName ?? "Link");
+    }
+    #endregion
+
+    #region Static effect that adds link condition
+    public static AddLinkConditionClass AddLinkConditionStaticEffect(Func<Permanent, bool> permanentCondition, Func<CardSource, bool> cardCondition, int linkCost, bool isInheritedEffect, CardSource card, Func<bool> condition, string effectName)
+    {
+        AddLinkConditionClass addLinkConditionClass = new AddLinkConditionClass();
+        addLinkConditionClass.SetUpICardEffect(effectName, CanUseCondition, card);
+        addLinkConditionClass.SetUpAddLinkConditionClass(getLinkCondition: GetLink);
+
+        if (isInheritedEffect)
+            addLinkConditionClass.SetIsInheritedEffect(true);
+
+        bool CanUseCondition(Hashtable hashtable)
+        {
+            return condition == null || condition();
+        }
+
+        bool CardCondition(CardSource cardSource)
+        {
+            if (cardSource != null)
+            {
+                if (cardCondition == null || cardCondition(cardSource))
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        bool PermanentCondition(Permanent permanent)
+        {
+            if (permanent != null)
+            {
+                if (permanent.TopCard != null)
+                {
+                    if (permanentCondition == null || permanentCondition(permanent))
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            return false;
+        }
+
+        LinkCondition GetLink(CardSource cardSource)
+        {
+            if (cardSource == card)
+            {
+                if (CardCondition(cardSource)){
+                    LinkCondition LinkCondition = new LinkCondition(
+                                        digimonCondition: PermanentCondition,
+                                        cost: linkCost);
+
+                    return LinkCondition;
+                }
+            }
+
+            return null;
+        }
+
+        
+
+        
+
+        return addLinkConditionClass;
+    }
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectFactory/AddLinkRequirement.cs.meta

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

+ 3 - 3
Assets/Scripts/CardEffectFactory/KeyWordEffects/Link.cs

@@ -16,7 +16,7 @@ public partial class CardEffectFactory
     /// <param name="Func(bool)">condition for you to be able to link</param>
     /// <param name="Func(Permanent,bool)">Any permaent condtion for you to link to</param>
     /// <author>Mike Bunch</author>
-    public static ActivateClass LinkEffect(CardSource card, Func<Permanent, bool> digimonCondition, Func<bool> condition = null)
+    public static ActivateClass LinkEffect(CardSource card, Func<bool> condition = null)
     {
         if (card == null) return null;
         if (!CardEffectCommons.IsOwnerTurn(card)) return null;
@@ -33,7 +33,7 @@ public partial class CardEffectFactory
             {
                 if(permanent != card.PermanentOfThisCard())
                 {
-                    if (digimonCondition == null || digimonCondition(permanent))
+                    if (card.linkCondition == null || card.linkCondition.digimonCondition(permanent))
                     {
                         return true;
                     }
@@ -62,7 +62,7 @@ public partial class CardEffectFactory
         IEnumerator ActivateCoroutine(Hashtable _hashtable)
         {
 
-            yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(card.LinkCost, activateClass));
+            yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(card.linkCondition.cost, activateClass));
 
             Permanent selectedPermanent = null;
 

+ 7 - 0
Assets/Scripts/CardEffectInterfaces.cs

@@ -385,6 +385,13 @@ public interface IAddBurstDigivolutionConditionEffect
 }
 #endregion
 
+#region "Target card gains Link conditions" effect
+public interface IAddLinkConditionEffect
+{
+    LinkCondition GetLinkCondition(CardSource cardSource);
+}
+#endregion
+
 #region "Target card gains App Fusion digivolution conditions" effect
 public interface IAddAppFusionConditionEffect
 {

+ 27 - 0
Assets/Scripts/CardEffects/AddLinkConditionClass.cs

@@ -0,0 +1,27 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System;
+public class AddLinkConditionClass : ICardEffect, IAddLinkConditionEffect
+{
+    Func<CardSource, LinkCondition> _getLinkCondition { get; set; }
+    public void SetUpAddLinkConditionClass(Func<CardSource, LinkCondition> getLinkCondition)
+    {
+        _getLinkCondition = getLinkCondition;
+    }
+    public LinkCondition GetLinkCondition(CardSource cardSource)
+    {
+        if (cardSource != null)
+        {
+            if (_getLinkCondition != null)
+            {
+                if (_getLinkCondition(cardSource) != null)
+                {
+                    return _getLinkCondition(cardSource);
+                }
+            }
+        }
+
+        return null;
+    }
+}

+ 11 - 0
Assets/Scripts/CardEffects/AddLinkConditionClass.cs.meta

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

+ 111 - 15
Assets/Scripts/CardSource.cs

@@ -348,10 +348,6 @@ public class CardSource : MonoBehaviour
     public List<EvoCost> BaseEvoCostsFromEntity => _cEntity_Base.EvoCosts;
     #endregion
 
-    #region Link Cost
-    public int LinkCost => _cEntity_Base.LinkCost;
-    #endregion
-
     #region evoCosts
     public List<Func<Permanent, int>> EvoCosts(CardEffectCommons.IgnoreRequirement ignore, bool checkAvailability)
     {
@@ -2137,6 +2133,24 @@ public class CardSource : MonoBehaviour
     }
     #endregion
 
+    #region Link requirement
+    public LinkCondition linkCondition
+    {
+        get
+        {
+            ICardEffect addLinkConditonEffect =
+            EffectList(EffectTiming.None)
+            .Find(cardEffect => cardEffect is IAddLinkConditionEffect
+                && cardEffect.CanUse(null)
+                && ((IAddLinkConditionEffect)cardEffect).GetLinkCondition(this) != null);
+
+            if (addLinkConditonEffect != null) return ((IAddLinkConditionEffect)addLinkConditonEffect).GetLinkCondition(this);
+
+            return null;
+        }
+    }
+    #endregion
+
     #region whether this card can DNA digivolve
     public bool CanPlayJogress(bool PayCost)
     {
@@ -2450,6 +2464,40 @@ public class CardSource : MonoBehaviour
     }
     #endregion
 
+    #region whether this card can Link
+    public bool CanLink(bool PayCost)
+    {
+        if (linkCondition != null)
+        {
+            if (PayCost)
+            {
+                int cost = linkCondition.cost;
+
+                if (Owner.MaxMemoryCost < cost)
+                {
+                    return false;
+                }
+            }
+
+            if (Owner.GetBattleAreaDigimons().Count >= 1)
+            {
+                foreach (Permanent digimon in Owner.GetFieldPermanents())
+                {
+                    if (digimon != null)
+                    {
+                        if (linkCondition.digimonCondition(digimon))
+                        {
+                            return true;
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+    #endregion
+
     #region whether this card can App Fusion
     public bool CanPlayAppFusion(bool PayCost)
     {
@@ -2481,17 +2529,7 @@ public class CardSource : MonoBehaviour
                                 {
                                     if (appFusionCondition.linkedCondition(linkedCard))
                                     {
-                                        if (PayCost)
-                                        {
-                                            int cost = appFusionCondition.cost;
-
-                                            cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { digimon }, checkAvailability: true);
-
-                                            if (Owner.MaxMemoryCost < cost)
-                                            {
-                                                return false;
-                                            }
-                                        }
+                                        return true;
                                     }
                                 }
                             }
@@ -2559,6 +2597,53 @@ public class CardSource : MonoBehaviour
     }
     #endregion
 
+    #region whether target permanent can Link into this card
+    public bool CanLinkFromTargetPermanent(Permanent targetPermanent, bool PayCost)
+    {
+        if (targetPermanent != null)
+        {
+            if (targetPermanent.TopCard != null)
+            {
+                if (targetPermanent.TopCard.Owner.GetFieldPermanents().Contains(targetPermanent))
+                {
+                    if (this.CanLink(PayCost))
+                    {
+                        if (linkCondition != null)
+                        {
+                            if (!this.CanNotEvolve(targetPermanent))
+                            {
+                                if (appFusionCondition.digimonCondition(targetPermanent))
+                                {
+                                    foreach (CardSource linkedCard in targetPermanent.LinkedCards)
+                                    {
+                                        if (appFusionCondition.linkedCondition(linkedCard))
+                                        {
+                                            if (PayCost)
+                                            {
+                                                int cost = appFusionCondition.cost;
+
+                                                cost = GetChangedCostItselef(cost, SelectCardEffect.Root.Hand, new List<Permanent>() { targetPermanent }, checkAvailability: true);
+
+                                                if (Owner.MaxMemoryCost < cost)
+                                                {
+                                                    return false;
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+    #endregion
+
+
     #region whether target permanent can App Fusion into this card
     public bool CanAppFusionFromTargetPermanent(Permanent targetPermanent, bool PayCost)
     {
@@ -2945,6 +3030,17 @@ public class BurstDigivolutionCondition
     public int cost { get; private set; } = 0;
 }
 
+public class LinkCondition
+{
+    public LinkCondition(Func<Permanent, bool> digimonCondition, int cost)
+    {
+        this.digimonCondition = digimonCondition;
+        this.cost = cost;
+    }
+    public Func<Permanent, bool> digimonCondition { get; private set; } = null;
+    public int cost { get; private set; } = 0;
+}
+
 public class AppFusionCondition
 {
     public AppFusionCondition(Func<CardSource, bool> linkedCondition, string selectLinkMessage, Func<Permanent, bool> digimonCondition, string selectDigimonMessage, int cost)

+ 28 - 19
Assets/Scripts/Effect Examples/Link_Examples.cs

@@ -10,30 +10,39 @@ namespace DCGO.CardEffects.Examples
         {
             List<ICardEffect> cardEffects = new List<ICardEffect>();
 
-            #region Basic link effect keyword
-            if (timing == EffectTiming.OnDeclaration)
+            #region Link Condition
+            if (timing == EffectTiming.None)
             {
-                //conditions for the permanent to link to
-                bool PermanentCondition(Permanent permanent)
+                static bool PermanentCondition(Permanent targetPermanent)
                 {
-                    if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
-                    {
-                        if (permanent.TopCard.EqualsTraits("Appmon"))
-                        {
-                            return true;
-                        }
-                    }
-
-                    return false;
+                    return targetPermanent.TopCard.HasAppmonTraits;
                 }
 
-                //any conditions for being able to link (currently there are none but situations could arise) - OPTIONAL
-                bool Condition()
-                {
-                    return true;
-                }
+                /// <summary>
+                /// Used to add a link condition to itself
+                /// </summary>
+                /// <param name="permanentCondition">Function to check for target permanent conditions</param>
+                /// <param name="linkCost">Cost to perform link</param>
+                /// <param name="card">Reference to this card</param>
+                /// <param name="condition">OPTIONAL - Function to check for effect conditions</param>
+                /// <param name="cardCondition">OPTIONAL - Function to check for cards conditions</param>
+                /// <param name="effectName">OPTIONAL - name to show for effect (default "Link")</param>
+                /// <author>Mike Bunch</author>
+                cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 0, card: card));
+            }
 
-                cardEffects.Add(CardEffectFactory.LinkEffect(card, PermanentCondition, Condition));
+            #endregion
+
+            #region Basic link effect keyword
+            if (timing == EffectTiming.OnDeclaration)
+            {
+                /// <summary>
+                /// Used to link a card
+                /// </summary>
+                /// <param name="card">Reference to this card</param>
+                /// <param name="condition">OPTIONAL - Function to check for effect conditions</param>
+                /// <author>Mike Bunch</author>
+                cardEffects.Add(CardEffectFactory.LinkEffect(card));
             }
             #endregion
 

+ 49 - 1
Assets/Scripts/TurnStateMachine.cs

@@ -2241,7 +2241,7 @@ public class TurnStateMachine : MonoBehaviourPunCallbacks
                                                     }
 
                                                     //Normal evolution and burst evolution possible
-                                                    else if (canNormalDigivolution && !canJogressDigivolution && canBurstDigivolution)
+                                                    else if (canNormalDigivolution && !canJogressDigivolution && canBurstDigivolution && !canAppFusion)
                                                     {
                                                         Vector3 Pos = handCard.transform.position;
 
@@ -2288,6 +2288,54 @@ public class TurnStateMachine : MonoBehaviourPunCallbacks
                                                             }
                                                         }
                                                     }
+                                                    //Normal evolution and App Fusion possible
+                                                    else if (canNormalDigivolution && !canJogressDigivolution && !canBurstDigivolution && canAppFusion)
+                                                    {
+                                                        Vector3 Pos = handCard.transform.position;
+
+                                                        ResetUI();
+
+                                                        handCard.transform.GetChild(0).gameObject.SetActive(false);
+
+                                                        handCard.GetComponent<Draggable_HandCard>().ReturnDefaultPosition();
+
+                                                        StartCoroutine(SelectWheterToAppFusion());
+
+                                                        IEnumerator SelectWheterToAppFusion()
+                                                        {
+                                                            isSync = true;
+
+                                                            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().MoveToExecuteCardEffect_SetPosition(handCard.cardSource, Pos));
+                                                            handCard.transform.position = handCard.cardSource.Owner.brainStormObject.BrainStormHandCards[0].transform.position;
+
+                                                            GManager.instance.selectAppFusionEffect.SetUp_SelectWheterToAppFusion
+                                                                (card: handCard.cardSource,
+                                                                evoRoot: fieldCardFrame.GetFramePermanent().TopCard,
+                                                                canNoSelect: true,
+                                                                endSelectCoroutine_Digivolve: _Digivolution,
+                                                                endSelectCoroutine_AppFusion: _SelectAppFusionPermanents,
+                                                                noSelectCoroutine: _NoSelectCoroutine);
+
+                                                            yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectAppFusionEffect.SelectWheterToAppFusion());
+
+                                                            IEnumerator _Digivolution()
+                                                            {
+                                                                yield return null;
+                                                                Digivolution();
+                                                            }
+
+                                                            IEnumerator _SelectAppFusionPermanents()
+                                                            {
+                                                                yield return null;
+                                                                SelectAppFusionCards(false);
+                                                            }
+
+                                                            IEnumerator _NoSelectCoroutine()
+                                                            {
+                                                                yield return StartCoroutine(Return());
+                                                            }
+                                                        }
+                                                    }
 
                                                     #region Select Jogress evolution source
                                                     void SelectJogressDigivolutionCards(bool move)