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

added would digivolution card discarded, added bt10 tactimon

mbunch_kascope 2 лет назад
Родитель
Сommit
5669055326

+ 168 - 79
Assets/CardEffect/BT10/Purple/Tactimon_BT10_084.cs

@@ -2,129 +2,218 @@ using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System.Linq;
-using Photon;
 using System;
-using Photon.Pun;
 
-public class Tactimon_BT10_084 : CEntity_Effect
+namespace DCGO.CardEffects.BT10
 {
-    public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+    public class Tactimon_BT10_084 : CEntity_Effect
     {
-        List<ICardEffect> cardEffects = new List<ICardEffect>();
-
-        if (timing == EffectTiming.OnEnterFieldAnyone)
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
         {
-            ActivateClass activateClass = new ActivateClass();
-            activateClass.SetUpICardEffect("Play Digimons from trash", CanUseCondition, card);
-            activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
-            cardEffects.Add(activateClass);
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
 
-            string EffectDiscription()
+            #region On Play
+            if (timing == EffectTiming.OnEnterFieldAnyone)
             {
-                return "[On Play] Play 1 purple or yellow Digimon card with 6000 DP or less from your trash without paying its memory cost. If you have 1 or fewer security cards, you may play 1 level 6 or lower Digimon card with [Angel] or [Fallen Angel] in its traits from your trash without paying its memory cost instead.";
-            }
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Play Digimons from trash", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
+                cardEffects.Add(activateClass);
 
-            bool CanSelectCardCondition(CardSource cardSource)
-            {
-                if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
+                string EffectDiscription()
                 {
-                    if (cardSource.IsDigimon)
+                    return "[On Play] Play 1 purple or yellow Digimon card with 6000 DP or less from your trash without paying its memory cost. If you have 1 or fewer security cards, you may play 1 level 6 or lower Digimon card with [Angel] or [Fallen Angel] in its traits from your trash without paying its memory cost instead.";
+                }
+
+                bool CanSelectCardCondition(CardSource cardSource)
+                {
+                    if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
                     {
-                        if (cardSource.Level <= 4 && cardSource.HasLevel)
+                        if (cardSource.IsDigimon)
                         {
-                            if (cardSource.CardTraits.Contains("BagraArmy"))
+                            if (cardSource.Level <= 4 && cardSource.HasLevel)
                             {
-                                return true;
+                                if (cardSource.CardTraits.Contains("BagraArmy"))
+                                {
+                                    return true;
+                                }
+
+                                if (cardSource.CardTraits.Contains("Bagra Army"))
+                                {
+                                    return true;
+                                }
                             }
+                        }
+                    }
 
-                            if (cardSource.CardTraits.Contains("Bagra Army"))
-                            {
-                                return true;
-                            }
+                    return false;
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    if (CardEffectCommons.IsExistOnBattleArea(card))
+                    {
+                        if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
+                        {
+                            return true;
                         }
                     }
+
+                    return false;
                 }
 
-                return false;
-            }
+                IEnumerator ActivateCoroutine(Hashtable _hashtable)
+                {
+                    if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
+                    {
+                        List<CardSource> selectedCards = new List<CardSource>();
+
+                        int maxCount = Math.Min(2, card.Owner.TrashCards.Count(CanSelectCardCondition));
+
+                        SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
+
+                        selectCardEffect.SetUp(
+                                    canTargetCondition: CanSelectCardCondition,
+                                    canTargetCondition_ByPreSelecetedList: null,
+                                    canEndSelectCondition: null,
+                                    canNoSelect: () => true,
+                                    selectCardCoroutine: SelectCardCoroutine,
+                                    afterSelectCardCoroutine: null,
+                                    message: "Select cards to play.",
+                                    maxCount: maxCount,
+                                    canEndNotMax: false,
+                                    isShowOpponent: true,
+                                    mode: SelectCardEffect.Mode.Custom,
+                                    root: SelectCardEffect.Root.Trash,
+                                    customRootCardList: null,
+                                    canLookReverseCard: true,
+                                    selectPlayer: card.Owner,
+                                    cardEffect: activateClass);
+
+                        selectCardEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards to play.");
+                        selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
+
+                        yield return StartCoroutine(selectCardEffect.Activate());
+
+                        IEnumerator SelectCardCoroutine(CardSource cardSource)
+                        {
+                            selectedCards.Add(cardSource);
 
-            bool CanUseCondition(Hashtable hashtable)
-            {
-                return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
+                            yield return null;
+                        }
+
+                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
+                                    cardSources: selectedCards,
+                                    activateClass: activateClass,
+                                    payCost: false,
+                                    isTapped: false,
+                                    root: SelectCardEffect.Root.Trash,
+                                    activateETB: true));
+
+                        foreach (CardSource selectedCard in selectedCards)
+                        {
+                            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
+                                                                    targetPermanent: selectedCard.PermanentOfThisCard(),
+                                                                    effectDuration: EffectDuration.UntilOpponentTurnEnd,
+                                                                    activateClass: activateClass));
+                        }
+                    }
+                }
             }
