Browse Source

Add overclock keyword

Andrej Erdelsky 2 năm trước cách đây
mục cha
commit
8c8eeced84

+ 2 - 0
Assets/CardEffect/EX7/Yellow/Cendrillmon_EX7_030.cs

@@ -14,6 +14,8 @@ namespace DCGO.CardEffects.EX7
 
             if (timing == EffectTiming.OnEndTurn)
             {
+                cardEffects.Add(CardEffectFactory.OverclockSelfEffect(trait: "Puppet", isInheritedEffect: false, card: card,
+                    condition: null));
             }
 
             #endregion

+ 2 - 0
Assets/CardEffect/EX7/Yellow/Chaperomon_EX7_027.cs

@@ -13,6 +13,8 @@ namespace DCGO.CardEffects.EX7
 
             if (timing == EffectTiming.OnEndTurn)
             {
+                cardEffects.Add(CardEffectFactory.OverclockSelfEffect(trait: "Puppet", isInheritedEffect: false, card: card,
+                    condition: null));
             }
 
             #endregion

+ 124 - 0
Assets/Scripts/CardEffectCommons/KeyWordEffects/Overclock.cs

@@ -0,0 +1,124 @@
+using System.Collections;
+using System.Collections.Generic;
+
+public partial class CardEffectCommons
+{
+    static bool CanSelectPermanentCondition(Permanent permanent, string trait, CardSource cardSource)
+    {
+        return IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, cardSource) &&
+               permanent != cardSource.PermanentOfThisCard() &&
+               (permanent.IsToken || permanent.TopCard.ContainsTraits(trait));
+    }
+
+    #region Can activate [Overclock]
+
+    public static bool CanActivateOverclock(string trait, CardSource cardSource, ICardEffect activateClass)
+    {
+        return IsExistOnBattleArea(cardSource) &&
+               HasMatchConditionPermanent(permanent => CanSelectPermanentCondition(permanent, trait, cardSource)) &&
+               cardSource.PermanentOfThisCard().CanAttack(activateClass, withoutTap: true);
+    }
+
+    #endregion
+
+    #region Effect process of [Overclock]
+
+    public static IEnumerator OverclockProcess(string trait, CardSource cardSource, ICardEffect activateClass)
+    {
+        if (HasMatchConditionPermanent(permanent => CanSelectPermanentCondition(permanent, trait, cardSource)))
+        {
+            SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+
+            selectPermanentEffect.SetUp(
+                selectPlayer: cardSource.Owner,
+                canTargetCondition: permanent => CanSelectPermanentCondition(permanent, trait, cardSource),
+                canTargetCondition_ByPreSelecetedList: null,
+                canEndSelectCondition: null,
+                maxCount: 1,
+                canNoSelect: true,
+                canEndNotMax: false,
+                selectPermanentCoroutine: SelectPermanentCoroutine,
+                afterSelectPermanentCoroutine: null,
+                mode: SelectPermanentEffect.Mode.Custom,
+                cardEffect: activateClass);
+
+            selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
+                "The opponent is selecting 1 Digimon to delete.");
+
+            yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+
+            IEnumerator SelectPermanentCoroutine(Permanent permanent)
+            {
+                yield return ContinuousController.instance.StartCoroutine(
+                    DeletePeremanentAndProcessAccordingToResult(
+                        targetPermanents: new List<Permanent>() { permanent },
+                        activateClass: activateClass,
+                        successProcess: _ => SuccessProcess(),
+                        failureProcess: null));
+
+                IEnumerator SuccessProcess()
+                {
+                    Permanent selectedPermanent = cardSource.PermanentOfThisCard();
+
+                    if (selectedPermanent.CanAttack(activateClass, withoutTap: true))
+                    {
+                        SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
+
+                        selectAttackEffect.SetUp(
+                            attacker: selectedPermanent,
+                            canAttackPlayerCondition: () => true,
+                            defenderCondition: _ => false,
+                            cardEffect: activateClass);
+
+                        selectAttackEffect.SetWithoutTap();
+                        yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
+                    }
+                }
+            }
+        }
+    }
+
+    #endregion
+
+    #region Target 1 Digimon gains [Overclock]
+
+    public static IEnumerator GainOverclock(string trait, 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 overclock = CardEffectFactory.OverclockEffect(
+            trait: trait,
+            targetPermanent: targetPermanent,
+            isInheritedEffect: false,
+            condition: CanUseCondition,
+            rootCardEffect: activateClass,
+            targetPermanent.TopCard);
+
+        AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: overclock,
+            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/Overclock.cs.meta

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

+ 68 - 0
Assets/Scripts/CardEffectFactory/KeyWordEffects/Overclock.cs

@@ -0,0 +1,68 @@
+using System.Collections;
+using System;
+
+public partial class CardEffectFactory
+{
+    #region Trigger effect of [Overclock] on oneself
+
+    public static ActivateClass OverclockSelfEffect(string trait, bool isInheritedEffect, CardSource card, Func<bool> condition,
+        ICardEffect rootCardEffect = null)
+    {
+        Permanent targetPermanent = card.PermanentOfThisCard();
+
+        bool CanUseCondition()
+        {
+            return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
+                   (condition == null || condition());
+        }
+
+        return OverclockEffect(trait: trait, targetPermanent: targetPermanent, isInheritedEffect: isInheritedEffect,
+            condition: CanUseCondition,
+            rootCardEffect: rootCardEffect, card);
+    }
+
+    #endregion
+
+    #region Trigger effect of [Overclock]
+
+    public static ActivateClass OverclockEffect(string trait, 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("Overclock", CanUseCondition, card);
+        activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.OverclockEffectDiscription(trait));
+        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.CanActivateOverclock(trait, targetPermanent.TopCard, activateClass) &&
+                   (condition == null || condition());
+        }
+
+        IEnumerator ActivateCoroutine(Hashtable hashtable)
+        {
+            return CardEffectCommons.OverclockProcess(trait, targetPermanent.TopCard, activateClass);
+        }
+
+        return activateClass;
+    }
+
+    #endregion
+}

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

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

