Ver Fonte

Merge pull request #1184 from DCGO2/hooperk-ST23-03

Implement ST23-03 and IsFaceDown/IsFaceUp
x89rt2 há 4 meses atrás
pai
commit
895e4d9228

+ 252 - 0
Assets/Scripts/CardEffect/ST23/Yellow/ST23_03.cs

@@ -0,0 +1,252 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+// Cougarmon
+namespace DCGO.CardEffects.ST23
+{
+    public class ST23_03 : CEntity_Effect
+    {
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+        {
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
+
+            #region Alt Digivolution Condition            
+            if (timing == EffectTiming.None)
+            {
+                static bool PermanentCondition(Permanent targetPermanent)
+                {
+                    return targetPermanent.TopCard.EqualsTraits("Glowing Dawn");
+                }
+
+                cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 3, permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
+            }
+            #endregion
+
+            #region Shared OP / WD
+
+            string SharedEffectName = "Add your top security to hand. <Recovery +1>";
+
+            string SharedEffectDescription(string tag) => $"[{tag}] Add your top security card to the hand. Then, <Recovery +1>. (Place the top card of your deck as your top security card.)";
+
+            CardEffectFactory.ActivateClassesForSharedEffects
+                (ref cardEffects, timing, card,
+                    SharedEffectName,
+                    SharedActivateCoroutine,
+                    SharedEffectDescription,
+                    optional: false,
+                    onPlay: true,
+                    whenDigivolving: true);
+
+            IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
+            {
+                if (card.Owner.SecurityCards.Any())
+                {
+                    CardSource topCard = card.Owner.SecurityCards[0];
+
+                    yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
+                    yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(player: card.Owner, refSkillInfos: ref ContinuousController.instance.nullSkillInfos, activateClass).ReduceSecurity());
+                }
+
+                yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
+            }
+            #endregion
+
+            #region Your Turn
+            if (timing == EffectTiming.BeforePayCost)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("By trashing the bottom face down card under your tamer, Reduce the digivolution cost by 2", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
+                cardEffects.Add(activateClass);
+
+
+                string EffectDescription()
+                {
+                    return "[Your Turn] When this Digimon would digivolve into a [Glowing Dawn] trait Digimon card, by trashing the bottom face-down card from under any of your Tamers, reduce the cost by 2.";
+                }
+
+                bool PermanentCondition(Permanent permanent)
+                {
+
+                    if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
+                    {
+                        if (permanent == card.PermanentOfThisCard())
+                        {
+                            return true;
+                        }
+                    }
+
+                    return false;
+                }
+
+                bool HasProperTrait(CardSource source)
+                {
+                    return  source.IsDigimon &&
+                            source.EqualsTraits("Glowing Dawn");
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
+                    {
+                        if (CardEffectCommons.IsOwnerTurn(card))
+                        {
+                            if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, HasProperTrait))
+                            {
+                                if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, ValidTamerCondition))
+                                {
+                                    return true;
+                                }
+                            }
+                        }  
+                    }
+
+                    return false;
+                }
+
+                bool FaceDownCards(CardSource cardSource) => cardSource.IsFaceDown;
+
+                bool ValidTamerCondition(Permanent permanent)
+                {
+                    return permanent.IsTamer
+                        && permanent.DigivolutionCards.Any(FaceDownCards);
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                {
+                    bool trash = false;
+
+                    SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
+
+                    selectPermanentEffect1.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: ValidTamerCondition,
+                        canTargetCondition_ByPreSelecetedList: null,
+                        canEndSelectCondition: null,
+                        maxCount: 1,
+                        canNoSelect: true,
+                        canEndNotMax: false,
+                        selectPermanentCoroutine: null,
+                        afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
+                        mode: SelectPermanentEffect.Mode.Custom,
+                        cardEffect: activateClass);
+
+                    selectPermanentEffect1.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
+
+                    yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
+
+                    IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
+                    {
+                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, FaceDownCards));
+
+                        trash = true;
+                    }
+
+                    if (trash)
+                    {
+                        Hashtable hashtable = new Hashtable();
+                        hashtable.Add("CardEffect", activateClass);
+
+                        ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
+
+                        ChangeCostClass changeCostClass = new ChangeCostClass();
+                        changeCostClass.SetUpICardEffect("Digivolution Cost -2", CanUseCondition1, card);
+                        changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
+                        card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
+
+                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
+
+                        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 -= 2;
+                                    }
+                                }
+                            }
+
+                            return Cost;
+                        }
+
+                        bool PermanentsCondition(List<Permanent> targetPermanents)
+                        {
+                            if (targetPermanents != null)
+                            {
+                                if (targetPermanents.Count(PermanentCondition) >= 1)
+                                {
+                                    return true;
+                                }
+                            }
+
+                            return false;
+                        }
+
+                        bool PermanentCondition(Permanent targetPermanent)
+                        {
+                            if (targetPermanent.TopCard != null)
+                            {
+                                if (targetPermanent.TopCard.Owner == card.Owner)
+                                {
+                                    if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
+                                    {
+                                        return true;
+                                    }
+                                }
+                            }
+
+                            return false;
+                        }
+
+                        bool CardSourceCondition(CardSource cardSource)
+                        {
+                            if (cardSource != null)
+                            {
+                                if (cardSource.Owner == card.Owner)
+                                {
+                                    return cardSource.EqualsTraits("Glowing Dawn");
+                                }
+                            }
+
+                            return false;
+                        }
+
+                        bool RootCondition(SelectCardEffect.Root root)
+                        {
+                            return true;
+                        }
+
+                        bool isUpDown()
+                        {
+                            return true;
+                        }
+
+                    }
+                }
+            }
+            #endregion
+
+            #region Barrier - ESS
+            if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
+                cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: true, card: card, condition: null));
+            #endregion
+
+            return cardEffects;
+        }
+    }
+}

+ 16 - 0
Assets/Scripts/Script/CardSource.cs

@@ -55,6 +55,22 @@ public class CardSource : MonoBehaviour
 
     public bool IsFlipped { get; private set; }
 
+    public bool IsFaceUp 
+    { 
+        get 
+        { 
+            return !IsFlipped; 
+        }
+    }
+
+    public bool IsFaceDown
+    {
+        get
+        {
+            return IsFlipped;
+        }
+    }
+
     #region set face
 
     public void SetFace(string str = "")