Sfoglia il codice sorgente

Add decode keyword

Andrej Erdelsky 1 anno fa
parent
commit
834a10a48f

+ 2 - 79
Assets/CardEffect/BT19/Blue/MarineBullmon_BT19_024.cs

@@ -13,85 +13,8 @@ namespace DCGO.CardEffects.BT19
 
             if (timing == EffectTiming.WhenRemoveField)
             {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("<Decode Blue (Lv.4)>", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
-                cardEffects.Add(activateClass);
-
-                string EffectDescription()
-                {
-                    return
-                        "<Decode Blue (Lv.4)> (When this Digimon would leave the battle area other than in battle, you may play 1 Blue Level 4 Digimon card from its digivolution cards without paying the cost)";
-                }
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
-                           CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
-                           !CardEffectCommons.IsByBattle(hashtable);
-                }
-
-                bool CanSelectSourceCardCondition(CardSource cardSource)
-                {
-                    return cardSource.IsDigimon &&
-                           cardSource.CardColors.Contains(CardColor.Blue) &&
-                           cardSource.IsLevel4 &&
-                           CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
-                }
-
-                bool CanActivateCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
-                           card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition);
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    List<CardSource> selectedCards = new List<CardSource>();
-
-                    SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
-
-                    selectCardEffect.SetUp(
-                        canTargetCondition: CanSelectSourceCardCondition,
-                        canTargetCondition_ByPreSelecetedList: null,
-                        canEndSelectCondition: null,
-                        canNoSelect: () => true,
-                        selectCardCoroutine: SelectCardCoroutine,
-                        afterSelectCardCoroutine: null,
-                        message: "Select 1 digivolution card to play.",
-                        maxCount: 1,
-                        canEndNotMax: false,
-                        isShowOpponent: true,
-                        mode: SelectCardEffect.Mode.Custom,
-                        root: SelectCardEffect.Root.Custom,
-                        customRootCardList: card.PermanentOfThisCard().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));
-                }
+                cardEffects.Add(CardEffectFactory.DecodeSelfEffect(color: CardColor.Blue, level: 4, isInheritedEffect: false, card: card,
+                    condition: null));
             }
 
             #endregion

+ 2 - 79
Assets/CardEffect/BT19/Blue/Ryugumon_BT19_027.cs

@@ -13,85 +13,8 @@ namespace DCGO.CardEffects.BT19
 
             if (timing == EffectTiming.WhenRemoveField)
             {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect("<Decode Blue (Lv.5)>", CanUseCondition, card);
-                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
-                cardEffects.Add(activateClass);
-
-                string EffectDescription()
-                {
-                    return
-                        "<Decode Blue (Lv.5)> (When this Digimon would leave the battle area other than in battle, you may play 1 Blue Level 5 Digimon card from its digivolution cards without paying the cost)";
-                }
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
-                           CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
-                           !CardEffectCommons.IsByBattle(hashtable);
-                }
-
-                bool CanSelectSourceCardCondition(CardSource cardSource)
-                {
-                    return cardSource.IsDigimon &&
-                           cardSource.CardColors.Contains(CardColor.Blue) &&
-                           cardSource.IsLevel5 &&
-                           CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
-                }
-
-                bool CanActivateCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
-                           card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition);
-                }
-
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
-                {
-                    List<CardSource> selectedCards = new List<CardSource>();
-
-                    SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
-
-                    selectCardEffect.SetUp(
-                        canTargetCondition: CanSelectSourceCardCondition,
-                        canTargetCondition_ByPreSelecetedList: null,
-                        canEndSelectCondition: null,
-                        canNoSelect: () => true,
-                        selectCardCoroutine: SelectCardCoroutine,
-                        afterSelectCardCoroutine: null,
-                        message: "Select 1 digivolution card to play.",
-                        maxCount: 1,
-                        canEndNotMax: false,
-                        isShowOpponent: true,
-                        mode: SelectCardEffect.Mode.Custom,
-                        root: SelectCardEffect.Root.Custom,
-                        customRootCardList: card.PermanentOfThisCard().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));
-                }
+                cardEffects.Add(CardEffectFactory.DecodeSelfEffect(color: CardColor.Blue, level: 5, isInheritedEffect: false, card: card,
+                    condition: null));
             }
 
             #endregion

