Преглед на файлове

Update BT25_082.cs

Next attempt at fixing not playing tamer.
x89rt2 преди 3 месеца
родител
ревизия
472a4e9dc5
променени са 1 файла, в които са добавени 35 реда и са изтрити 67 реда
  1. 35 67
      Assets/Scripts/CardEffect/BT25/Purple/BT25_082.cs

+ 35 - 67
Assets/Scripts/CardEffect/BT25/Purple/BT25_082.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Linq;
 
 // BlackGatomon
 namespace DCGO.CardEffects.BT25
@@ -12,7 +13,6 @@ namespace DCGO.CardEffects.BT25
             List<ICardEffect> cardEffects = new List<ICardEffect>();
 
             #region Digivolution Condition
-
             if (timing == EffectTiming.None)
             {
                 bool Condition(Permanent permanent)
@@ -23,20 +23,27 @@ namespace DCGO.CardEffects.BT25
 
                 cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 3, permanentCondition: Condition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
             }
-
             #endregion
 
             #region Shared OP/WD
-
-            string SharedEffectName() => "Play a tamer with [Three Musketeers] in text from hand for free";
+            string SharedEffectName = "Play a tamer with [Three Musketeers] in text from hand for free";
+
+            CardEffectFactory.ActivateClassesForSharedEffects
+                (ref cardEffects, timing, card,
+                    SharedEffectName,
+                    SharedActivateCoroutine,
+                    SharedEffectDescription,
+                    additionalActivateCondition: AdditionalActivateCondition,
+                    optional: false,
+                    onPlay: true,
+                    whenDigivolving: true);
 
             string SharedEffectDescription(string tag) => $"[{tag}] If you have 1 or fewer Tamers, you may play 1 Tamer card with [Three Musketeers] in its text from your hand without paying the cost.";
 
-            bool SharedCanActivateCondition(Hashtable hashtable)
+            bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass)
             {
-                return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
-                    && CardEffectCommons.HasMatchConditionOwnersHand(card, TraitedTamer)
-                    && CardEffectCommons.MatchConditionOwnersPermanentCount(card, permanent => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)) <= 1;
+                return CardEffectCommons.HasMatchConditionOwnersHand(card, TraitedTamer)
+                    && card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1;
             }
 
             bool TraitedTamer(CardSource cardSource)
@@ -47,69 +54,33 @@ namespace DCGO.CardEffects.BT25
 
             IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
             {
-                SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
-                int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, TraitedTamer));
-
-                selectHandEffect.SetUp(
-                    selectPlayer: card.Owner,
-                    canTargetCondition: TraitedTamer,
-                    canTargetCondition_ByPreSelecetedList: null,
-                    canEndSelectCondition: null,
-                    maxCount: maxCount,
-                    canNoSelect: true,
-                    canEndNotMax: false,
-                    isShowOpponent: true,
-                    selectCardCoroutine: null,
-                    afterSelectCardCoroutine: null,
-                    mode: SelectHandEffect.Mode.PlayForFree,
-                    cardEffect: activateClass);
-
-                selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
-                selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
-
-                return null;
-            }
-
-            #endregion
-
-            #region On Play
-
-            if (timing == EffectTiming.OnEnterFieldAnyone)
-            {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
-                activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
-                cardEffects.Add(activateClass);
-
-                bool CanUseCondition(Hashtable hashtable)
+                if (CardEffectCommons.HasMatchConditionOwnersHand(card, TraitedTamer))
                 {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
-                        && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
+                    SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
+
+                    selectHandEffect.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: TraitedTamer,
+                        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 card to play.", "The opponent is selecting 1 card to play.");
+                    selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
                 }
-            }
 
-            #endregion
-
-            #region When Digivolving
-
-            if (timing == EffectTiming.OnEnterFieldAnyone)
-            {
-                ActivateClass activateClass = new ActivateClass();
-                activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
-                activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
-                cardEffects.Add(activateClass);
-
-                bool CanUseCondition(Hashtable hashtable)
-                {
-                    return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
-                        && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
-                }
+                return null;
             }
-
             #endregion
 
             #region All Turns
-
             if (timing == EffectTiming.None)
             {
                 bool Condition()
@@ -139,11 +110,9 @@ namespace DCGO.CardEffects.BT25
 
                 cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: true, card: card, condition: Condition, effectName: effectName, cardCondition: CardCondition));
             }
-
             #endregion
 
             #region Inherited When Attacking
-
             if (timing == EffectTiming.OnAllyAttack)
             {
                 ActivateClass activateClass = new ActivateClass();
@@ -275,7 +244,6 @@ namespace DCGO.CardEffects.BT25
                     }
                 }
             }
-
             #endregion
 
             return cardEffects;