فهرست منبع

Implement AD1-009 and Mode.Attack

hooperk 5 ماه پیش
والد
کامیت
cb4d606bbb
2فایلهای تغییر یافته به همراه337 افزوده شده و 0 حذف شده
  1. 295 0
      Assets/Scripts/CardEffect/AD1/Red/AD1_009.cs
  2. 42 0
      Assets/Scripts/Script/SelectPermanentEffect.cs

+ 295 - 0
Assets/Scripts/CardEffect/AD1/Red/AD1_009.cs

@@ -0,0 +1,295 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+// BlitzGreymon
+namespace DCGO.CardEffects.AD1
+{
+    public class AD1_009 : CEntity_Effect
+    {
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+        {
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
+
+            #region Alternative Digivolution Condition
+            if (timing == EffectTiming.None)
+            {
+                bool PermanentCondition(Permanent targetPermanent)
+                {
+                    return targetPermanent.TopCard.ContainsCardName("Greymon")
+                        || targetPermanent.TopCard.EqualsTraits("ADVENTURE");
+                }
+
+                cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
+                    level: 5,
+                    permanentCondition: PermanentCondition,
+                    digivolutionCost: 3,
+                    ignoreDigivolutionRequirement: false,
+                    card: card,
+                    condition: null)
+                );
+            }
+            #endregion
+
+            #region Alliance, Piercing and Blocker
+            if (timing == EffectTiming.OnAllyAttack)
+            {
+                cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
+            }
+
+            if (timing == EffectTiming.OnDetermineDoSecurityCheck)
+            {
+                cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
+            }
+
+            if (timing == EffectTiming.None)
+            {
+                cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
+            }
+            #endregion
+
+            #region Shared OP / WD
+
+            string SharedEffectName = "<De-Digivolve 3> 1 opponent's Digimon. Until the end of your opponent's turn this Digimon and 1 with [Garurumon] in name cannot be affected by their Digimon's effects";
+
+            string SharedEffectDescription(string tag)
+                => $"[{tag}] <De-Digivolve 3> 1 of your opponent's Digimon. Then, until your opponent's turn ends, their Digimon's effects don't affect this Digimon and 1 of your Digimon with [Garurumon] in its name.";
+
+            bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
+
+            bool IsEnemyDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
+
+            bool IsOwnGarurumon(Permanent permanent)
+            {
+                return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                    && permanent.TopCard.ContainsCardName("Garurumon");
+            }
+
+            IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
+            {
+                if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsEnemyDigimon))
+                {
+                    SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+                    selectPermanentEffect.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: IsEnemyDigimon,
+                        canTargetCondition_ByPreSelecetedList: null,
+                        canEndSelectCondition: null,
+                        maxCount: 1,
+                        canNoSelect: false,
+                        canEndNotMax: false,
+                        selectPermanentCoroutine: null,
+                        afterSelectPermanentCoroutine: null,
+                        mode: SelectPermanentEffect.Mode.Degenerate,
+                        cardEffect: activateClass);
+
+                    selectPermanentEffect.SetDegenerationCount(3);
+
+                    selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-Digivolve", "The opponent is selecting 1 Digimon to De-Digivolve");
+                    yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+                }
+
+                if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsOwnGarurumon))
+                {
+                    SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+                    selectPermanentEffect.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: IsOwnGarurumon,
+                        canTargetCondition_ByPreSelecetedList: null,
+                        canEndSelectCondition: null,
+                        maxCount: 1,
+                        canNoSelect: false,
+                        canEndNotMax: false,
+                        selectPermanentCoroutine: SelectPermanentCoroutine,
+                        afterSelectPermanentCoroutine: null,
+                        mode: SelectPermanentEffect.Mode.Custom,
+                        cardEffect: activateClass);
+
+                    selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get immunity.", "The opponent is selecting 1 Digimon that will get immunity.");
+                    yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+
+                    IEnumerator SelectPermanentCoroutine(Permanent permanent)
+                    {
+                        #region Give Digimon Effect Immunity
+                        permanent.UntilOpponentTurnEndEffects.Add((_timing) => PermanentEffectFactory.DigimonEffectImmunity(permanent));
+
+                        yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(permanent));
+                        #endregion
+                    }
+                }
+
+                #region Give Digimon Effect Immunity
+                Permanent thisPermanent = card.PermanentOfThisCard();
+                thisPermanent.UntilOpponentTurnEndEffects.Add((_timing) => PermanentEffectFactory.DigimonEffectImmunity(thisPermanent));
+
+                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(thisPermanent));
+                #endregion
+            }
+            #endregion
+
+            #region On Play
+            if (timing == EffectTiming.OnEnterFieldAnyone)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
+                activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("On Play"));
+                cardEffects.Add(activateClass);
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistOnBattleArea(card)
+                        && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
+                }
+            }
+            #endregion
+
+            #region When Digivolving
+            if (timing == EffectTiming.OnEnterFieldAnyone)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
+                activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
+                cardEffects.Add(activateClass);
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistOnBattleArea(card)
+                        && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
+                }
+            }
+            #endregion
+
+            #region End of Your Turn
+            if (timing == EffectTiming.OnEndTurn)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("DNA digivolve into [Omnimon Alter-S]. 1 Digimon may attack.", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
+                cardEffects.Add(activateClass);
+
+                string EffectDescription() =>  "[End of Your Turn] 2 of your Digimon may DNA digivolve into [Omnimon Alter-S] in the hand. Then, 1 of your Digimon may attack.";
+
+                bool CanSelectDNACardCondition(CardSource cardSource)
+                {
+                    return cardSource.IsDigimon
+                        && cardSource.CanPlayJogress(true)
+                        && cardSource.EqualsCardName("Omnimon Alter-S");
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistOnBattleArea(card)
+                        && CardEffectCommons.IsOwnerTurn(card);
+                }
+
+                bool CanActivateCondition(Hashtable hashtable) =>  CardEffectCommons.IsExistOnBattleArea(card);
+
+                bool IsYourDigimon(Permanent permanent)
+                {
+                    return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                        && permanent.CanAttack(activateClass);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    #region DNA digivolve
+                    yield return ContinuousController.instance.StartCoroutine(
+                        CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
+                            CanSelectDNACardCondition,
+                            payCost: true,
+                            isHand: true,
+                            activateClass
+                        ));
+                    #endregion
+                    #region May Attack
+                    if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYourDigimon))
+                    {
+                        SelectPermanentEffect selectPermanentEffect =
+                            GManager.instance.GetComponent<SelectPermanentEffect>();
+
+                        selectPermanentEffect.SetUp(
+                            selectPlayer: card.Owner,
+                            canTargetCondition: IsYourDigimon,
+                            canTargetCondition_ByPreSelecetedList: null,
+                            canEndSelectCondition: null,
+                            maxCount: 1,
+                            canNoSelect: true,
+                            canEndNotMax: false,
+                            selectPermanentCoroutine: null,
+                            afterSelectPermanentCoroutine: null,
+                            mode: SelectPermanentEffect.Mode.Attack,
+                            cardEffect: activateClass);
+
+                        selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.",
+                            "The opponent is selecting 1 Digimon that will attack.");
+
+                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+                    }
+                    #endregion
+                }
+            }
+            #endregion
+
+            #region Assembly
+            if (timing == EffectTiming.None)
+            {
+                string cardName1 = "MetalGreymon: Alterous Mode";
+                string cardName2 = "Greymon";
+                AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
+                addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
+                addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
+                addAssemblyConditionClass.SetNotShowUI(true);
+                cardEffects.Add(addAssemblyConditionClass);
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return true;
+                }
+
+                AssemblyCondition GetAssembly(CardSource cardSource)
+                {
+                    if (cardSource == card)
+                    {
+                        AssemblyConditionElement element1 = new AssemblyConditionElement(CanSelectCardCondition1, selectMessage: $"[{cardName1}]", elementCount: 1);
+                        AssemblyConditionElement element2 = new AssemblyConditionElement(CanSelectCardCondition2, selectMessage: $"[{cardName2}]", elementCount: 1);
+
+                        bool CanSelectCardCondition1(CardSource cardSource)
+                        {
+                            return cardSource != null && 
+                                cardSource.Owner == card.Owner && 
+                                cardSource.IsDigimon && 
+                                cardSource.EqualsCardName(cardName1);
+                        }
+
+                        bool CanSelectCardCondition2(CardSource cardSource)
+                        {
+                            return cardSource != null && 
+                                cardSource.Owner == card.Owner && 
+                                cardSource.IsDigimon && 
+                                cardSource.EqualsCardName(cardName2);
+                        }
+
+                        AssemblyCondition assemblyCondition = new AssemblyCondition(
+                            elements:new List<AssemblyConditionElement>() { element1, element2 },
+                            reduceCost: 4);
+
+                        return assemblyCondition;
+                    }
+
+                    return null;
+                }
+            }
+            #endregion
+
+            #region ESS Sec +1
+            if (timing == EffectTiming.None)
+            {
+                cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: null));
+            }
+            #endregion
+
+            return cardEffects;
+        }
+    }
+}

