Jelajahi Sumber

Implemented Suggested Decode Rework

Lewisaaronwelch 1 tahun lalu
induk
melakukan
97b7adc987

+ 7 - 2
Assets/CardEffect/BT19/Blue/BT19_024.cs

@@ -13,8 +13,13 @@ namespace DCGO.CardEffects.BT19
 
             if (timing == EffectTiming.WhenRemoveField)
             {
-                cardEffects.Add(CardEffectFactory.DecodeSelfEffect(color: CardColor.Blue, level: 4, isInheritedEffect: false, card: card,
-                    condition: null));
+                bool SourceCondition(CardSource source)
+                {
+                    return source.CardColors.Contains(CardColor.Blue) && source.HasLevel && source.IsLevel4;
+                }
+
+                string[] decodeStrings = { "(Blue Lv.4)", "Blue Level 4 Digimon" };
+                cardEffects.Add(CardEffectFactory.DecodeSelfEffect(card: card, isInheritedEffect: false, decodeStrings: decodeStrings, sourceCondition: SourceCondition, condition: null));
             }
 
             #endregion

+ 8 - 3
Assets/CardEffect/BT19/Blue/BT19_027.cs

@@ -13,8 +13,13 @@ namespace DCGO.CardEffects.BT19
 
             if (timing == EffectTiming.WhenRemoveField)
             {
-                cardEffects.Add(CardEffectFactory.DecodeSelfEffect(color: CardColor.Blue, level: 5, isInheritedEffect: false, card: card,
-                    condition: null));
+                bool SourceCondition(CardSource source)
+                {
+                    return source.CardColors.Contains(CardColor.Blue) && source.HasLevel && source.IsLevel5;
+                }
+
+                string[] decodeStrings = { "(Blue Lv.5)", "Blue Level 5 Digimon" };
+                cardEffects.Add(CardEffectFactory.DecodeSelfEffect(card: card, isInheritedEffect: false, decodeStrings: decodeStrings, sourceCondition: SourceCondition, condition: null));
             }
 
             #endregion
@@ -175,7 +180,7 @@ namespace DCGO.CardEffects.BT19
                         yield return null;
                     }
 