+ 119 - 0
Assets/Scripts/CardEffectCommons/KeyWordEffects/Decode.cs

@@ -0,0 +1,119 @@
+using System.Collections;
+using System.Collections.Generic;
+
+public partial class CardEffectCommons
+{
+    static bool CanSelectSourceCardCondition(CardSource source, CardColor color, int level, ICardEffect activateClass)
+    {
+        return source.IsDigimon &&
+               source.CardColors.Contains(color) &&
+               source.HasLevel && source.Level == level &&
+               CanPlayAsNewPermanent(cardSource: source, payCost: false, cardEffect: activateClass);
+    }
+
+    #region Can activate [Decode]
+
+    public static bool CanActivateDecode(CardColor color, int level, CardSource cardSource, ICardEffect activateClass)
+    {
+        return IsExistOnBattleAreaDigimon(cardSource) &&
+               cardSource.PermanentOfThisCard().DigivolutionCards.Some(
+                   source => CanSelectSourceCardCondition(source, color, level, activateClass));
+    }
+
+    #endregion
+
+    #region Effect process of [Decode]
+
+    public static IEnumerator DecodeProcess(CardColor color, int level, CardSource cardSource, ICardEffect activateClass)
+    {
+        List<CardSource> selectedCards = new List<CardSource>();
+
+        SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
+
+        selectCardEffect.SetUp(
+            canTargetCondition: source => CanSelectSourceCardCondition(source, color, level, activateClass),
+            canTargetCondition_ByPreSelecetedList: null,
+            canEndSelectCondition: null,
+            canNoSelect: () => true,
+            selectCardCoroutine: SelectCardCoroutine,
+            afterSelectCardCoroutine: null,
+            message: "Select 1 digivolution card to play.",
+            maxCount: 1,
+            canEndNotMax: false,
+            isShowOpponent: true,
+            mode: SelectCardEffect.Mode.Custom,
+            root: SelectCardEffect.Root.Custom,
+            customRootCardList: cardSource.PermanentOfThisCard().DigivolutionCards,
+            canLookReverseCard: true,
+            selectPlayer: cardSource.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 ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
+
+        IEnumerator SelectCardCoroutine(CardSource source)
+        {
+            selectedCards.Add(source);
+
+            yield return null;
+        }
+
+        yield return ContinuousController.instance.StartCoroutine(
+            PlayPermanentCards(
+                cardSources: selectedCards,
+                activateClass: activateClass,
+                payCost: false,
+                isTapped: false,
+                root: SelectCardEffect.Root.DigivolutionCards,
+                activateETB: true));
+    }
+
+    #endregion
+
+    #region Target 1 Digimon gains [Decode]
+
+    public static IEnumerator GainDecode(CardColor color, int level, Permanent targetPermanent, EffectDuration effectDuration,
+        ICardEffect activateClass)
+    {
+        if (targetPermanent == null) yield break;
+        if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+
+        bool CanUseCondition()
+        {
+            return IsPermanentExistsOnBattleArea(targetPermanent) &&
+                   !targetPermanent.TopCard.CanNotBeAffected(activateClass);
+        }
+
+        ActivateClass decode = CardEffectFactory.DecodeEffect(
+            color: color,
+            level: level,
+            targetPermanent: targetPermanent,
+            isInheritedEffect: false,
+            condition: CanUseCondition,
+            rootCardEffect: activateClass,
+            targetPermanent.TopCard);
+
+        AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: decode,
+            timing: EffectTiming.OnAllyAttack);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
+                .CreateBuffEffect(targetPermanent));
+        }
+    }
+
+    #endregion
+}