+ 42 - 0
Assets/Scripts/Script/SelectPermanentEffect.cs

@@ -78,6 +78,15 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
         _degenerationCount = degenerationCount;
     }
 
+    public void SetCanNotAttackPlayer()
+    {
+        _canAttackPlayer = false;
+    }
+    public void SetDefenderCondition(Func<Permanent, bool> defenderCondition)
+    {
+        _defenderCondition = defenderCondition;
+    }
+
     //Player to select
     Player _selectPlayer = null;
     //Conditions of units that can be selected
@@ -103,6 +112,8 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
     bool _isLocal = false;
     bool _isdigiXros = false;
     int _degenerationCount = 1;
+    bool _canAttackPlayer = true;
+    Func<Permanent, bool> _defenderCondition = (permanent) => true;
 
     public enum Mode
     {
@@ -113,6 +124,7 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
         PutLibraryBottom,
         PutLibraryTop,
         Degenerate,
+        Attack,
         Custom
     }
 
@@ -232,6 +244,7 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
         List<Permanent> libraryTopPermanents = new List<Permanent>();
         List<Permanent> handBouncePermanents = new List<Permanent>();
         List<Permanent> degeneratePermanents = new List<Permanent>();
+        List<Permanent> attackPermanents = new List<Permanent>();
 
         _noSelect = false;
 
