Selaa lähdekoodia

Remaining changes for Collision

hooperk 4 kuukautta sitten
vanhempi
sitoutus
1fff73ec57

+ 1 - 1
Assets/Scripts/CardEffect/AD1/Blue/AD1_011.cs

@@ -109,7 +109,7 @@ namespace DCGO.CardEffects.AD1
 
                     if (CardEffectCommons.IsJogress(hashtable))
                     {
-                        card.PermanentOfThisCard().UntilEachTurnEndEffects.Add(_timing => PermanentEffectFactory.CanNotSwitchAttackTargetEffect(card.PermanentOfThisCard()));
+                        card.PermanentOfThisCard().UntilEachTurnEndEffects.Add(_timing => PermanentEffectFactory.CanNotSwitchAttackTargetEffect(card.PermanentOfThisCard(), activateClass));
                     }
                 }
             }

+ 2 - 36
Assets/Scripts/CardEffect/BT18/Purple/BT18_083.cs

@@ -157,12 +157,9 @@ namespace DCGO.CardEffects.BT18
 
             if (timing == EffectTiming.None)
             {
-                AddSkillClass addSkillClass = new AddSkillClass();
-                addSkillClass.SetUpICardEffect("Your Digimon gain Collision", CanUseCondition, card);
-                addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
-                cardEffects.Add(addSkillClass);
+                cardEffects.Add(CardEffectFactory.CollisionStaticEffect(PermanentCondition, false, card, CanUseCondition));
 
-                bool CanUseCondition(Hashtable hashtable)
+                bool CanUseCondition()
                 {
                     return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
                 }
@@ -172,37 +169,6 @@ namespace DCGO.CardEffects.BT18
                     return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
                            permanent.DP <= card.PermanentOfThisCard().DP;
                 }
-
-                bool CardSourceCondition(CardSource cardSource)
-                {
-                    if (CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource))
-                    {
-                        if (cardSource == cardSource.PermanentOfThisCard().TopCard)
-                        {
-                            if (PermanentCondition(cardSource.PermanentOfThisCard()))
-                            {
-                                return true;
-                            }
-                        }
-                    }
-
-                    return false;
-                }
-
-                List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
-                {
-                    if (_timing == EffectTiming.OnCounterTiming)
-                    {
-                        bool Condition()
-                        {
-                            return CardSourceCondition(cardSource);
-                        }
-
-                        cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, cardSource, Condition));
-                    }
-
-                    return cardEffects;
-                }
             }
             #endregion
 

+ 4 - 118
Assets/Scripts/CardEffect/BT21/Purple/BT21_077.cs