+            #endregion
 
-            bool CanActivateCondition(Hashtable hashtable)
+            #region Opponents Turn
+            if (timing == EffectTiming.WhenWouldDigivolutionCardDiscarded)
             {
-                if (CardEffectCommons.IsExistOnBattleArea(card))
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Trash digivolution cards instead", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
+                cardEffects.Add(activateClass);
+
+                string EffectDiscription()
                 {
-                    if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
+                    return "[Opponent's Turn] When an effect would trash one of your other Digimon's digivolution cards, you may trash this Digimon's digivolution cards instead.";
+                }
+
+                bool PermanentCondition(Permanent permanent)
+                {
+                    if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
+                    {
+                        if (permanent != card.PermanentOfThisCard())
+                        {
+                            return true;
+                        }
+                    }
+
+                    return false;
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    if (CardEffectCommons.CanTriggerOnTrashDigivolutionCard(hashtable, PermanentCondition, cardEffect => true, cardSource => true))
                     {
                         return true;
                     }
+
+                    return false;
                 }
 
-                return false;
-            }
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
+                    {
+                        if (!CardEffectCommons.IsOwnerTurn(card))
+                        {
+                            return true;
+                        }
+                    }
 
-            IEnumerator ActivateCoroutine(Hashtable _hashtable)
-            {
-                if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
+                    return false;
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable _hashtable)
                 {
-                    List<CardSource> selectedCards = new List<CardSource>();
+                    List<CardSource> discardedCards = CardEffectCommons.GetDiscardedCardsFromHashtable(_hashtable);
 
-                    int maxCount = Math.Min(2, card.Owner.TrashCards.Count(CanSelectCardCondition));
+                    if (discardedCards.Count > 0)
+                    {
+                        if(card.PermanentOfThisCard().cardSources.Count >= discardedCards.Count)
+                        {
+                            discardedCards.ForEach(source => source.willBeRemoveSources = false);
 
-                    SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
+                            SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
 
-                    selectCardEffect.SetUp(
-                                canTargetCondition: CanSelectCardCondition,
+                            selectCardEffect.SetUp(
+                                canTargetCondition: (CardSource) => true,
                                 canTargetCondition_ByPreSelecetedList: null,
                                 canEndSelectCondition: null,
-                                canNoSelect: () => true,
-                                selectCardCoroutine: SelectCardCoroutine,
+                                canNoSelect: () => false,
+                                selectCardCoroutine: null,
                                 afterSelectCardCoroutine: null,
-                                message: "Select cards to play.",
-                                maxCount: maxCount,
+                                message: "Select card(s) to trash.",
+                                maxCount: discardedCards.Count,
                                 canEndNotMax: false,
                                 isShowOpponent: true,
-                                mode: SelectCardEffect.Mode.Custom,
-                                root: SelectCardEffect.Root.Trash,
-                                customRootCardList: null,
+                                mode: SelectCardEffect.Mode.Discard,
+                                root: SelectCardEffect.Root.Custom,
+                                customRootCardList: card.PermanentOfThisCard().cardSources,
                                 canLookReverseCard: true,
                                 selectPlayer: card.Owner,
                                 cardEffect: activateClass);
 
-                    selectCardEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards 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.Trash,
-                                activateETB: true));
-
-                    foreach (CardSource selectedCard in selectedCards)
-                    {
-                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
-                                                                targetPermanent: selectedCard.PermanentOfThisCard(),
-                                                                effectDuration: EffectDuration.UntilOpponentTurnEnd,
-                                                                activateClass: activateClass));
+                            yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
+                        }
                     }
                 }
             }
-        }
+            #endregion
 
-        return cardEffects;
+            return cardEffects;
+        }
     }
-}
+}

+ 1 - 1
Assets/Editor/AttachCardData.cs

