Ver código fonte

Add Vortex Keyword

Andrej Erdelsky 2 anos atrás
pai
commit
bb7b287cb4

+ 3 - 44
Assets/CardEffect/EX7/Green/GrandGalemon_EX7_034.cs

@@ -10,52 +10,11 @@ namespace DCGO.CardEffects.EX7
             List<ICardEffect> cardEffects = new List<ICardEffect>();
 
             #region Vortex
-
+            
             if (timing == EffectTiming.OnEndTurn)
             {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("Vortex", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
-                cardEffects.Add(activateClass);
-
-                string EffectDescription()
-                {
-                    return
-                        "<Vortex> [End of Your Turn] This Digimon may attack an opponent's Digimon. With this effect, it can attack the turn it was played.";
-                }
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleArea(card) &&
-                           CardEffectCommons.IsOwnerTurn(card);
-                }
-
-                bool CanActivateCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleArea(card) &&
-                           card.PermanentOfThisCard().CanAttack(activateClass, isVortex: true) &&
-                           CardEffectCommons.HasMatchConditionOpponentsPermanent(card, permanent =>
-                               permanent.IsDigimon &&
-                               card.PermanentOfThisCard().CanAttackTargetDigimon(permanent, activateClass, isVortex: true));
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    Permanent selectedPermanent = card.PermanentOfThisCard();
-
-                    if (selectedPermanent.CanAttack(activateClass, isVortex: true))
-                    {
-                        SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
-
-                        selectAttackEffect.SetUp(
-                            attacker: selectedPermanent,
-                            canAttackPlayerCondition: () => false,
-                            defenderCondition: _ => true,
-                            cardEffect: activateClass);
-
-                        yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
-                    }
-                }
+                cardEffects.Add(CardEffectFactory.VortexSelfEffect(isInheritedEffect: false, card: card,
+                    condition: null));
             }
 
             #endregion

+ 3 - 44
Assets/CardEffect/EX7/Green/Zephagamon_EX7_036.cs

@@ -23,49 +23,8 @@ namespace DCGO.CardEffects.EX7
 
             if (timing == EffectTiming.OnEndTurn)
             {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("Vortex", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
-                cardEffects.Add(activateClass);
-
-                string EffectDescription()
-                {
-                    return
-                        "<Vortex> [End of Your Turn] This Digimon may attack an opponent's Digimon. With this effect, it can attack the turn it was played.";
-                }
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleArea(card) &&
-                           CardEffectCommons.IsOwnerTurn(card);
-                }
-
-                bool CanActivateCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleArea(card) &&
-                           card.PermanentOfThisCard().CanAttack(activateClass, isVortex: true) &&
-                           CardEffectCommons.HasMatchConditionOpponentsPermanent(card, permanent =>
-                               permanent.IsDigimon &&
-                               card.PermanentOfThisCard().CanAttackTargetDigimon(permanent, activateClass, isVortex: true));
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    Permanent selectedPermanent = card.PermanentOfThisCard();
-
-                    if (selectedPermanent.CanAttack(activateClass, isVortex: true))
-                    {
-                        SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
-
-                        selectAttackEffect.SetUp(
-                            attacker: selectedPermanent,
-                            canAttackPlayerCondition: () => false,
-                            defenderCondition: _ => true,
-                            cardEffect: activateClass);
-
-                        yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
-                    }
-                }
+                cardEffects.Add(CardEffectFactory.VortexSelfEffect(isInheritedEffect: false, card: card,
+                    condition: null));
             }
 
             #endregion
@@ -83,7 +42,7 @@ namespace DCGO.CardEffects.EX7
                 return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
                        permanent.IsSuspended;
             }