@@ -132,65 +132,8 @@ namespace DCGO.CardEffects.BT21
 
                                 if (selectedPermanent != null)
                                 {
-                                    AddSkillClass addSkillClass = new AddSkillClass();
-                                    addSkillClass.SetUpICardEffect("Gain Collision", CanUseCondition1, card);
-                                    addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
-                                    selectedPermanent.TopCard.Owner.UntilOwnerTurnEndEffects.Add((_timing) => addSkillClass);
-
-                                    bool CanUseCondition1(Hashtable hashtable)
-                                    {
-                                        return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
-                                    }
-
-                                    bool CardSourceCondition(CardSource cardSource)
-                                    {
-                                        return PermanentCondition(selectedPermanent);
-                                    }
-
-                                    bool PermanentCondition(Permanent permanent)
-                                    {
-                                        if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
-                                        {
-                                            if (!permanent.TopCard.CanNotBeAffected(activateClass))
-                                            {
-                                                if (permanent == selectedPermanent)
-                                                    return true;
-                                            }
-                                        }
-
-                                        return false;
-                                    }
-
-                                    List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
-                                    {
-                                        if (_timing == EffectTiming.OnCounterTiming)
-                                        {
-                                            bool CardSourceCondition(CardSource cardSource)
-                                            {
-                                                if (CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource))
-                                                {
-                                                    if (cardSource == selectedPermanent.TopCard)
-                                                    {
-                                                        if (PermanentCondition(selectedPermanent))
-                                                        {
-                                                            return true;
-                                                        }
-                                                    }
-                                                }
-
-                                                return false;
-                                            }
-
-                                            bool Condition()
-                                            {
-                                                return CardSourceCondition(cardSource);
-                                            }
-
-                                            cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, cardSource, Condition));
-                                        }
-
-                                        return cardEffects;
-                                    }
+                                    CollisionClass collisionClass = PermanentEffectFactory.CollisionEffect(selectedPermanent, activateClass);
+                                    CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOwnerTurnEnd, card: card, cardEffect: collisionClass, timing: EffectTiming.OnCounterTiming);
 
                                     ActivateClass activateClassDebuff = new ActivateClass();
                                     activateClassDebuff.SetUpICardEffect("Attack with this Digimon", CanUseConditionDebuff,
@@ -346,65 +289,8 @@ namespace DCGO.CardEffects.BT21
 
                                 if (selectedPermanent != null)
                                 {
-                                    AddSkillClass addSkillClass = new AddSkillClass();
-                                    addSkillClass.SetUpICardEffect("Gain Collision", CanUseCondition1, card);
-                                    addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
-                                    selectedPermanent.TopCard.Owner.UntilOwnerTurnEndEffects.Add((_timing) => addSkillClass);
-
-                                    bool CanUseCondition1(Hashtable hashtable)
-                                    {
-                                        return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
-                                    }
-
-                                    bool CardSourceCondition(CardSource cardSource)
-                                    {
-                                        return PermanentCondition(selectedPermanent);
-                                    }
-
-                                    bool PermanentCondition(Permanent permanent)
-                                    {
-                                        if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
-                                        {
-                                            if (!permanent.TopCard.CanNotBeAffected(activateClass))
-                                            {
-                                                if (permanent == selectedPermanent)
-                                                    return true;
-                                            }
-                                        }
-
-                                        return false;
-                                    }
-
-                                    List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
-                                    {
-                                        if (_timing == EffectTiming.OnCounterTiming)
-                                        {
-                                            bool CardSourceCondition(CardSource cardSource)
-                                            {
-                                                if (CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource))
-                                                {
-                                                    if (cardSource == selectedPermanent.TopCard)
-                                                    {
-                                                        if (PermanentCondition(selectedPermanent))
-                                                        {
-                                                            return true;
-                                                        }
-                                                    }
-                                                }
-
-                                                return false;
-                                            }
-
-                                            bool Condition()
-                                            {
-                                                return CardSourceCondition(cardSource);
-                                            }
-
-                                            cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, cardSource, Condition));
-                                        }
-
-                                        return cardEffects;
-                                    }
+                                    CollisionClass collisionClass = PermanentEffectFactory.CollisionEffect(selectedPermanent, activateClass);
+                                    CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOwnerTurnEnd, card: card, cardEffect: collisionClass, timing: EffectTiming.OnCounterTiming);
 
                                     ActivateClass activateClassDebuff = new ActivateClass();
                                     activateClassDebuff.SetUpICardEffect("Attack with this Digimon", CanUseConditionDebuff, selectedPermanent.TopCard);

+ 1 - 1
Assets/Scripts/CardEffect/BT23/Blue/BT23_017.cs

@@ -236,7 +236,7 @@ namespace DCGO.CardEffects.BT23
                                 #region Delete Digimon Played
 
                                 yield return ContinuousController.instance.StartCoroutine(
-                                    CardEffectCommons.AddSelfDeleteEffect(playedDigimon, CardEffectCommons.DeleteTiming.AtOpponentTurnEnd));
+                                    CardEffectCommons.AddSelfDeleteEffect(playedDigimon, CardEffectCommons.DeleteTiming.AtOpponentTurnEnd, activateClass));
 
                                 #endregion
                             }

