Просмотр исходного кода

Implement BT25-102 and Link +X Security Effects

hooperk 3 месяцев назад
Родитель
Сommit
14fce360f8

+ 253 - 0
Assets/Scripts/CardEffect/BT25/Black/BT25_102.cs

@@ -0,0 +1,253 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+// Factorial Area
+namespace DCGO.CardEffects.BT25
+{
+    public class BT25_102 : CEntity_Effect
+    {
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+        {
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
+
+            #region Ignore Color Requirement
+
+            if (timing == EffectTiming.None)
+            {
+                IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
+                ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
+                ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
+                cardEffects.Add(ignoreColorConditionClass);
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return card.Owner.SecurityCards.Count(cardSource => !cardSource.IsFlipped) == 0;
+                }
+
+                bool CardCondition(CardSource cardSource)
+                {
+                    return cardSource == card;
+                }
+            }
+
+            #endregion
+
+            #region All Turns - Security
+
+            bool SecurityPermanentCondition(Permanent permanent)
+            {
+                return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                    && (permanent.TopCard.CardColors.Contains(CardColor.Black) || permanent.TopCard.CardColors.Contains(CardColor.Red))
+                    && permanent.TopCard.HasTSTraits;
+            }
+
+            #region Blocker
+            if (timing == EffectTiming.None)
+            {
+                bool CanUseCondition()
+                {
+                    return CardEffectCommons.IsExistInSecurity(card, false);
+                }
+
+                cardEffects.Add(CardEffectFactory.BlockerStaticEffect(permanentCondition: SecurityPermanentCondition, isInheritedEffect: false, card: card, condition: CanUseCondition));
+            }
+            #endregion
+
+            #region Link +1
+            if (timing == EffectTiming.None)
+            {
+                bool Condition()
+                {
+                    return CardEffectCommons.IsExistInSecurity(card, false)
+                        && CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasOXII);
+                }
+
+                bool HasOXII(Permanent permanent)
+                {
+                    return permanent.TopCard.EqualsCardName("Vulcanusmon");
+                }
+
+                cardEffects.Add(CardEffectFactory.ChangeLinkMaxStaticEffect(
+                    permanentCondition: SecurityPermanentCondition,
+                    changeValue: 1,
+                    isInheritedEffect: false,
+                    card: card,
+                    condition: Condition));
+            }
+            #endregion
+
+            #endregion
+
+            #region Main Effect
+
+            if (timing == EffectTiming.OptionSkill)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Replace your bottom sec with this face-up card, play a [TS] Digimon for -3", CanUseCondition, card);
+                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
+                cardEffects.Add(activateClass);
+
+                string EffectDescription()
+                {
+                    return "[Main] Add your bottom security card to the hand and place this card face up as the bottom security card. Then, you may play 1 green or black [TS] trait Digimon card from your hand with the play cost reduced by 3.";
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
+                }
+
+                bool CanSelectCardCondition(CardSource cardSource)
+                {
+                    return (cardSource.HasDigimonColor(CardColor.Black) || cardSource.HasDigimonColor(CardColor.Red))
+                        && cardSource.HasTSTraits
+                        && CardEffectCommons.CanPlayAsNewPermanent(cardSource, true, activateClass, fixedCost: cardSource.GetCostItself - 3);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(CardEffectFactory.ReplaceBottomSecurityWithFaceUpOptionEffect(card, activateClass));
+
+                    SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
+                    int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardCondition));
+
+                    selectHandEffect.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: CanSelectCardCondition,
+                        canTargetCondition_ByPreSelecetedList: null,
+                        canEndSelectCondition: null,
+                        maxCount: maxCount,
+                        canNoSelect: true,
+                        canEndNotMax: false,
+                        isShowOpponent: true,
+                        selectCardCoroutine: null,
+                        afterSelectCardCoroutine: null,
+                        mode: SelectHandEffect.Mode.PlayForCost,
+                        cardEffect: activateClass);
+
+                    selectHandEffect.SetReducedCostTuple((3, null));
+                    selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
+                    selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
+
+                    yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
+                }
+            }
+
+            #endregion
+
+            #region Security Effect
+
+            if (timing == EffectTiming.SecuritySkill)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect($"Play 1 lvl 4- Black or Red [TS] Digimon card from hand", CanUseCondition, card);
+                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
+                activateClass.SetIsSecurityEffect(true);
+                cardEffects.Add(activateClass);
+
+                string EffectDescription()
+                 => "[Security] You may play 1 level 4 or lower black or red [TS] trait Digimon card from your hand or trash without paying the cost.";
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
+                }
+
+                bool CanPlayCondition(CardSource cardSource)
+                {
+                    return (cardSource.HasDigimonColor(CardColor.Black) || cardSource.HasDigimonColor(CardColor.Red))
+                        && cardSource.HasLevel && cardSource.Level <= 4
+                        && cardSource.HasTSTraits
+                        && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayCondition);
+                    bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlayCondition);
+
+                    if (canSelectHand || canSelectTrash)
+                    {
+                        if (canSelectHand && canSelectTrash)
+                        {
+                            List<SelectionElement<int>> selectionElements1 = new List<SelectionElement<int>>()
+                        {
+                            new (message: $"From hand", value : 1, spriteIndex: 0),
+                            new (message: $"From trash", value : 2, spriteIndex: 1),
+                            new (message: $"Don't play", value: 3, spriteIndex: 2)
+                        };
+
+                            string selectPlayerMessage1 = "From which area will you play a card?";
+                            string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
+
+                            GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
+                        }
+                        else
+                        {
+                            GManager.instance.userSelectionManager.SetInt(canSelectHand ? 1 : 2);
+                        }
+                        yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
+                        bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
+                        bool fromTrash = GManager.instance.userSelectionManager.SelectedIntValue == 2;
+
+                        if (fromHand)
+                        {
+                            SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
+
+                            selectHandEffect.SetUp(
+                                selectPlayer: card.Owner,
+                                canTargetCondition: CanPlayCondition,
+                                canTargetCondition_ByPreSelecetedList: null,
+                                canEndSelectCondition: null,
+                                maxCount: 1,
+                                canNoSelect: true,
+                                canEndNotMax: false,
+                                isShowOpponent: true,
+                                selectCardCoroutine: null,
+                                afterSelectCardCoroutine: null,
+                                mode: SelectHandEffect.Mode.PlayForFree,
+                                cardEffect: activateClass);
+
+                            selectHandEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
+
+                            yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
+                        }
+                        if (fromTrash)
+                        {
+                            SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
+
+                            selectCardEffect.SetUp(
+                                canTargetCondition: CanPlayCondition,
+                                canTargetCondition_ByPreSelecetedList: null,
+                                canEndSelectCondition: null,
+                                canNoSelect: () => true,
+                                selectCardCoroutine: null,
+                                afterSelectCardCoroutine: null,
+                                message: "Select 1 digimon to play",
+                                maxCount: 1,
+                                canEndNotMax: false,
+                                isShowOpponent: true,
+                                mode: SelectCardEffect.Mode.PlayForFree,
+                                root: SelectCardEffect.Root.Trash,
+                                customRootCardList: null,
+                                canLookReverseCard: true,
+                                selectPlayer: card.Owner,
+                                cardEffect: activateClass);
+
+                            selectCardEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
+                            selectCardEffect.SetUpCustomMessage_ShowCard("Selected Digimon");
+
+                            yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
+                        }
+                    }
+                }
+            }
+
+            #endregion
+
+            return cardEffects;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/CardEffect/BT25/Black/BT25_102.cs.meta

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

+ 25 - 0
Assets/Scripts/Script/Permanent.cs

@@ -927,6 +927,31 @@ public class Permanent
                     #endregion
                 }
 
+                #region Effects of face up security
+                    foreach (CardSource cardSource in player.SecurityCards)
+                    {
+                        if (cardSource.IsFlipped)
+                            continue;
+
+                        foreach (ICardEffect cardEffect in cardSource.EffectList(EffectTiming.None))
+                        {
+                            if (cardEffect is IChangeLinkMaxEffect)
+                            {
+                                if (((IChangeLinkMaxEffect)cardEffect).PermanentCondition(this))
+                                {
+                                    if (cardEffect.CanUse(null))
+                                    {
+                                        if (!TopCard.CanNotBeAffected(cardEffect))
+                                        {
+                                            cardEffects_ChangeLinkedMax.Add(cardEffect);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    #endregion
+
                 #region player effect
                 foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
                 {