@@ -12,7 +12,7 @@ public class AttachCardData : MonoBehaviour
     {
         List<CEntity_Base> List = GetAsset.LoadAll<CEntity_Base>("Assets/CardBaseEntity/");
 
-        List<string> UnimplementedCardIDs = new List<string>() { "BT10-084", "P-137", "P-138", "P-139", "P-140", "P-141", "P-142" };
+        List<string> UnimplementedCardIDs = new List<string>() { "P-137", "P-138", "P-139", "P-140", "P-141", "P-142" };
 
         foreach (GameObject obj in Selection.gameObjects)
         {

+ 4 - 0
Assets/Scenes/ContinuousControllerScene.unity

@@ -1061,6 +1061,7 @@ MonoBehaviour:
   - {fileID: 11400000, guid: 26d40164a8b061f43acc297d76295d19, type: 2}
   - {fileID: 11400000, guid: 4bdbba99ed026f6439c3afc08a54481a, type: 2}
   - {fileID: 11400000, guid: 922054ff2cbec7b4984475843a577c7b, type: 2}
+  - {fileID: 11400000, guid: 8a1ce7781be09084e951080f37cd0527, type: 2}
   - {fileID: 11400000, guid: a3250bf560733b04680aa04b263cbd68, type: 2}
   - {fileID: 11400000, guid: cc03a4c8b8ab0a94383656698e5109d8, type: 2}
   - {fileID: 11400000, guid: 0a8595051b2e3294b94865ce88831e3e, type: 2}
@@ -1398,6 +1399,7 @@ MonoBehaviour:
   - {fileID: 11400000, guid: 71c9f0fec34a4734198f77c985a7cb54, type: 2}
   - {fileID: 11400000, guid: 154aedfd140a7b249a8739c9cbf764be, type: 2}
   - {fileID: 11400000, guid: c94daeadd77900e4b9b74b48a49905a5, type: 2}
+  - {fileID: 11400000, guid: 2a43af69032bf5548b68f07e9f17997c, type: 2}
   - {fileID: 11400000, guid: d3300934853d72849ac26165b0bcb557, type: 2}
   - {fileID: 11400000, guid: cc90208a71b5cbf46bf9ee1696797dcd, type: 2}
   - {fileID: 11400000, guid: 450a2e1e102a5114997d33005997f4e4, type: 2}
@@ -6309,6 +6311,7 @@ MonoBehaviour:
   - {fileID: 11400000, guid: 71c9f0fec34a4734198f77c985a7cb54, type: 2}
   - {fileID: 11400000, guid: 154aedfd140a7b249a8739c9cbf764be, type: 2}
   - {fileID: 11400000, guid: c94daeadd77900e4b9b74b48a49905a5, type: 2}
+  - {fileID: 11400000, guid: 2a43af69032bf5548b68f07e9f17997c, type: 2}
   - {fileID: 11400000, guid: 6af0885e857dbbe429f397bcd61c0fdd, type: 2}
   - {fileID: 11400000, guid: 225bf89ccbf61904399ac906c2d8ff3d, type: 2}
   - {fileID: 11400000, guid: 2c61c2dd40881bb4690f5506df1e407f, type: 2}
@@ -6632,6 +6635,7 @@ MonoBehaviour:
   - {fileID: 11400000, guid: 26d40164a8b061f43acc297d76295d19, type: 2}
   - {fileID: 11400000, guid: 4bdbba99ed026f6439c3afc08a54481a, type: 2}
   - {fileID: 11400000, guid: 922054ff2cbec7b4984475843a577c7b, type: 2}
+  - {fileID: 11400000, guid: 8a1ce7781be09084e951080f37cd0527, type: 2}
   - {fileID: 11400000, guid: 7cec6db8cf364674ca6ce81183d89d0a, type: 2}
   - {fileID: 11400000, guid: 01a8e36e2c86afe4d98489acafe82482, type: 2}
   - {fileID: 11400000, guid: 2171d096e9dc3bc4f983e66a4d345547, type: 2}

+ 39 - 5
Assets/Scripts/CardController.cs

@@ -3767,22 +3767,56 @@ public class ITrashDigivolutionCards
         if (_permanent.TopCard == null) yield break;
         if (_permanent.HasNoDigivolutionCards) yield break;
         if (_permanent.TopCard.CanNotBeAffected(_cardEffect)) yield break;
-        _trashTargetCards = _trashTargetCards.Filter((cardSource) => _permanent.DigivolutionCards.Contains(cardSource) && !cardSource.CanNotTrashFromDigivolutionCards(_cardEffect));
+        _trashTargetCards = _trashTargetCards.Filter((cardSource) => 
+            _permanent.DigivolutionCards.Contains(cardSource) && 
+            !cardSource.CanNotTrashFromDigivolutionCards(_cardEffect));
         if (_trashTargetCards.Count == 0) yield break;
 
+        _trashTargetCards.ForEach(source => source.willBeRemoveSources = true);
+
         string message = "Discarded card" + Utils.PluralFormSuffix(_trashTargetCards.Count);
         yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(_trashTargetCards, message, true, true));
 
         yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(_permanent));
 