@@ -316,6 +329,10 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
                             message = $"Select cards to De-Digivolve {_degenerationCount}.";
                             break;
 
+                        case Mode.Attack:
+                            message = "Select a Digimon to attack with.";
+                            break;
+
                         case Mode.Custom:
                             message = "Select cards.";
                             break;
@@ -847,6 +864,10 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
                             case Mode.Degenerate:
                                 degeneratePermanents.Add(targetPermanent);
                                 break;
+
+                            case Mode.Attack:
+                                attackPermanents.Add(targetPermanent);
+                                break;
                         }
                         #endregion
 
@@ -908,6 +929,27 @@ public class SelectPermanentEffect : MonoBehaviourPunCallbacks
                             yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, _degenerationCount, _cardEffect).Degeneration());
                         }
                     }
+
+                    if (attackPermanents.Count > 0)
+                    {
+                        foreach (Permanent selectedPermanent in degeneratePermanents)
+                        {
+                            if (selectedPermanent.CanAttack(_cardEffect))
+                            {
+                                SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
+
+                                selectAttackEffect.SetUp(
+                                    attacker: selectedPermanent,
+                                    canAttackPlayerCondition: () => _canAttackPlayer,
+                                    defenderCondition: _defenderCondition,
+                                    cardEffect: _cardEffect);
+
+                                if (!_canNoSelect) selectAttackEffect.SetCanNotSelectNotAttack();
+
+                                yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
+                            }
+                        }
+                    }
                 }
             }
         }