Переглянути джерело

Merge pull request #1481 from DCGO2/x89rt2-patch-21

Update EX6_057.cs
x89rt2 2 місяців тому
батько
коміт
baba8b54dd
1 змінених файлів з 86 додано та 339 видалено
  1. 86 339
      Assets/Scripts/CardEffect/EX6/Purple/EX6_057.cs

+ 86 - 339
Assets/Scripts/CardEffect/EX6/Purple/EX6_057.cs

@@ -1,11 +1,7 @@
 using System.Collections;
 using System.Collections.Generic;
-using UnityEngine;
-using System.Linq;
-using Photon;
-using System;
-using Photon.Pun;
 
+// Lilithmon
 namespace DCGO.CardEffects.EX6
 {
     public class EX6_057 : CEntity_Effect
@@ -14,298 +10,94 @@ namespace DCGO.CardEffects.EX6
         {
             List<ICardEffect> cardEffects = new List<ICardEffect>();
 
-            #region On Play
-            if (timing == EffectTiming.OnEnterFieldAnyone)
-            {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("Give 1 opponent Digimon [End of Your Turn] Delete this Digimon.", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
-                cardEffects.Add(activateClass);
-
-                string EffectDiscription()
-                {
-                    return "[On Play] Until the end of your opponent's turn, 1 of your opponent's Digimon gains [End of Your Turn] Delete this Digimon.";
-                }
+            #region Shared OP / WD
+            string SharedEffectName = "Give 1 opponent Digimon [End of Your Turn] Delete this Digimon";
 
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
-                }
+            CardEffectFactory.ActivateClassesForSharedEffects
+                (ref cardEffects, timing, card,
+                    SharedEffectName,
+                    SharedActivateCoroutine,
+                    SharedEffectDescription,
+                    optional: false,
+                    onPlay: true,
+                    whenDigivolving: true);
 
-                bool CanActivateCondition(Hashtable hashtable)
-                {
-                    if(CardEffectCommons.IsExistOnBattleArea(card))
-                    {
-                        return true;
-                    }
-                    return false;
-                }
+            string SharedEffectDescription(string tag) => $"[{tag}] Until the end of your opponent's turn, 1 of your opponent's Digimon gains [End of Your Turn] Delete this Digimon.";
 
+            IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
+            {
                 bool CanSelectPermanentCondition(Permanent permanent)
                 {
-                    if(CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent,card))
-                    {
-                        return true;
-                    }   
-                    return false;
+                    return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
                 }
 
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
                 {
-                    if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
-                    {
-                        int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
+                    SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
 
-                        SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+                    selectPermanentEffect.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: CanSelectPermanentCondition,
+                        canTargetCondition_ByPreSelecetedList: null,
+                        canEndSelectCondition: null,
+                        maxCount: 1,
+                        canNoSelect: false,
+                        canEndNotMax: false,
+                        selectPermanentCoroutine: SelectPermanentCoroutine,
+                        afterSelectPermanentCoroutine: null,
+                        mode: SelectPermanentEffect.Mode.Custom,
+                        cardEffect: activateClass);
 
-                        selectPermanentEffect.SetUp(
-                            selectPlayer: card.Owner,
-                            canTargetCondition: CanSelectPermanentCondition,
-                            canTargetCondition_ByPreSelecetedList: null,
-                            canEndSelectCondition: null,
-                            maxCount: maxCount,
-                            canNoSelect: false,
-                            canEndNotMax: false,
-                            selectPermanentCoroutine: SelectPermanentCoroutine,
-                            afterSelectPermanentCoroutine: null,
-                            mode: SelectPermanentEffect.Mode.Custom,
-                            cardEffect: activateClass);
+                    selectPermanentEffect.SetUpCustomMessage(
+                        "Select 1 Digimon that will get [End of Your Turn] Delete this Digimon.",
+                        "The opponent is selecting 1 Digimon that will get [End of Your Turn] Delete this Digimon.");
 
-                        selectPermanentEffect.SetUpCustomMessage(
-                            "Select 1 Digimon that will get [End of Your Turn] Delete this Digimon.",
-                            "The opponent is selecting 1 Digimon that will get [End of Your Turn] Delete this Digimon.");
+                    yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
 
-                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+                    IEnumerator SelectPermanentCoroutine(Permanent permanent)
+                    {
+                        Permanent selectedPermanent = permanent;
 
-                        IEnumerator SelectPermanentCoroutine(Permanent permanent)
+                        if (selectedPermanent != null)
                         {
-                            Permanent selectedPermanent = permanent;
-
-                            if (selectedPermanent != null)
+                            ActivateClass activateClass1 = new ActivateClass();
+                            activateClass1.SetUpICardEffect("Delete this Digimon", CanUseCondition1, selectedPermanent.TopCard);
+                            activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDescription1());
+                            activateClass1.SetEffectSourcePermanent(selectedPermanent);
+                            CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: PermanentEffectFactory.AddDetailClass(selectedPermanent, "[End of Your Turn] Delete this Digimon.", true, activateClass), timing: EffectTiming.None);
+                            CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnEndTurn);
+
+                            if (!permanent.TopCard.CanNotBeAffected(activateClass))
                             {
                                 yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
                             }
 
-                            if (selectedPermanent != null)
+                            string EffectDescription1()
                             {
-                                ActivateClass activateClass1 = new ActivateClass();
-                                activateClass1.SetUpICardEffect("Delete this Digimon", CanUseCondition1, selectedPermanent.TopCard);
-                                activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
-                                activateClass1.SetEffectSourcePermanent(selectedPermanent);
-                                selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
-                                selectedPermanent.UntilOwnerTurnEndEffects.Add(GetDetailEffect);
-
-                                if (!permanent.TopCard.CanNotBeAffected(activateClass))
-                                {
-                                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
-                                }
-
-                                string EffectDiscription1()
-                                {
-                                    return "[End of Your Turn] Delete this Digimon.";
-                                }
-
-                                bool CanUseCondition1(Hashtable hashtable1)
-                                {
-                                    if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
-                                    {
-                                        if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
-                                        {
-                                            if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
-                                            {
-                                                return true;
-                                            }
-                                        }
-                                    }
-
-                                    return false;
-                                }
-
-                                bool CanActivateCondition1(Hashtable hashtable1)
-                                {
-                                    if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
-                                    {
-                                        if (!permanent.TopCard.CanNotBeAffected(activateClass))
-                                        {
-                                            return true;
-                                        }
-                                    }
-
-                                    return false;
-                                }
-
-                                IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
-                                {
-                                    if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
-                                    {
-                                        yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
-                                        new List<Permanent>() { selectedPermanent },
-                                        CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
-                                    }
-                                }
-
-                                ICardEffect GetCardEffect(EffectTiming _timing)
-                                {
-                                    if (_timing == EffectTiming.OnEndTurn)
-                                    {
-                                        return activateClass1;
-                                    }
-
-                                    return null;
-                                }
-
-                                ICardEffect GetDetailEffect(EffectTiming timing)
-                                {
-                                   if (timing == EffectTiming.None)
-                                   {
-                                       return PermanentEffectFactory.AddDetailClass(permanent, "[End of your turn] Delete this Digimon", true, activateClass);
-                                   }
-                                   return null;
-                                }
+                                return "[End of Your Turn] Delete this Digimon.";
                             }
-                        }
-                    }
-                }
-            }
-            #endregion
-
-            #region When Digivolving
-            if (timing == EffectTiming.OnEnterFieldAnyone)
-            {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("Give 1 opponent Digimon [End of Your Turn] Delete this Digimon.", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
-                cardEffects.Add(activateClass);
-
-                string EffectDiscription()
-                {
-                    return "[When Digivolving] Until the end of your opponent's turn, 1 of your opponent's Digimon gains [End of Your Turn] Delete this Digimon.";
-                }
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
-                }
-
-                bool CanActivateCondition(Hashtable hashtable)
-                {
-                    if (CardEffectCommons.IsExistOnBattleArea(card))
-                    {
-                        return true;
-                    }
-                    return false;
-                }
-
-                bool CanSelectPermanentCondition(Permanent permanent)
-                {
-                    if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
-                    {
-                        return true;
-                    }
-                    return false;
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
-                    {
-                        int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
-
-                        SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
 
-                        selectPermanentEffect.SetUp(
-                            selectPlayer: card.Owner,
-                            canTargetCondition: CanSelectPermanentCondition,
-                            canTargetCondition_ByPreSelecetedList: null,
-                            canEndSelectCondition: null,
-                            maxCount: maxCount,
-                            canNoSelect: false,
-                            canEndNotMax: false,
-                            selectPermanentCoroutine: SelectPermanentCoroutine,
-                            afterSelectPermanentCoroutine: null,
-                            mode: SelectPermanentEffect.Mode.Custom,
-                            cardEffect: activateClass);
-
-                        selectPermanentEffect.SetUpCustomMessage(
-                            "Select 1 Digimon that will get [End of Your Turn] Delete this Digimon.",
-                            "The opponent is selecting 1 Digimon that will get [End of Your Turn] Delete this Digimon.");
-
-                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
-
-                        IEnumerator SelectPermanentCoroutine(Permanent permanent)
-                        {
-                            Permanent selectedPermanent = permanent;
-
-                            if (selectedPermanent != null)
+                            bool CanUseCondition1(Hashtable hashtable1)
                             {
-                                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
+                                return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent)
+                                    && selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent)
+                                    && GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner
+                                    && !permanent.TopCard.CanNotBeAffected(activateClass);
                             }
 
-                            if (selectedPermanent != null)
+                            bool CanActivateCondition1(Hashtable hashtable1)
                             {
-                                ActivateClass activateClass1 = new ActivateClass();
-                                activateClass1.SetUpICardEffect("Delete this Digimon", CanUseCondition1, selectedPermanent.TopCard);
-                                activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
-                                activateClass1.SetEffectSourcePermanent(selectedPermanent);
-                                selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
-
-                                if (!permanent.TopCard.CanNotBeAffected(activateClass))
-                                {
-                                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
-                                }
-
-                                string EffectDiscription1()
-                                {
-                                    return "[End of Your Turn] Delete this Digimon.";
-                                }
-
-                                bool CanUseCondition1(Hashtable hashtable1)
-                                {
-                                    if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
-                                    {
-                                        if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
-                                        {
-                                            if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
-                                            {
-                                                return true;
-                                            }
-                                        }
-                                    }
-
-                                    return false;
-                                }
-
-                                bool CanActivateCondition1(Hashtable hashtable1)
-                                {
-                                    if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
-                                    {
-                                        if (!permanent.TopCard.CanNotBeAffected(activateClass))
-                                        {
-                                            return true;
-                                        }
-                                    }
-
-                                    return false;
-                                }
-
-                                IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
-                                {
-                                    if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
-                                    {
-                                        yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
-                                        new List<Permanent>() { selectedPermanent },
-                                        CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
-                                    }
-                                }
+                                return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent)
+                                    && !permanent.TopCard.CanNotBeAffected(activateClass);
+                            }
 
-                                ICardEffect GetCardEffect(EffectTiming _timing)
+                            IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
+                            {
+                                if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
                                 {
-                                    if (_timing == EffectTiming.OnEndTurn)
-                                    {
-                                        return activateClass1;
-                                    }
-
-                                    return null;
+                                    yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
+                                    new List<Permanent>() { selectedPermanent },
+                                    CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
                                 }
                             }
                         }