+        #region cut in effect
+
+        // "When digivolution cards would be trashed" effect
+
+        yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.StackSkillInfos(
+            CardEffectCommons.WhenDigivolutionCardWouldDiscardedCheckHashtable(
+                _permanent,
+                _trashTargetCards,
+                _cardEffect
+            ),
+            EffectTiming.WhenWouldDigivolutionCardDiscarded));
+
+        if (GManager.instance.autoProcessing_CutIn.HasAwaitingActivateEffects())
+        {
+            // effect
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.ShrinkSecurityDigimonDisplay());
+
+            // cut in effect process
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.autoProcessing_CutIn.TriggeredSkillProcess(false, AutoProcessing.HasExecutedSameEffect));
+        }
+        #endregion
+
+        //fix trash target permanent
+        Permanent permanentTarget_Fixed = _permanent;
+
+        // fix delete target sources
+        List<CardSource> trashDigivolutionCards_Fixed = _trashTargetCards.Filter(cardsource =>
+            cardsource != null
+            && cardsource.willBeRemoveSources);
+
         #region "When digivolution cards are trashed" effect
 
         #region Hashtable Setting
         Hashtable hashtable = new Hashtable()
             {
                 {"CardEffect", _cardEffect},
-                {"Permanent", _permanent},
-                {"DiscardedCards", _trashTargetCards},
+                {"Permanent", permanentTarget_Fixed},
+                {"DiscardedCards", trashDigivolutionCards_Fixed},
             };
         #endregion
 
@@ -3791,9 +3825,9 @@ public class ITrashDigivolutionCards
 
         yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(_trashTargetCards).Overflow());
 
-        foreach (CardSource cardSource in _trashTargetCards)
+        foreach (CardSource cardSource in trashDigivolutionCards_Fixed)
         {
-            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, _permanent));
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(cardSource, permanentTarget_Fixed));
 
             yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource));
 

+ 14 - 0
Assets/Scripts/CardEffectCommons/HashtableSetting.cs

@@ -296,4 +296,18 @@ public partial class CardEffectCommons
         };
     }
     #endregion
+
+    #region Hashtable used when check whether the permanent would remove field effect
+    public static Hashtable WhenDigivolutionCardWouldDiscardedCheckHashtable(Permanent targetPermanent, List<CardSource> cardSources, ICardEffect cardEffect)
+    {
+        Hashtable hashtable = new Hashtable()
+        {
+            {"CardEffect", cardEffect},
+            {"Permanent", targetPermanent},
+            {"DiscardedCards", cardSources},
+        };
+
+        return hashtable;
+    }
+    #endregion
 }

+ 7 - 0
Assets/Scripts/CardSource.cs

@@ -1736,9 +1736,16 @@ public class CardSource : MonoBehaviour
     public void SetIsToken(bool isToken) => IsToken = isToken;
     #endregion
 
+    #region Will this card be trashed from sources
+    public bool willBeRemoveSources { get; set; } = false;
+    #endregion
+
     #region whether this card can not be trashed from digivolution cards
     public bool CanNotTrashFromDigivolutionCards(ICardEffect _cardEffect)
     {
+        if (willBeRemoveSources)
+            return true;
+
         #region the effects of permanents
         if (GManager.instance.turnStateMachine.gameContext.Players
             .Map(player => player.GetFieldPermanents())

+ 1 - 0
Assets/Scripts/ICardEffect.cs

@@ -767,6 +767,7 @@ public enum EffectTiming
     OnPermamemtReturnedToHand,
     OnReturnCardsToHandFromTrash,
     AfterEffectsActivate,
+    WhenWouldDigivolutionCardDiscarded,
 }
 #endregion