Procházet zdrojové kódy

Add EmperorDragonOfCalamity_BT20_094

Pedro Paulo de Almeida Marinho před 1 rokem
rodič
revize
adc1186809

+ 524 - 0
Assets/CardEffect/BT20/Red/EmperorDragonOfCalamity_BT20_094.cs

@@ -0,0 +1,524 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using Photon.Pun;
+
+
+namespace DCGO.CardEffects
+{
+    public class BT20_094 : CEntity_Effect
+    {
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+        {
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
+
+            #region Main
+            if (timing == EffectTiming.OptionSkill)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Play 1 [Free] trait Digimon card from your trash with the play cost reduced by 5.", CanUseCondition, card);
+                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
+                cardEffects.Add(activateClass);
+
+                string EffectDiscription()
+                {
+                    return "[Main] You may play 1 [Free] trait Digimon card from your trash with the play cost reduced by 5. Then, place this card in the battle area.";
+                }
+
+                bool isFreeTrait(CardSource cardSource)
+                {
+                    if (cardSource.IsDigimon)
+                        return cardSource.ContainsTraits("Free");
+
+                    return false;
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    if(CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, isFreeTrait))
+                    {
+                        #region reduce play cost
+                        ChangeCostClass changeCostClass = new ChangeCostClass();
+                        changeCostClass.SetUpICardEffect($"Play Cost -5", CanUseCondition1, card);
+                        changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
+                        Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
+                        card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
+
+                        ICardEffect GetCardEffect(EffectTiming _timing)
+                        {
+                            if (_timing == EffectTiming.None)
+                            {
+                                return changeCostClass;
+                            }
+
+                            return null;
+                        }
+
+                        bool CanUseCondition1(Hashtable hashtable)
+                        {
+                            return true;
+                        }
+
+                        int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
+                        {
+                            if (CardSourceCondition(cardSource))
+                            {
+                                if (RootCondition(root))
+                                {
+                                    if (PermanentsCondition(targetPermanents))
+                                    {
+                                        Cost -= 5;
+                                    }
+                                }
+                            }
+
+                            return Cost;
+                        }
+
+                        bool PermanentsCondition(List<Permanent> targetPermanents)
+                        {
+                            if (targetPermanents == null)
+                            {
+                                return true;
+                            }
+
+                            else
+                            {
+                                if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
+                                {
+                                    return true;
+                                }
+                            }
+
+                            return false;
+                        }
+
+                        bool CardSourceCondition(CardSource cardSource)
+                        {
+                            if (cardSource.HasPlayCost)
+                            {
+                                if (cardSource.IsDigimon)
+                                    return cardSource.ContainsTraits("Free");
+                            }
+
+                            return false;
+                        }
+
+                        bool RootCondition(SelectCardEffect.Root root)
+                        {
+                            return true;
+                        }
+
+                        bool isUpDown()
+                        {
+                            return true;
+                        }
+                        #endregion
+
+                        List<CardSource> selectedCards = new List<CardSource>();
+
+                        SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
+
+                        selectCardEffect.SetUp(
+                            canTargetCondition: isFreeTrait,
+                            canTargetCondition_ByPreSelecetedList: null,
+                            canEndSelectCondition: null,
+                            canNoSelect: () => true,
+                            selectCardCoroutine: null,
+                            afterSelectCardCoroutine: SelectCardCoroutine,
+                            message: "Select 1 [Free] trait Digimon card to play.",
+                            maxCount: 1,
+                            canEndNotMax: false,
+                            isShowOpponent: true,
+                            mode: SelectCardEffect.Mode.Custom,
+                            root: SelectCardEffect.Root.Trash,
+                            customRootCardList: null,
+                            canLookReverseCard: true,
+                            selectPlayer: card.Owner,
+                            cardEffect: activateClass);
+
+                        selectCardEffect.SetUpCustomMessage(
+                "Select 1 [Free] trait Digimon card to play.",
+                "The opponent is selecting 1 [Free] trait Digimon card to play.");
+                        selectCardEffect.SetUpCustomMessage_ShowCard("Play Card");
+
+                        yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
+
+                        IEnumerator SelectCardCoroutine(List<CardSource> sources)
+                        {
+                            selectedCards = sources;
+                            yield return null;
+                        }
+
+                        #region Place As Source
+                        if (selectedCards.Count > 0)
+                        {
+                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
+                                    cardSources: selectedCards,
+                                    activateClass: activateClass,
+                                    payCost: true,
+                                    isTapped: false,
+                                    root: SelectCardEffect.Root.Trash,
+                                    activateETB: true));
+                        }
+                        #endregion
+
+                        #region Remove Cost effect after use
+                        card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
+                        #endregion
+                    }
+
+                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
+                }
+            }
+            #endregion
+
+            #region Delay Effect
+            
+            if (timing == EffectTiming.WhenRemoveField)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect(
+                    "Play 1 card with the [Legend-Arms] trait from the removed Digimon's digivolution cards without paying the cost",
+                    CanUseCondition, card);
+                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
+                activateClass.SetHashString("PlayDigivolutionCard_EX6_065");
+                cardEffects.Add(activateClass);
+                
+                string EffectDescription()
+                {
+                    return
+                        "You may play 1 [Imperialdramon: Dragon Mode] from any of your [Imperialdramon: Fighter Mode]'s digivolution cards without paying the cost.";
+                        
+                }
+                
+                bool IsOwnerPermanentCondition(Permanent permanent)
+                {
+                    if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
+                    {
+                        if (permanent.DigivolutionCards.Count(isImperialDramonFighterMode) >= 1)
+                        {
+                            return true;
+                        }
+                    }
+                    
+                    return false;
+                }
+                
+                bool IsOwnerPermanentToBeDeletedCondition(Permanent permanent)
+                {
+                    if (IsOwnerPermanentCondition(permanent))
+                    {
+                        if (permanent.willBeRemoveField)
+                        {
+                            return true;
+                        }
+                    }
+                    
+                    return false;
+                }
+                
+                bool isImperialDramonFighterMode(CardSource cardSource)
+                {
+                    if (cardSource.IsDigimon)
+                    {
+                        if (cardSource.ContainsCardName("Imperialdramon: Dragon Mode"))
+                        {
+                            if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
+                                    cardEffect: activateClass))
+                            {
+                                return true;
+                            }
+                        }
+                    }
+                    
+                    return false;
+                }
+                
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
+                    {
+                        if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsOwnerPermanentCondition))
+                        {
+                            if (!CardEffectCommons.IsByEffect(hashtable,
+                                    cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
+                            {
+                                return true;
+                            }
+                        }
+                    }
+                    
+                    return false;
+                }
+                
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(
+                        CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
+                            targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
+                            activateClass: activateClass, successProcess: permanents => SuccessProcess(),
+                            failureProcess: null));
+                }
+                
+                IEnumerator SuccessProcess()
+                {
+                    if (CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentToBeDeletedCondition))
+                    {
+                        int maxCount = Math.Min(1,
+                            CardEffectCommons.MatchConditionPermanentCount(IsOwnerPermanentToBeDeletedCondition));
+                        
+                        SelectPermanentEffect selectPermanentEffect =
+                            GManager.instance.GetComponent<SelectPermanentEffect>();
+                        
+                        selectPermanentEffect.SetUp(
+                            selectPlayer: card.Owner,
+                            canTargetCondition: IsOwnerPermanentToBeDeletedCondition,
+                            canTargetCondition_ByPreSelecetedList: null,
+                            canEndSelectCondition: null,
+                            maxCount: maxCount,
+                            canNoSelect: true,
+                            canEndNotMax: false,
+                            selectPermanentCoroutine: SelectPermanentCoroutine,
+                            afterSelectPermanentCoroutine: null,
+                            mode: SelectPermanentEffect.Mode.Custom,
+                            cardEffect: activateClass);
+                        
+                        selectPermanentEffect.SetUpCustomMessage(
+                            "Select 1 Digimon which has digivolution cards.",
+                            "The opponent is selecting 1 Digimon which has digivolution cards.");
+                        
+                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+                        
+                        IEnumerator SelectPermanentCoroutine(Permanent permanent)
+                        {
+                            Permanent selectedPermanent = permanent;
+                            
+                            if (selectedPermanent != null)
+                            {
+                                if (selectedPermanent.DigivolutionCards.Count(isImperialDramonFighterMode) >= 1)
+                                {
+                                    maxCount = Math.Min(1,
+                                        selectedPermanent.DigivolutionCards.Count(isImperialDramonFighterMode));
+                                    
+                                    List<CardSource> selectedCards = new List<CardSource>();
+                                    
+                                    SelectCardEffect selectCardEffect =
+                                        GManager.instance.GetComponent<SelectCardEffect>();
+                                    
+                                    selectCardEffect.SetUp(
+                                        canTargetCondition: isImperialDramonFighterMode,
+                                        canTargetCondition_ByPreSelecetedList: null,
+                                        canEndSelectCondition: null,
+                                        canNoSelect: () => true,
+                                        selectCardCoroutine: SelectCardCoroutine,
+                                        afterSelectCardCoroutine: null,
+                                        message: "Select 1 digivolution card to play.",
+                                        maxCount: maxCount,
+                                        canEndNotMax: false,
+                                        isShowOpponent: true,
+                                        mode: SelectCardEffect.Mode.Custom,
+                                        root: SelectCardEffect.Root.Custom,
+                                        customRootCardList: selectedPermanent.DigivolutionCards,
+                                        canLookReverseCard: true,
+                                        selectPlayer: card.Owner,
+                                        cardEffect: activateClass);
+                                    
+                                    selectCardEffect.SetUpCustomMessage(
+                                        "Select 1 digivolution card to play.",
+                                        "The opponent is selecting 1 digivolution card to play.");
+                                    selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
+                                    
+                                    yield return StartCoroutine(selectCardEffect.Activate());
+                                    
+                                    IEnumerator SelectCardCoroutine(CardSource cardSource)
+                                    {
+                                        selectedCards.Add(cardSource);
+                                        
+                                        yield return null;
+                                    }
+                                    
+                                    yield return ContinuousController.instance.StartCoroutine(
+                                        CardEffectCommons.PlayPermanentCards(
+                                            cardSources: selectedCards,
+                                            activateClass: activateClass,
+                                            payCost: false,
+                                            isTapped: false,
+                                            root: SelectCardEffect.Root.DigivolutionCards,
+                                            activateETB: true));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            
+            #endregion
+
+            #region SecurityEffect
+            if (timing == EffectTiming.SecuritySkill)
+            {
+            ActivateClass activateClass = new ActivateClass();
+            activateClass.SetUpICardEffect($"Play 1 Digimon with [Free] in its traits from hand or trash", CanUseCondition, card);
+            activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
+            activateClass.SetIsSecurityEffect(true);
+            cardEffects.Add(activateClass);
+
+            string EffectDiscription()
+            {
+                return "[Security] You may play 1 level 3 Digimon card with [Free] in its traits from your hand or trash without paying its memory cost.";
+            }
+
+            bool CanSelectCardCondition(CardSource cardSource)
+            {
+                if (cardSource != null)
+                {
+                    if (cardSource.IsDigimon)
+                    {
+                        if (cardSource.Owner == card.Owner)
+                        {
+                            if (cardSource.CardTraits.Contains("Free"))
+                            {
+                                if (cardSource.Level == 3)
+                                {
+                                    if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
+                                    {
+                                        if (cardSource.HasLevel)
+                                        {
+                                            return true;
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+
+                return false;
+            }
+
+            bool CanUseCondition(Hashtable hashtable)
+            {
+                return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
+            }
+
+            IEnumerator ActivateCoroutine(Hashtable _hashtable)
+            {
+                bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
+                bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
+
+                if (canSelectHand || canSelectTrash)
+                {
+                    if (canSelectHand && canSelectTrash)
+                    {
+                        List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
+                        {
+                            new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
+                            new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
+                        };
+
+                        string selectPlayerMessage = "From which area do you play a card?";
+                        string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
+
+                        GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
+                    }
+
+                    else
+                    {
+                        GManager.instance.userSelectionManager.SetBool(canSelectHand);
+                    }
+
+                    yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
+
+                    bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
+
+                    List<CardSource> selectedCards = new List<CardSource>();
+
+                    IEnumerator SelectCardCoroutine(CardSource cardSource)
+                    {
+                        selectedCards.Add(cardSource);
+
+                        yield return null;
+                    }
+
+                    if (fromHand)
+                    {
+                        int maxCount = 1;
+
+                        SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
+
+                        selectHandEffect.SetUp(
+                            selectPlayer: card.Owner,
+                            canTargetCondition: CanSelectCardCondition,
+                            canTargetCondition_ByPreSelecetedList: null,
+                            canEndSelectCondition: null,
+                            maxCount: maxCount,
+                            canNoSelect: true,
+                            canEndNotMax: false,
+                            isShowOpponent: true,
+                            selectCardCoroutine: SelectCardCoroutine,
+                            afterSelectCardCoroutine: null,
+                            mode: SelectHandEffect.Mode.Custom,
+                            cardEffect: activateClass);
+
+                        selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
+                        selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
+
+                        yield return StartCoroutine(selectHandEffect.Activate());
+                    }
+
+                    else
+                    {
+                        int maxCount = 1;
+
+                        SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
+
+                        selectCardEffect.SetUp(
+                            canTargetCondition: CanSelectCardCondition,
+                            canTargetCondition_ByPreSelecetedList: null,
+                            canEndSelectCondition: null,
+                            canNoSelect: () => true,
+                            selectCardCoroutine: SelectCardCoroutine,
+                            afterSelectCardCoroutine: null,
+                            message: "Select 1 card to play.",
+                            maxCount: maxCount,
+                            canEndNotMax: false,
+                            isShowOpponent: true,
+                            mode: SelectCardEffect.Mode.Custom,
+                            root: SelectCardEffect.Root.Trash,
+                            customRootCardList: null,
+                            canLookReverseCard: true,
+                            selectPlayer: card.Owner,
+                            cardEffect: activateClass);
+
+                        selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
+                        selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
+
+                        yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
+                    }
+
+                    SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
+
+                    if (!fromHand)
+                    {
+                        root = SelectCardEffect.Root.Trash;
+                    }
+
+                    yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
+                }
+            }
+            }
+            #endregion
+            
+
+            return cardEffects;
+        }
+    }
+}