+ 15 - 10
Assets/Scripts/DataBase.cs

@@ -461,7 +461,7 @@ public class DataBase : MonoBehaviour
 
     public static string RetaliationEffectDiscription()
     {
-        return "<Retaliation> (When this Digimon is deleted after losing a battle, delete the Digimon it was battling)";
+        return "<Retaliation> (When this Digimon is deleted after losing a battle, delete the Digimon it was battling.)";
     }
 
     public static string BilitzEffectDiscription()
@@ -488,11 +488,6 @@ 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()
     {
@@ -501,7 +496,7 @@ public class DataBase : MonoBehaviour
 
     public static string BlastDigivolveEffectDiscription()
     {
-        return "[Hand] [Counter] <Blast Digivolve> (Your Digimon may digivolve into this card without paying the cost).";
+        return "[Hand] [Counter] <Blast Digivolve> (Your Digimon may digivolve into this card without paying the cost.)";
     }
 
     public static string BlastDNADigivolveEffectDiscription()
@@ -511,7 +506,7 @@ public class DataBase : MonoBehaviour
 
     public static string FortitudeEffectDiscription()
     {
-        return "<Fortitude> (When this Digimon with digivolution cards is deleted, play this card without paying the cost).";
+        return "<Fortitude> (When this Digimon with digivolution cards is deleted, play this card without paying the cost.)";
     }
 
     public static string AllianceEffectDiscription()
@@ -521,12 +516,22 @@ public class DataBase : MonoBehaviour
 
     public static string PartitionEffectDiscription()
     {
-        return "<Partition> (When this Digimon with 1 of each specified card in its digivolution cards would leave the battle area other than by one of your effects or in battle, you may play 1 of each card without paying their costs)";
+        return "<Partition> (When this Digimon with 1 of each specified card in its digivolution cards would leave the battle area other than by one of your effects or in battle, you may play 1 of each card without paying their costs.)";
     }
 
     public static string CollisionEffectDiscription()
     {
-        return "<Collision> (During this Digimon's attack, all of your opponent's Digimon gain <Blocker>, and your opponent blocks if possible)";
+        return "<Collision> (During this Digimon's attack, all of your opponent's Digimon gain <Blocker>, and your opponent blocks if possible.)";
+    }
+    
+    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 OverclockEffectDiscription(string trait)
+    {
+        return $"<Overclock [{trait}]> (At the end of your turn, by deleting 1 of your Tokens or other [{trait}] trait Digimon, this Digimon attacks a player without suspending.)";
     }
 
     public static string ReplaceToASCII(string text)