-            
+
             bool CanActivateSharedCondition(Hashtable hashtable)
             {
                 return CardEffectCommons.IsExistOnBattleArea(card);

+ 79 - 0
Assets/Scripts/CardEffectCommons/KeyWordEffects/Vortex.cs

@@ -0,0 +1,79 @@
+using System.Collections;
+
+public partial class CardEffectCommons
+{
+    #region Can activate [Vortex]
+
+    public static bool CanActivateVortex(CardSource cardSource, ICardEffect activateClass)
+    {
+        return IsExistOnBattleArea(cardSource) &&
+               cardSource.PermanentOfThisCard().CanAttack(activateClass, isVortex: true) &&
+               HasMatchConditionOpponentsPermanent(cardSource, permanent =>
+                   permanent.IsDigimon &&
+                   cardSource.PermanentOfThisCard().CanAttackTargetDigimon(permanent, activateClass, isVortex: true));
+    }
+
+    #endregion
+
+    #region Effect process of [Vortex]
+
+    public static IEnumerator VortexProcess(CardSource cardSource, ICardEffect activateClass)
+    {
+        Permanent selectedPermanent = cardSource.PermanentOfThisCard();
+
+        if (selectedPermanent.CanAttack(activateClass, isVortex: true))
+        {
+            SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
+
+            selectAttackEffect.SetUp(
+                attacker: selectedPermanent,
+                canAttackPlayerCondition: () => false,
+                defenderCondition: _ => true,
+                cardEffect: activateClass);
+
+            yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
+        }
+    }
+
+    #endregion
+
+    #region Target 1 Digimon gains [Vortex]
+
+    public static IEnumerator GainVortex(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
+    {
+        if (targetPermanent == null) yield break;
+        if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+
+        bool CanUseCondition()
+        {
+            return IsPermanentExistsOnBattleArea(targetPermanent) &&
+                   !targetPermanent.TopCard.CanNotBeAffected(activateClass);
+        }
+
+        ActivateClass vortex = CardEffectFactory.VortexEffect(
+            targetPermanent: targetPermanent,
+            isInheritedEffect: false,
+            condition: CanUseCondition,
+            rootCardEffect: activateClass,
+            targetPermanent.TopCard);
+
+        AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: vortex,
+            timing: EffectTiming.OnAllyAttack);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
+                .CreateBuffEffect(targetPermanent));
+        }
+    }
+
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectCommons/KeyWordEffects/Vortex.cs.meta

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

+ 67 - 0
Assets/Scripts/CardEffectFactory/KeyWordEffects/Vortex.cs

@@ -0,0 +1,67 @@
+using System.Collections;
+using System;
+
+public partial class CardEffectFactory
+{
+    #region Trigger effect of [Vortex] on oneself
+
+    public static ActivateClass VortexSelfEffect(bool isInheritedEffect, CardSource card, Func<bool> condition,
+        ICardEffect rootCardEffect = null)
+    {
+        Permanent targetPermanent = card.PermanentOfThisCard();
+
+        bool CanUseCondition()
+        {
+            return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
+                   (condition == null || condition());
+        }
+
+        return VortexEffect(targetPermanent: targetPermanent, isInheritedEffect: isInheritedEffect, condition: CanUseCondition,
+            rootCardEffect: rootCardEffect, card);
+    }
+
+    #endregion
+
+    #region Trigger effect of [Vortex]
+
+    public static ActivateClass VortexEffect(Permanent targetPermanent, bool isInheritedEffect, Func<bool> condition,
+        ICardEffect rootCardEffect, CardSource card)
+    {
+        if (targetPermanent == null) return null;
+        if (targetPermanent.TopCard == null) return null;
+        if (card == null) return null;
+
+        ActivateClass activateClass = new ActivateClass();
+        activateClass.SetUpICardEffect("Vortex", CanUseCondition, card);
+        activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.VortexEffectDiscription());
+        activateClass.SetIsInheritedEffect(isInheritedEffect);
+
+        if (rootCardEffect != null)
+        {
+            activateClass.SetIsInheritedEffect(false);
+            activateClass.SetEffectSourcePermanent(targetPermanent);
+            activateClass.SetRootCardEffect(rootCardEffect);
+        }
+
+        bool CanUseCondition(Hashtable hashtable)
+        {
+            return CardEffectCommons.IsExistOnBattleArea(card) &&
+                   CardEffectCommons.IsOwnerTurn(card);
+        }
+
+        bool CanActivateCondition(Hashtable hashtable)
+        {
+            return CardEffectCommons.CanActivateVortex(targetPermanent.TopCard, activateClass) &&
+                   (condition == null || condition());
+        }
+
+        IEnumerator ActivateCoroutine(Hashtable hashtable)
+        {
+            return CardEffectCommons.VortexProcess(targetPermanent.TopCard, activateClass);
+        }
+
+        return activateClass;
+    }
+
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectFactory/KeyWordEffects/Vortex.cs.meta

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

+ 5 - 0
Assets/Scripts/DataBase.cs

@@ -488,6 +488,11 @@ public class DataBase : MonoBehaviour
     {
         return "<Raid> (When this Digimon attacks, you may switch the target of attack to 1 of your opponent's unsuspended Digimon with the highest DP.)";
     }
+    
+    public static string VortexEffectDiscription()
+    {
+        return "<Vortex> (At the end of your turn, this Digimon may attack an opponent's Digimon. With this effect, it can attack the turn it was played.)";
+    }
 
     public static string BarrierEffectDiscription()
     {