@@ -319,69 +111,46 @@ namespace DCGO.CardEffects.EX6
             {
                 ActivateClass activateClass = new ActivateClass();
                 activateClass.SetUpICardEffect("Delete 1 level 5 or lower Digimon to prevent leaving the battle area", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
                 activateClass.SetHashString("Protection_EX6_057");
                 cardEffects.Add(activateClass);
 
-                string EffectDiscription()
+                string EffectDescription()
                 {
                     return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area other than in battle, by deleting 1 level 5 or lower Digimon, prevent it from leaving.";
                 }
 
                 bool CanSelectPermanentCondition(Permanent permanent)
                 {
-                    if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
-                    {
-                        if (permanent.Level <= 5)
-                        {
-                            return true;
-                        }
-                    }
-                    return false;
+                    return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
+                        && permanent.TopCard.HasLevel
+                        && permanent.Level <= 5;
                 }
 
                 bool CanUseCondition(Hashtable hashtable)
                 {
-                    if (CardEffectCommons.IsExistOnBattleArea(card))
-                    {
-                        if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
-                        {
-                            if (!CardEffectCommons.IsByBattle(hashtable))
-                            {
-                                return true;
-                            }
-                        }
-                    }
-
-                    return false;
+                    return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
+                        && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
+                        && !CardEffectCommons.IsByBattle(hashtable);
                 }
 
                 bool CanActivateCondition(Hashtable hashtable)
                 {
-                    if (CardEffectCommons.IsExistOnBattleArea(card))
-                    {
-                        if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
-                        {
-                            return true;
-                        }
-                    }
-
-                    return false;
+                    return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
+                        && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
                 }
 
                 IEnumerator ActivateCoroutine(Hashtable hashtable)
                 {
                     if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
                     {
-                        int maxCount = 1;
-
                         SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
                         selectPermanentEffect.SetUp(
                             selectPlayer: card.Owner,
                             canTargetCondition: CanSelectPermanentCondition,
                             canTargetCondition_ByPreSelecetedList: null,
                             canEndSelectCondition: null,
-                            maxCount: maxCount,
+                            maxCount: 1,
                             canNoSelect: true,
                             canEndNotMax: false,
                             selectPermanentCoroutine: SelectPermanentCoroutine,
@@ -416,61 +185,39 @@ namespace DCGO.CardEffects.EX6
             {
                 ActivateClass activateClass = new ActivateClass();
                 activateClass.SetUpICardEffect("Trash the top card of your opponent's security", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
                 cardEffects.Add(activateClass);
 
-                string EffectDiscription()
+                string EffectDescription()
                 {
                     return "[Opponent's Turn] [Once Per Turn] When another Digimon is deleted, trash the top card of your opponent's security stack.";
                 }
 
                 bool PermanentCondition(Permanent permanent)
                 {
-                    if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
-                    {
-                        if (permanent.IsDigimon)
-                        {
-                            if (permanent != card.PermanentOfThisCard())
-                            {
-                                return true;
-                            }
-                        }
-                    }
-
-                    return false;
+                    return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
+                        && permanent != card.PermanentOfThisCard();
                 }
 
                 bool CanUseCondition(Hashtable hashtable)
                 {
-                    if (CardEffectCommons.IsOpponentTurn(card))
-                    {
-                        if (CardEffectCommons.IsExistOnBattleArea(card))
-                        {
-                            if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
-                            {
-                                return true;
-                            }
-                        }
-                    }
-                    return false;
+                    return CardEffectCommons.IsOpponentTurn(card)
+                        && CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
+                        && CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass);
                 }
 
                 bool CanActivateCondition(Hashtable hashtable)
                 {
-                    if(CardEffectCommons.IsExistOnBattleArea(card))
-                    {
-                        return true;
-                    }
-                    return false;
+                    return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
                 }
 
                 IEnumerator ActivateCoroutine(Hashtable hashtable)
                 {
                     yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
-                   player: card.Owner.Enemy,
-                   destroySecurityCount: 1,
-                   cardEffect: activateClass,
-                   fromTop: true).DestroySecurity());
+                        player: card.Owner.Enemy,
+                        destroySecurityCount: 1,
+                        cardEffect: activateClass,
+                        fromTop: true).DestroySecurity());
                 }
             }
             #endregion
@@ -478,4 +225,4 @@ namespace DCGO.CardEffects.EX6
             return cardEffects;
         }
     }
-}
+}