+ 1 - 1
Assets/Scripts/CardEffect/BT23/Green/BT23_037.cs

@@ -176,7 +176,7 @@ namespace DCGO.CardEffects.BT23
                                 #region Delete Digimon Played
 
                                 yield return ContinuousController.instance.StartCoroutine(
-                                    CardEffectCommons.AddSelfDeleteEffect(playedDigimon, CardEffectCommons.DeleteTiming.AtOpponentTurnEnd));
+                                    CardEffectCommons.AddSelfDeleteEffect(playedDigimon, CardEffectCommons.DeleteTiming.AtOpponentTurnEnd, activateClass));
                                 
                                 #endregion
                             }

+ 1 - 1
Assets/Scripts/CardEffect/BT23/Red/BT23_048.cs

@@ -205,7 +205,7 @@ namespace DCGO.CardEffects.BT23
                                 #region Delete Digimon Played
 
                                 yield return ContinuousController.instance.StartCoroutine(
-                                    CardEffectCommons.AddSelfDeleteEffect(playedDigimon, CardEffectCommons.DeleteTiming.AtOpponentTurnEnd));
+                                    CardEffectCommons.AddSelfDeleteEffect(playedDigimon, CardEffectCommons.DeleteTiming.AtOpponentTurnEnd, activateClass));
                                 
                                 #endregion
                             }

+ 1 - 1
Assets/Scripts/CardEffect/EX11/Yellow/EX11_022.cs

@@ -162,7 +162,7 @@ namespace DCGO.CardEffects.EX11
                     if (selectedCard != null)
                     {
                         yield return ContinuousController.instance.StartCoroutine(
-                            CardEffectCommons.AddSelfDeleteEffect(selectedCard.PermanentOfThisCard(), CardEffectCommons.DeleteTiming.AtTurnEnd));
+                            CardEffectCommons.AddSelfDeleteEffect(selectedCard.PermanentOfThisCard(), CardEffectCommons.DeleteTiming.AtTurnEnd, activateClass));
                     }
 
                     #endregion

+ 1 - 61
Assets/Scripts/CardEffect/EX8/Black/EX8_070.cs

@@ -71,37 +71,7 @@ namespace DCGO.CardEffects.EX8
 
                     if (cardsTrashed)
                     {
-                        AddSkillClass addSkillClass = new AddSkillClass();
-                        addSkillClass.SetUpICardEffect("Gain Collision", CanUseCondition1, card);
-                        addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
-
-                        selectedPermanent.TopCard.Owner.UntilOpponentTurnEndEffects.Add((_timing) => addSkillClass);
-
-                        bool CanUseCondition1(Hashtable hashtable)
-                        {
-                            return true;
-                        }
-
-                        bool CardSourceCondition(CardSource cardSource)
-                        {
-                            return PermanentCondition(selectedPermanent);
-                        }
-
-                        bool PermanentCondition(Permanent permanent)
-                        {
-                            if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
-                            {
-                                if (!permanent.TopCard.CanNotBeAffected(activateClass))
-                                {
-                                    if(permanent == selectedPermanent)
-                                        return true;
-                                }
-                            }
-
-                            return false;
-                        }
-
-                        //yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCollision(selectedPermanent, EffectDuration.UntilOpponentTurnEnd, activateClass));
+                        yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCollision(selectedPermanent, EffectDuration.UntilOpponentTurnEnd, activateClass));
                         yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainPierce(selectedPermanent, EffectDuration.UntilOpponentTurnEnd, activateClass));
                         yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainReboot(selectedPermanent, EffectDuration.UntilOpponentTurnEnd, activateClass));
                         yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(selectedPermanent, 3000, EffectDuration.UntilOpponentTurnEnd, activateClass));
@@ -125,36 +95,6 @@ namespace DCGO.CardEffects.EX8
                             activateClass: activateClass,
                             effectName: "Can't return to deck by opponent's effects"));
 