-                    if(selectedPermanent != null)
+                    if (selectedPermanent != null)
                     {
                         bool selectedHasLevel = selectedPermanent.TopCard.HasLevel;
                         int selectedLevel = selectedPermanent.TopCard.Level;

+ 10 - 15
Assets/Scripts/CardEffectCommons/KeyWordEffects/Decode.cs

@@ -1,37 +1,37 @@
+using System;
 using System.Collections;
 using System.Collections.Generic;
 
 public partial class CardEffectCommons
 {
-    static bool CanSelectSourceCardCondition(CardSource source, CardColor color, int level, ICardEffect activateClass)
+    static bool CanSelectSourceCardCondition(CardSource source, Func<CardSource, bool> sourceCondition, ICardEffect activateClass)
     {
         return source.IsDigimon &&
-               source.CardColors.Contains(color) &&
-               source.HasLevel && source.Level == level &&
+               sourceCondition(source) &&
                CanPlayAsNewPermanent(cardSource: source, payCost: false, cardEffect: activateClass);
     }
 
     #region Can activate [Decode]
 
-    public static bool CanActivateDecode(CardColor color, int level, CardSource cardSource, ICardEffect activateClass)
+    public static bool CanActivateDecode(CardSource cardSource, Func<CardSource, bool> sourceCondition, ICardEffect activateClass)
     {
         return IsExistOnBattleAreaDigimon(cardSource) &&
                cardSource.PermanentOfThisCard().DigivolutionCards.Some(
-                   source => CanSelectSourceCardCondition(source, color, level, activateClass));
+                   source => CanSelectSourceCardCondition(source, sourceCondition, activateClass));
     }
 
     #endregion
 
     #region Effect process of [Decode]
 
-    public static IEnumerator DecodeProcess(CardColor color, int level, CardSource cardSource, ICardEffect activateClass)
+    public static IEnumerator DecodeProcess(CardSource cardSource, Func<CardSource, bool> sourceCondition, ICardEffect activateClass)
     {
         List<CardSource> selectedCards = new List<CardSource>();
 
         SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
 
         selectCardEffect.SetUp(
-            canTargetCondition: source => CanSelectSourceCardCondition(source, color, level, activateClass),
+            canTargetCondition: source => CanSelectSourceCardCondition(source, sourceCondition, activateClass),
             canTargetCondition_ByPreSelecetedList: null,
             canEndSelectCondition: null,
             canNoSelect: () => true,
@@ -76,7 +76,7 @@ public partial class CardEffectCommons
 
     #region Target 1 Digimon gains [Decode]
 
-    public static IEnumerator GainDecode(CardColor color, int level, Permanent targetPermanent, EffectDuration effectDuration,
+    public static IEnumerator GainDecode(Permanent targetPermanent, string[] decodeStrings, Func<CardSource, bool> sourceCondition, EffectDuration effectDuration,
         ICardEffect activateClass)
     {
         if (targetPermanent == null) yield break;
@@ -93,13 +93,8 @@ public partial class CardEffectCommons
         }
 
         ActivateClass decode = CardEffectFactory.DecodeEffect(
-            color: color,
-            level: level,
-            targetPermanent: targetPermanent,
-            isInheritedEffect: false,
-            condition: CanUseCondition,
-            rootCardEffect: activateClass,
-            targetPermanent.TopCard);
+            targetPermanent: targetPermanent, isInheritedEffect: false, decodeStrings,
+            condition: CanUseCondition, sourceCondition: sourceCondition, rootCardEffect: activateClass, card);
 
         AddEffectToPermanent(
             targetPermanent: targetPermanent,

+ 10 - 8
Assets/Scripts/CardEffectFactory/KeyWordEffects/Decode.cs

@@ -5,7 +5,7 @@ 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,
+    public static ActivateClass DecodeSelfEffect(CardSource card, bool isInheritedEffect, string[] decodeStrings, Func<CardSource, bool> sourceCondition, Func<bool> condition,
         ICardEffect rootCardEffect = null)
     {
         Permanent targetPermanent = card.PermanentOfThisCard();
@@ -15,25 +15,27 @@ public partial class CardEffectFactory
             return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
                    (condition == null || condition());
         }
+        if (sourceCondition == null) sourceCondition = _ => true;
 
-        return DecodeEffect(color: color, level: level, targetPermanent: targetPermanent, isInheritedEffect: isInheritedEffect,
-            condition: CanUseCondition, rootCardEffect: rootCardEffect, card);
+        return DecodeEffect(targetPermanent: targetPermanent, isInheritedEffect: isInheritedEffect, decodeStrings,
+            condition: CanUseCondition, sourceCondition: sourceCondition, 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)
+    public static ActivateClass DecodeEffect(Permanent targetPermanent, bool isInheritedEffect, string[] decodeStrings,
+        Func<bool> condition, Func<CardSource, bool> sourceCondition, ICardEffect rootCardEffect, CardSource card)
     {
         if (targetPermanent == null) return null;
         if (targetPermanent.TopCard == null) return null;
         if (card == null) return null;
+        if (sourceCondition == null) sourceCondition = _ => true;
 
         ActivateClass activateClass = new ActivateClass();
         activateClass.SetUpICardEffect("Decode", CanUseCondition, card);
-        activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.DecodeEffectDiscription(color, level));
+        activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.DecodeEffectDiscription(decodeStrings));
         activateClass.SetIsInheritedEffect(isInheritedEffect);
 
         if (rootCardEffect != null)
@@ -52,13 +54,13 @@ public partial class CardEffectFactory
 
         bool CanActivateCondition(Hashtable hashtable)
         {
-            return CardEffectCommons.CanActivateDecode(color, level, targetPermanent.TopCard, activateClass) &&
+            return CardEffectCommons.CanActivateDecode(targetPermanent.TopCard, sourceCondition, activateClass) &&
                    (condition == null || condition());
         }
 
         IEnumerator ActivateCoroutine(Hashtable hashtable)
         {
-            return CardEffectCommons.DecodeProcess(color, level, targetPermanent.TopCard, activateClass);
+            return CardEffectCommons.DecodeProcess(targetPermanent.TopCard, sourceCondition, activateClass);
         }
 
         return activateClass;

+ 25 - 18
Assets/Scripts/DataBase.cs

@@ -44,7 +44,6 @@ public class DataBase : MonoBehaviour
 
     public static Dictionary<CardColor, Color> CardColor_ColorLightDictionary = new Dictionary<CardColor, Color>()
     {
-
         { CardColor.Green,new Color32(55,255,49,255)},
         { CardColor.Red,new Color32(253,63,49,255)},
         { CardColor.Blue, new Color32(49,118,253,255) },
@@ -253,7 +252,6 @@ public class DataBase : MonoBehaviour
                     break;
             }
         }
-
         else
         {
             switch (SetID)
@@ -534,22 +532,22 @@ 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)
+    public static string DecodeEffectDiscription(string[] decodeStrings)
     {
-        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",
-            _ => ""
-        };
+        //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.)";
+            $"<Decode {decodeStrings[0]}> (When this Digimon would leave the battle area other than in battle, you may play 1 {decodeStrings[1]} Digimon card from its digivolution cards without paying the cost.)";
     }
 
     public static string ExecuteEffectDiscription()
@@ -561,6 +559,7 @@ public class DataBase : MonoBehaviour
     {
         return "<Progress> (While attacking, your opponent's effects don't affect this Digimon.)";
     }
+
     public static string LinkEffectDiscription()
     {
         return "[Link] (Plug this card from the hand or battle area sideways into the specified Digimon in the battle area.)";
@@ -591,8 +590,10 @@ public class DataBase : MonoBehaviour
     public static string FirstPlayerIndexIdKey = "FirstPlayerIndexId";
 
     #region use for sort
+
     public static CardKind[] cardKinds = new[] { CardKind.Digimon, CardKind.Tamer, CardKind.Option };
     public static CardColor[] cardColors = new[] { CardColor.Red, CardColor.Blue, CardColor.Yellow, CardColor.Green, CardColor.Black, CardColor.Purple, CardColor.White, CardColor.None };
+
     public static string[] SetIDs = new string[]
     {
         "BT28",
@@ -708,9 +709,11 @@ public class DataBase : MonoBehaviour
 
         "P",
     };
+
     #endregion
 
     #region ENG ban list
+
     public static CardRestriction ENGBanList = new CardRestriction(new List<CardLimitCount>()
                 {
                     new CardLimitCount("BT11-064", 1),
@@ -765,9 +768,11 @@ public class DataBase : MonoBehaviour
                         "EX7-064",
                     })
                 });