+ 3 - 0
Assets/Scripts/CardEffectCommons/KeyWordEffects/Decode.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: e3820b12fa9547d5847adc8c4405a406
+timeCreated: 1729516213

+ 68 - 0
Assets/Scripts/CardEffectFactory/KeyWordEffects/Decode.cs

@@ -0,0 +1,68 @@
+using System.Collections;
+using System;
+
+public partial class CardEffectFactory
+{
+    #region Trigger effect of [Decode] on oneself
+
+    public static ActivateClass DecodeSelfEffect(CardColor color, int level, bool isInheritedEffect, CardSource card, Func<bool> condition,
+        ICardEffect rootCardEffect = null)
+    {
+        Permanent targetPermanent = card.PermanentOfThisCard();
+
+        bool CanUseCondition()
+        {
+            return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
+                   (condition == null || condition());
+        }
+
+        return DecodeEffect(color: color, level: level, targetPermanent: targetPermanent, isInheritedEffect: isInheritedEffect,
+            condition: CanUseCondition, rootCardEffect: rootCardEffect, card);
+    }
+
+    #endregion
+
+    #region Trigger effect of [Decode]
+
+    public static ActivateClass DecodeEffect(CardColor color, int level, Permanent targetPermanent, bool isInheritedEffect,
+        Func<bool> condition, ICardEffect rootCardEffect, CardSource card)
+    {
+        if (targetPermanent == null) return null;
+        if (targetPermanent.TopCard == null) return null;
+        if (card == null) return null;
+
+        ActivateClass activateClass = new ActivateClass();
+        activateClass.SetUpICardEffect("Decode", CanUseCondition, card);
+        activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.DecodeEffectDiscription(color, level));
+        activateClass.SetIsInheritedEffect(isInheritedEffect);
+
+        if (rootCardEffect != null)
+        {
+            activateClass.SetIsInheritedEffect(false);
+            activateClass.SetEffectSourcePermanent(targetPermanent);
+            activateClass.SetRootCardEffect(rootCardEffect);
+        }
+
+        bool CanUseCondition(Hashtable hashtable)
+        {
+            return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
+                   CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
+                   !CardEffectCommons.IsByBattle(hashtable);
+        }
+
+        bool CanActivateCondition(Hashtable hashtable)
+        {
+            return CardEffectCommons.CanActivateDecode(color, level, targetPermanent.TopCard, activateClass) &&
+                   (condition == null || condition());
+        }
+
+        IEnumerator ActivateCoroutine(Hashtable hashtable)
+        {
+            return CardEffectCommons.DecodeProcess(color, level, targetPermanent.TopCard, activateClass);
+        }
+
+        return activateClass;
+    }
+
+    #endregion
+}

+ 3 - 0
Assets/Scripts/CardEffectFactory/KeyWordEffects/Decode.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 3967d052625445c8a88a88c7918e0cc4
+timeCreated: 1729515388

+ 18 - 0
Assets/Scripts/DataBase.cs

@@ -533,6 +533,24 @@ public class DataBase : MonoBehaviour
     {
         return $"<Overclock [{trait}]> (At the end of your turn, by deleting 1 of your Tokens or other [{trait}] trait Digimon, this Digimon attacks a player without suspending.)";
     }
+    
+    public static string DecodeEffectDiscription(CardColor color, int level)
+    {
+        string colorString = color switch
+        {
+            CardColor.Red => "Red",
+            CardColor.Blue => "Blue",
+            CardColor.Yellow => "Yellow",
+            CardColor.Green => "Green",
+            CardColor.Black => "Black",
+            CardColor.Purple => "Purple",
+            CardColor.White => "White",
+            _ => ""
+        };
+        
+        return
+            $"<Decode {colorString} ({level})> (When this Digimon would leave the battle area other than in battle, you may play 1 {colorString} Level {level} Digimon card from its digivolution cards without paying the cost.)";
+    }
 
     public static string ReplaceToASCII(string text)
     {