-                        List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
-                        {
-                            if (_timing == EffectTiming.OnCounterTiming)
-                            {
-                                bool CardSourceCondition(CardSource cardSource)
-                                {
-                                    if (CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource))
-                                    {
-                                        if (cardSource == selectedPermanent.TopCard)
-                                        {
-                                            if (PermanentCondition(selectedPermanent))
-                                            {
-                                                return true;
-                                            }
-                                        }
-                                    }
-
-                                    return false;
-                                }
-
-                                bool Condition()
-                                {
-                                    return CardSourceCondition(cardSource);
-                                }
-
-                                cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, cardSource, Condition));
-                            }
-
-                            return cardEffects;
-                        }
                     }
                 }
             }

+ 2 - 2
Assets/Scripts/Script/CardEffectCommons/GiveEffect/GiveEffectToPermanent/DeleteSelf.cs

@@ -11,7 +11,7 @@ public partial class CardEffectCommons
         AtOpponentTurnEnd
     }
 
-    public static IEnumerator AddSelfDeleteEffect(Permanent permanent, DeleteTiming deleteTiming)
+    public static IEnumerator AddSelfDeleteEffect(Permanent permanent, DeleteTiming deleteTiming, ICardEffect activateClass)
     {
         bool deleteOnOwnturn = deleteTiming != DeleteTiming.AtOpponentTurnEnd;
         bool deleteOnOpponentsTurn = deleteTiming != DeleteTiming.AtOwnTurnEnd;
@@ -21,7 +21,7 @@ public partial class CardEffectCommons
         {
             if (timing == EffectTiming.OnEndTurn)
             {
-                return PermanentEffectFactory.DeleteSelfEffect(permanent, deleteOnOwnturn, deleteOnOpponentsTurn);
+                return PermanentEffectFactory.DeleteSelfEffect(permanent, activateClass, deleteOnOwnturn, deleteOnOpponentsTurn);
             }
             return null;
         }

+ 1 - 16
Assets/Scripts/Script/CardEffectCommons/KeyWordEffects/Collision.cs

@@ -19,22 +19,7 @@ public partial class CardEffectCommons
 
         CardSource card = targetPermanent.TopCard;
 
-        bool PermanentCondition(Permanent permanent) => permanent == targetPermanent;
-
-        bool CanUseCondition()
-        {
-            if (IsPermanentExistsOnBattleArea(targetPermanent))
-            {
-                if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
-                {
-                    return true;
-                }
-            }
-
-            return false;
-        }
-
-        CollisionClass collision = CardEffectFactory.CollisionSelfStaticEffect(false, targetPermanent.TopCard, CanUseCondition);
+        CollisionClass collision = PermanentEffectFactory.CollisionEffect(targetPermanent, activateClass);
 
         AddEffectToPermanent(targetPermanent: targetPermanent, effectDuration: effectDuration, card: card, cardEffect: collision, timing: EffectTiming.OnCounterTiming);
 

+ 1 - 1
Assets/Scripts/Script/CardEffectCommons/KeyWordEffects/Execute.cs

@@ -77,7 +77,7 @@ public partial class CardEffectCommons
             {
                 if (timing == EffectTiming.OnEndAttack)
                 {
-                    return PermanentEffectFactory.DeleteSelfEffect(selectedPermanent);
+                    return PermanentEffectFactory.DeleteSelfEffect(selectedPermanent, activateClass);
                 }
                 return null;
             }

+ 3 - 18
Assets/Scripts/Script/CardEffectFactory/KeyWordEffects/Collision.cs

@@ -15,18 +15,9 @@ public partial class CardEffectFactory
         {
             if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
             {
-                if (card.Owner.Enemy.GetBattleAreaDigimons().Count() > 0)
+                if (condition == null || condition())
                 {
-                    if (GManager.instance.attackProcess.IsAttacking)
-                    {
-                        if (GManager.instance.attackProcess.AttackingPermanent == card.PermanentOfThisCard())
-                        {
-                            if (condition == null || condition())
-                            {
-                                return true;
-                            }
-                        }
-                    }     
+                    return true;
                 }
             }
 
@@ -64,13 +55,7 @@ public partial class CardEffectFactory
 
         bool CanUseCondition(Hashtable hashtable)
         {
-            if (condition == null || condition())
-            {
-                if(PermanentCondition(card.PermanentOfThisCard()))
-                    return true;
-            }
-
-            return false;
+            return condition == null || condition();
         }
 
         return collisionClass;

+ 23 - 5
Assets/Scripts/Script/PermanentEffectFactory.cs

@@ -11,7 +11,7 @@ public partial class PermanentEffectFactory
 {
 
     #region Effect of a Permanent to Delete Itself
-    public static ActivateClass DeleteSelfEffect(Permanent permanent, bool deleteOnOwnturn = true, bool deleteOnOpponentsTurn = true)
+    public static ActivateClass DeleteSelfEffect(Permanent permanent, ICardEffect cardEffect, bool deleteOnOwnturn = true, bool deleteOnOpponentsTurn = true)
     {
         ActivateClass activateClass = new ActivateClass();
         activateClass.SetUpICardEffect("Delete this Digimon", CanUseCondition, permanent.TopCard);
@@ -21,7 +21,9 @@ public partial class PermanentEffectFactory
 
         bool CanUseCondition(Hashtable hashtable)
         {
-            if (permanent.TopCard != null && CardEffectCommons.IsExistOnBattleArea(permanent.TopCard))
+            if (permanent.TopCard != null
+                && CardEffectCommons.IsExistOnBattleArea(permanent.TopCard)
+                && !permanent.TopCard.CanNotBeAffected(cardEffect))
             {
                 if (CardEffectCommons.IsOwnerTurn(permanent.TopCard))
                 {
@@ -78,7 +80,7 @@ public partial class PermanentEffectFactory
     #endregion
 
     #region Cannot change Attack Target Effect
-    public static CanNotSwitchAttackTargetClass CanNotSwitchAttackTargetEffect(Permanent targetPermanent)
+    public static CanNotSwitchAttackTargetClass CanNotSwitchAttackTargetEffect(Permanent targetPermanent, ICardEffect activateClass)
     {
         CanNotSwitchAttackTargetClass canNotSwitchAttackTargetClass = new CanNotSwitchAttackTargetClass();
         canNotSwitchAttackTargetClass.SetUpICardEffect("This Digimon's attack target can't be switched.", CanUseCondition, targetPermanent.TopCard);
@@ -87,8 +89,9 @@ public partial class PermanentEffectFactory
 
         bool CanUseCondition(Hashtable hashtable)
         {
-            return CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent) &&
-                    CardEffectCommons.IsOwnerTurn(targetPermanent.TopCard);
+            return CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent)
+                && CardEffectCommons.IsOwnerTurn(targetPermanent.TopCard)
+                && !targetPermanent.TopCard.CanNotBeAffected(activateClass);
         }
 
         bool PermanentCondition(Permanent permanent)
@@ -97,4 +100,19 @@ public partial class PermanentEffectFactory
         }
     }
     #endregion
+
+    #region Gain Collision Effect
+    public static CollisionClass CollisionEffect(Permanent targetPermanent, ICardEffect activateClass)
+    {
+        return CardEffectFactory.CollisionStaticEffect(PermanentCondition, false, targetPermanent.TopCard, CanUseCondition);
+
+        bool CanUseCondition()
+        {
+            return CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent)
+                && !targetPermanent.TopCard.CanNotBeAffected(activateClass);
+        }
+
+        bool PermanentCondition(Permanent permanent) => permanent == targetPermanent;
+    }
+    #endregion
 }