+
     #endregion
 
     #region JPN ban list
+
     public static CardRestriction JPNBanList = new CardRestriction(new List<CardLimitCount>()
                 {
                     new CardLimitCount("BT11-064", 1),
@@ -810,13 +815,13 @@ public class DataBase : MonoBehaviour
                         "ST16-14",
                     })
                 });
+
     #endregion
 }
 
 [System.Serializable]
 public class ColorSpriteDic : TableBase<CardColor, Sprite, SamplePair>
 {
-
 }
 
 [System.Serializable]
@@ -824,8 +829,8 @@ public class TableBase<TKey, TValue, Type> where Type : KeyAndValue<TKey, TValue
 {
     [SerializeField]
     private List<Type> list;
-    private Dictionary<TKey, TValue> table;
 
+    private Dictionary<TKey, TValue> table;
 
     public Dictionary<TKey, TValue> GetTable()
     {
@@ -869,6 +874,7 @@ public class KeyAndValue<TKey, TValue>
         Key = key;
         Value = value;
     }
+
     public KeyAndValue(KeyValuePair<TKey, TValue> pair)
     {
         Key = pair.Key;
@@ -881,7 +887,6 @@ public class SamplePair : KeyAndValue<CardColor, Sprite>
 {
     public SamplePair(CardColor key, Sprite value) : base(key, value)
     {
-
     }
 }
 
@@ -963,6 +968,7 @@ public class ParameterComparer : IEqualityComparer<object[]>
     }
 
     #region select k elements from n different elements
+
     public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k)
     {
         if (items.Count() < k)
@@ -988,5 +994,6 @@ public class ParameterComparer : IEqualityComparer<object[]>
             }
         }
     }
+
     #endregion
 }